diff options
Diffstat (limited to 'lib/rubygems.rb')
-rw-r--r-- | lib/rubygems.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index ad7ab10756..ba7cf273b9 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -18,6 +18,7 @@ require_relative "rubygems/compatibility" require_relative "rubygems/defaults" require_relative "rubygems/deprecate" require_relative "rubygems/errors" +require_relative "rubygems/target_rbconfig" ## # RubyGems is the Ruby standard for publishing and managing third party @@ -179,6 +180,8 @@ module Gem @discover_gems_on_require = true + @target_rbconfig = nil + ## # Try to activate a gem containing +path+. Returns true if # activation succeeded or wasn't needed because it was already @@ -397,6 +400,23 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} end ## + # The RbConfig object for the deployment target platform. + # + # This is usually the same as the running platform, but may be + # different if you are cross-compiling. + + def self.target_rbconfig + @target_rbconfig || Gem::TargetRbConfig.for_running_ruby + end + + def self.set_target_rbconfig(rbconfig_path) + @target_rbconfig = Gem::TargetRbConfig.from_path(rbconfig_path) + Gem::Platform.local(refresh: true) + Gem.platforms << Gem::Platform.local unless Gem.platforms.include? Gem::Platform.local + @target_rbconfig + end + + ## # Quietly ensure the Gem directory +dir+ contains all the proper # subdirectories. If we can't create a directory due to a permission # problem, then we will silently continue. @@ -450,7 +470,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # distinction as extensions cannot be shared between the two. def self.extension_api_version # :nodoc: - if RbConfig::CONFIG["ENABLE_SHARED"] == "no" + if target_rbconfig["ENABLE_SHARED"] == "no" "#{ruby_api_version}-static" else ruby_api_version @@ -810,7 +830,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # Returns a String containing the API compatibility version of Ruby def self.ruby_api_version - @ruby_api_version ||= RbConfig::CONFIG["ruby_version"].dup + @ruby_api_version ||= target_rbconfig["ruby_version"].dup end def self.env_requirement(gem_name) @@ -1013,6 +1033,13 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} end ## + # Is this platform FreeBSD + + def self.freebsd_platform? + RbConfig::CONFIG["host_os"].to_s.include?("bsd") + end + + ## # Load +plugins+ as Ruby files def self.load_plugin_files(plugins) # :nodoc: |