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

ruby-changes:71661

From: Nobuyoshi <ko1@a...>
Date: Thu, 7 Apr 2022 09:47:27 +0900 (JST)
Subject: [ruby-changes:71661] 5c1b76a3a5 (master): Install built gem extension binaries

https://git.ruby-lang.org/ruby.git/commit/?id=5c1b76a3a5

From 5c1b76a3a55afeb07116bbd3492303c6b6cd890d Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 7 Apr 2022 01:44:43 +0900
Subject: Install built gem extension binaries

---
 tool/rbinstall.rb | 56 ++++++++++++++++---------------------------------------
 1 file changed, 16 insertions(+), 40 deletions(-)

diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 9d9b672be4..624961b4ee 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -853,6 +853,9 @@ module RbInstall https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L853
     def write_cache_file
     end
 
+    def build_extensions
+    end
+
     def shebang(bin_file_name)
       path = File.join(gem_dir, spec.bindir, bin_file_name)
       first_line = File.open(path, "rb") {|file| file.gets}
@@ -935,13 +938,12 @@ install?(:ext, :arch, :gem, :'default-gems', :'default-gems-arch') do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L938
   install_default_gem('ext', srcdir, bindir)
 end
 
-def load_gemspec(file, expanded = false)
+def load_gemspec(file, base = nil)
   file = File.realpath(file)
   code = File.read(file, encoding: "utf-8:-")
   code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\([^\)]*\)/m) do
     files = []
-    if expanded
-      base = File.dirname(file)
+    if base
       Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
         case File.basename(n); when ".", ".."; next; end
         next if File.directory?(File.join(base, n))
@@ -954,7 +956,7 @@ def load_gemspec(file, expanded = false) https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L956
   unless Gem::Specification === spec
     raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
   end
-  spec.loaded_from = file
+  spec.loaded_from = base ? File.join(base, File.basename(file)) : file
   spec.files.reject! {|n| n.end_with?(".gemspec") or n.start_with?(".git")}
 
   spec
@@ -1009,20 +1011,6 @@ def install_default_gem(dir, srcdir, bindir) https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L1011
 end
 
 install?(:ext, :comm, :gem, :'bundled-gems') do
-  if CONFIG['CROSS_COMPILING'] == 'yes'
-    # The following hacky steps set "$ruby = BASERUBY" in tool/fake.rb
-    $hdrdir = ''
-    $extmk = nil
-    $ruby = nil  # ...
-    ruby_path = $ruby + " -I#{Dir.pwd}" # $baseruby + " -I#{Dir.pwd}"
-  else
-    # ruby_path = File.expand_path(with_destdir(File.join(bindir, ruby_install_name)))
-    ENV['RUBYLIB'] = nil
-    ENV['RUBYOPT'] = nil
-    ruby_path = File.expand_path(with_destdir(File.join(bindir, ruby_install_name))) + " --disable=gems -I#{with_destdir(archlibdir)}"
-  end
-  Gem.instance_variable_set(:@ruby, ruby_path) if Gem.ruby != ruby_path
-
   gem_dir = Gem.default_dir
   install_dir = with_destdir(gem_dir)
   prepare "bundled gems", gem_dir
@@ -1042,40 +1030,28 @@ install?(:ext, :comm, :gem, :'bundled-gems') do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L1030
     :wrappers => true,
     :format_executable => true,
   }
-  gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}"
-  extensions_dir = with_destdir(Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir)
+
+  extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir
+  specifications_dir = File.join(gem_dir, "specifications")
+  build_dir = Gem::StubSpecification.gemspec_stub("", ".bundle", ".bundle").extensions_dir
 
   File.foreach("#{srcdir}/gems/bundled_gems") do |name|
     next if /^\s*(?:#|$)/ =~ name
     next unless /^(\S+)\s+(\S+).*/ =~ name
     gem_name = "#$1-#$2"
-    path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec"
-    if File.exist?(path)
-      spec = load_gemspec(path)
-    else
-      path = "#{srcdir}/.bundle/gems/#{gem_name}/#$1.gemspec"
-      next unless File.exist?(path)
-      spec = load_gemspec(path, true)
-    end
+    path = "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
+    next unless File.exist?(path)
+    spec = load_gemspec(path, "#{srcdir}/.bundle/gems/#{gem_name}")
     next unless spec.platform == Gem::Platform::RUBY
     next unless spec.full_name == gem_name
-    if !spec.extensions.empty? && CONFIG["EXTSTATIC"] == "static"
-      puts "skip installation of #{spec.name} #{spec.version}; bundled gem with an extension library is not supported on --with-static-linked-ext"
-      next
-    end
     spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"
-    if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
-      spec.extensions[0] ||= "-"
-    end
     package = RbInstall::DirPackage.new spec
     ins = RbInstall::UnpackedInstaller.new(package, options)
     puts "#{INDENT}#{spec.name} #{spec.version}"
     ins.install
-    unless $dryrun
-      File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
-    end
-    unless spec.extensions.empty?
-      install_recursive(ext, spec.extension_dir)
+    install_recursive("#{build_dir}/#{gem_name}", "#{extensions_dir}/#{gem_name}") do |src, dest|
+      # puts "#{INDENT}    #{dest[extensions_dir.size+gem_name.size+2..-1]}"
+      install src, dest, :mode => (File.executable?(src) ? $prog_mode : $data_mode)
     end
     installed_gems[spec.full_name] = true
   end
-- 
cgit v1.2.1


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

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