diff options
author | なつき <[email protected]> | 2023-03-17 09:16:03 -0700 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-03-23 17:18:49 +0900 |
commit | 22d037f4ccd6d04cd1ee9aa7dd6f0e6019b5df2b (patch) | |
tree | b0c7ba390f5faf8a0a875168f17b1ea777ebb190 /lib | |
parent | e46d473396401f8f320b4a5b8f638630ab42fa4c (diff) |
Move duplicated logic to parent class
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7582
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/ext/builder.rb | 13 | ||||
-rw-r--r-- | lib/rubygems/ext/ext_conf_builder.rb | 14 | ||||
-rw-r--r-- | lib/rubygems/ext/rake_builder.rb | 14 |
3 files changed, 15 insertions, 26 deletions
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb index b52ba0d5dd..adb118133d 100644 --- a/lib/rubygems/ext/builder.rb +++ b/lib/rubygems/ext/builder.rb @@ -54,6 +54,19 @@ class Gem::Ext::Builder end end + def self.rubygems_load_path + # This load_path is only needed when running rubygems test without a proper installation. + # Prepending it in a normal installation will cause problem with order of $LOAD_PATH. + # Therefore only add load_path if it is not present in the default $LOAD_PATH. + load_path = File.expand_path("../..", __dir__) + case load_path + when RbConfig::CONFIG["sitelibdir"], RbConfig::CONFIG["vendorlibdir"], RbConfig::CONFIG["rubylibdir"] + [] + else + ["-I#{load_path}"] + end + end + def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {}) verbose = Gem.configuration.really_verbose diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index f8fed2a8bf..22e740fde8 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -21,22 +21,10 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder destdir = ENV["DESTDIR"] - # This is only needed when running rubygems test without a proper installation. - # Prepending it in a normal installation can cause problem with order of $LOAD_PATH. - # Therefore only add rubygems_load_path if it is not present in the default $LOAD_PATH. - rubygems_load_path = File.expand_path("../..", __dir__) - load_path = - case rubygems_load_path - when RbConfig::CONFIG["sitelibdir"], RbConfig::CONFIG["vendorlibdir"], RbConfig::CONFIG["rubylibdir"] - [] - else - ["-I#{rubygems_load_path}"] - end - begin require "shellwords" cmd = Gem.ruby.shellsplit - cmd.push(*load_path) + cmd.push(*rubygems_load_path) cmd << File.basename(extension) cmd.push(*args) diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb index 9a3f8ca65e..ce5c10e505 100644 --- a/lib/rubygems/ext/rake_builder.rb +++ b/lib/rubygems/ext/rake_builder.rb @@ -18,20 +18,8 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder require "shellwords" rake = rake.shellsplit else - # This is only needed when running rubygems test without a proper installation. - # Prepending it in a normal installation can cause problem with order of $LOAD_PATH. - # Therefore only add rubygems_load_path if it is not present in the default $LOAD_PATH. - rubygems_load_path = File.expand_path("../..", __dir__) - load_path = - case rubygems_load_path - when RbConfig::CONFIG["sitelibdir"], RbConfig::CONFIG["vendorlibdir"], RbConfig::CONFIG["rubylibdir"] - [] - else - ["-I#{rubygems_load_path}"] - end - begin - rake = [Gem.ruby, *load_path, "-rrubygems", Gem.bin_path("rake", "rake")] + rake = [Gem.ruby, *rubygems_load_path, "-rrubygems", Gem.bin_path("rake", "rake")] rescue Gem::Exception rake = [Gem.default_exec_format % "rake"] end |