[前][次][番号順一覧][スレッド一覧]

ruby-changes:43877

From: nobu <ko1@a...>
Date: Wed, 17 Aug 2016 23:14:51 +0900 (JST)
Subject: [ruby-changes:43877] nobu:r55950 (trunk): gem extensions

nobu	2016-08-17 23:14:44 +0900 (Wed, 17 Aug 2016)

  New Revision: 55950

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55950

  Log:
    gem extensions
    
    * ext/extmk.rb: build gem extensions into separate directories
    * tool/rbinstall.rb: install pre-built gem extension files gem
      extension directories.  [ruby-core:76931] [Bug #12681]

  Modified files:
    trunk/ChangeLog
    trunk/ext/extmk.rb
    trunk/tool/rbinstall.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55949)
+++ ChangeLog	(revision 55950)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Aug 17 23:14:42 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/extmk.rb: build gem extensions into separate directories
+
+	* tool/rbinstall.rb: install pre-built gem extension files gem
+	  extension directories.  [ruby-core:76931] [Bug #12681]
+
 Tue Aug 16 21:04:30 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (UNICODE_HDR_DIR): separate unicode header files from
Index: ext/extmk.rb
===================================================================
--- ext/extmk.rb	(revision 55949)
+++ ext/extmk.rb	(revision 55950)
@@ -565,12 +565,24 @@ end https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L565
 
 Dir.chdir('..')
 FileUtils::makedirs('gems')
-FileUtils::makedirs('.ext/gems')
+FileUtils::makedirs("#$extout/gems")
 Dir.chdir('gems')
 extout = $extout
 gems.each do |d|
   $extout = extout.dup
   extmake(d, 'gems')
+  open("#{d}/Makefile", "r+b") do |f|
+    mf = f.read
+    f.rewind
+    mf.sub!(/^RUBYARCHDIR *= *(\$\(extout\))\/(\$\(arch\))(.*)/) {
+      "TARGET_SO_DIR = #$1/gems/#$2/#{d[%r{\A[^/]+}]}#$3\n" \
+      "TARGET_SO_TIME = .gems.-.arch.-.#{d[/\A[^\/]+/]}.time"
+    }
+    mf.gsub!(/\bRUBYARCHDIR\b/, 'TARGET_SO_DIR')
+    mf.gsub!(/\.TARGET_SO_DIR\.time/, '$(TARGET_SO_TIME)')
+    f.write(mf)
+    f.truncate(f.pos)
+  end
 end
 $extout = extout
 Dir.chdir('../ext')
Index: tool/rbinstall.rb
===================================================================
--- tool/rbinstall.rb	(revision 55949)
+++ tool/rbinstall.rb	(revision 55950)
@@ -678,6 +678,9 @@ module RbInstall https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L678
 
     def write_cache_file
     end
+
+    def build_extensions
+    end
   end
 end
 
@@ -750,11 +753,21 @@ install?(:ext, :comm, :gem) do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L753
     :wrappers => true,
     :format_executable => true,
   }
+  gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}"
+  extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir
   Gem::Specification.each_spec([srcdir+'/gems/*']) do |spec|
+    spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"
+    if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
+      spec.extensions[0] ||= "-"
+    end
     ins = RbInstall::UnpackedInstaller.new(spec, options)
     puts "#{" "*30}#{spec.name} #{spec.version}"
     ins.install
     File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
+    unless spec.extensions.empty?
+      install_recursive(ext, spec.extension_dir)
+      open_for_install(spec.gem_build_complete_path, $data_mode) {""}
+    end
     installed_gems[spec.full_name] = true
   end
   installed_gems, gems = Dir.glob(srcdir+'/gems/*.gem').partition {|gem| installed_gems.key?(File.basename(gem, '.gem'))}

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]