From 9839d82d1efe7466b0a9dc8f1d3a86f1ef5e332b Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 17 Aug 2016 14:14:44 +0000 Subject: [PATCH] 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/extmk.rb | 14 +++++++++++++- tool/rbinstall.rb | 13 +++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 91ed884668..8c52c54cd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Aug 17 23:14:42 2016 Nobuyoshi Nakada + + * 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 * common.mk (UNICODE_HDR_DIR): separate unicode header files from diff --git a/ext/extmk.rb b/ext/extmk.rb index aa9b0d80ea..a65a281617 100755 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -565,12 +565,24 @@ end 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') diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 104d5ff98f..28315f8bff 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -678,6 +678,9 @@ module RbInstall def write_cache_file end + + def build_extensions + end end end @@ -750,11 +753,21 @@ install?(:ext, :comm, :gem) do :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'))}