summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2022-10-15 16:31:00 +0900
committernagachika <nagachika@ruby-lang.org>2022-10-15 16:31:00 +0900
commit47dc4037166354dc929b5759b0a1ed065f8d716f (patch)
tree97f29496cc29133f93ab5c13c36b5db983ba4c6b /tool
parent21c876d3ca0980c23f55bea4e1fd0328de3395ae (diff)
merge revision(s) 5c1b76a3a55afeb07116bbd3492303c6b6cd890d:
Install built gem extension binaries --- tool/rbinstall.rb | 56 ++++++++++++++++--------------------------------------- 1 file changed, 16 insertions(+), 40 deletions(-)
Diffstat (limited to 'tool')
-rwxr-xr-xtool/rbinstall.rb56
1 files changed, 16 insertions, 40 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
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
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)
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)
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
: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