ruby-changes:72229
From: nagachika <ko1@a...>
Date: Sat, 18 Jun 2022 16:38:08 +0900 (JST)
Subject: [ruby-changes:72229] d56b2e8820 (ruby_3_1): merge revision(s) 5c1b76a3a55afeb07116bbd3492303c6b6cd890d: [Backport #18373]
https://git.ruby-lang.org/ruby.git/commit/?id=d56b2e8820 From d56b2e8820efd40840443ce3a5d16cff32a090c7 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sat, 18 Jun 2022 16:37:46 +0900 Subject: merge revision(s) 5c1b76a3a55afeb07116bbd3492303c6b6cd890d: [Backport #18373] Install built gem extension binaries --- tool/rbinstall.rb | 56 ++++++++++++++++--------------------------------------- 1 file changed, 16 insertions(+), 40 deletions(-) --- tool/rbinstall.rb | 56 ++++++++++++++++--------------------------------------- version.h | 2 +- 2 files changed, 17 insertions(+), 41 deletions(-) diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 0b1195e360..e4cb17c8ed 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -848,6 +848,9 @@ module RbInstall https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L848 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} @@ -930,13 +933,12 @@ install?(:ext, :arch, :gem, :'default-gems', :'default-gems-arch') do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L933 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)) @@ -949,7 +951,7 @@ def load_gemspec(file, expanded = false) https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L951 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 @@ -1004,20 +1006,6 @@ def install_default_gem(dir, srcdir, bindir) https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L1006 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 @@ -1037,40 +1025,28 @@ install?(:ext, :comm, :gem, :'bundled-gems') do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L1025 :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 diff --git a/version.h b/version.h index c282c5df14..0cfe3f6c38 100644 --- a/version.h +++ b/version.h @@ -11,7 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 35 +#define RUBY_PATCHLEVEL 36 #define RUBY_RELEASE_YEAR 2022 #define RUBY_RELEASE_MONTH 6 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/