summaryrefslogtreecommitdiff
path: root/lib/rubygems/ext/builder.rb
diff options
authorYuta Saito <[email protected]>2024-05-04 21:23:36 +0000
committergit <[email protected]>2024-06-18 00:59:35 +0000
commit273d41b9e3c90d4d3fe2ffcb88477197d528b9a0 (patch)
tree4449b79880de2d84cd1e82651f61902db35aeb8e /lib/rubygems/ext/builder.rb
parent91bbb7831301f405c56b5de1bd9e7a79f4d302b5 (diff)
[rubygems/rubygems] Add `--target-rbconfig` option to `gem install` and `gem update` commands
This patch adds `--target-rbconfig` option to specify the rbconfig.rb file for the deployment target platform. This is useful when cross-compiling gems. At the moment, this option is only available for `extconf.rb`-based extensions. https://github.com/rubygems/rubygems/commit/cf2843f7a2
Diffstat (limited to 'lib/rubygems/ext/builder.rb')
-rw-r--r--lib/rubygems/ext/builder.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index be1ba3031c..12eb62ef16 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -19,13 +19,14 @@ class Gem::Ext::Builder
$1.downcase
end
- def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = ["clean", "", "install"])
+ def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = ["clean", "", "install"],
+ target_rbconfig: Gem.target_rbconfig)
unless File.exist? File.join(make_dir, "Makefile")
raise Gem::InstallError, "Makefile not found"
end
# try to find make program from Ruby configure arguments first
- RbConfig::CONFIG["configure_args"] =~ /with-make-prog\=(\w+)/
+ target_rbconfig["configure_args"] =~ /with-make-prog\=(\w+)/
make_program_name = ENV["MAKE"] || ENV["make"] || $1
make_program_name ||= RUBY_PLATFORM.include?("mswin") ? "nmake" : "make"
make_program = Shellwords.split(make_program_name)
@@ -131,10 +132,11 @@ class Gem::Ext::Builder
# have build arguments, saved, set +build_args+ which is an ARGV-style
# array.
- def initialize(spec, build_args = spec.build_args)
+ def initialize(spec, build_args = spec.build_args, target_rbconfig = Gem.target_rbconfig)
@spec = spec
@build_args = build_args
@gem_dir = spec.full_gem_path
+ @target_rbconfig = target_rbconfig
@ran_rake = false
end
@@ -191,7 +193,7 @@ EOF
FileUtils.mkdir_p dest_path
results = builder.build(extension, dest_path,
- results, @build_args, lib_dir, extension_dir)
+ results, @build_args, lib_dir, extension_dir, @target_rbconfig)
verbose { results.join("\n") }