summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-25 03:26:36 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-25 03:26:36 +0000
commit369697bcebcfd05a2b7d541d59a85fa529cfe6c9 (patch)
tree84ee86a60d6ec70522b79996c5d5d7ca2c068a45 /lib
parentf90fdbfc73ff41570a068b410692acd4812ef9f5 (diff)
Import fast-loading gem_prelude.rb from RubyGems.
Import RubyGems r1516. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems.rb35
-rw-r--r--lib/rubygems/installer.rb9
-rw-r--r--lib/rubygems/platform.rb9
-rw-r--r--lib/rubygems/require_paths_builder.rb15
4 files changed, 53 insertions, 15 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 184461b4d0..f233b520f1 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -5,7 +5,6 @@
# See LICENSE.txt for permissions.
#++
-require 'rbconfig'
require 'rubygems/rubygems_version'
require 'thread'
@@ -82,11 +81,25 @@ end
#
module Gem
+ ConfigMap = {} unless defined?(ConfigMap)
+ require 'rbconfig'
+ ConfigMap.merge!(
+ :sitedir => RbConfig::CONFIG["sitedir"],
+ :ruby_version => RbConfig::CONFIG["ruby_version"],
+ :libdir => RbConfig::CONFIG["libdir"],
+ :sitelibdir => RbConfig::CONFIG["sitelibdir"],
+ :arch => RbConfig::CONFIG["arch"],
+ :bindir => RbConfig::CONFIG["bindir"],
+ :EXEEXT => RbConfig::CONFIG["EXEEXT"],
+ :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
+ :ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
+ )
+
MUTEX = Mutex.new
RubyGemsPackageVersion = RubyGemsVersion
- DIRECTORIES = %w[cache doc gems specifications]
+ DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
@@source_index = nil
@@win_platform = nil
@@ -120,7 +133,7 @@ module Gem
def self.prefix
prefix = File.dirname File.expand_path(__FILE__)
- if prefix == Config::CONFIG['sitelibdir'] then
+ if prefix == ConfigMap[:sitelibdir] then
nil
else
File.dirname prefix
@@ -221,7 +234,7 @@ module Gem
if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
'/usr/bin'
else # generic install
- Config::CONFIG['bindir']
+ ConfigMap[:bindir]
end
end
@@ -280,9 +293,9 @@ module Gem
# Return the Ruby command to use to execute the Ruby interpreter.
def ruby
if @ruby.nil? then
- @ruby = File.join(Config::CONFIG['bindir'],
- Config::CONFIG['ruby_install_name'])
- @ruby << Config::CONFIG['EXEEXT']
+ @ruby = File.join(ConfigMap[:bindir],
+ ConfigMap[:ruby_install_name])
+ @ruby << ConfigMap[:EXEEXT]
end
@ruby
@@ -342,7 +355,7 @@ module Gem
File.join spec.full_gem_path, path
end
- sitelibdir = Config::CONFIG['sitelibdir']
+ sitelibdir = ConfigMap[:sitelibdir]
# gem directories must come after -I and ENV['RUBYLIB']
$:.insert($:.index(sitelibdir), *require_paths)
@@ -529,9 +542,9 @@ module Gem
# not specified in the environment.
def default_dir
if defined? RUBY_FRAMEWORK_VERSION
- return File.join(File.dirname(Config::CONFIG["sitedir"]), "Gems", Config::CONFIG['ruby_version'])
+ return File.join(File.dirname(ConfigMap[:sitedir]), "Gems", ConfigMap[:ruby_version])
else
- File.join(Config::CONFIG['libdir'], 'ruby', 'gems', Config::CONFIG['ruby_version'])
+ File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
end
end
@@ -549,7 +562,7 @@ module Config # :nodoc:
# Return the path to the data directory associated with the named
# package. If the package is loaded as a gem, return the gem
# specific data directory. Otherwise return a path to the share
- # area as define by "#{Config::CONFIG['datadir']}/#{package_name}".
+ # area as define by "#{ConfigMap[:datadir]}/#{package_name}".
def datadir(package_name)
Gem.datadir(package_name) || Config.gem_original_datadir(package_name)
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 03f7c92828..46d0144a88 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -10,6 +10,7 @@ require 'rbconfig'
require 'rubygems/format'
require 'rubygems/ext'
+require 'rubygems/require_paths_builder'
##
# The installer class processes RubyGem .gem files and installs the
@@ -27,6 +28,8 @@ class Gem::Installer
class ExtensionBuildError < Gem::InstallError; end
include Gem::UserInteraction
+
+ include Gem::RequirePathsBuilder
##
# Constructs an Installer instance that will install the gem located at
@@ -111,6 +114,8 @@ class Gem::Installer
generate_bin
build_extensions
write_spec
+
+ write_require_paths_file_if_needed
# HACK remove? Isn't this done in multiple places?
cached_gem = File.join @gem_home, "cache", @gem.split(/\//).pop
@@ -235,8 +240,8 @@ class Gem::Installer
# the symlink if the gem being installed has a newer version.
#
def generate_bin_symlink(filename, bindir)
- if Config::CONFIG["arch"] =~ /dos|win32/i then
- alert_warning "Unable to use symlinks on win32, installing wrapper"
+ if Gem.win_platform? then
+ alert_warning "Unable to use symlinks on Windows, installing wrapper"
generate_bin_script filename, bindir
return
end
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 24081d4fec..496c4b1fb8 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -13,7 +13,7 @@ class Gem::Platform
attr_accessor :version
def self.local
- arch = Config::CONFIG['arch']
+ arch = Gem::ConfigMap[:arch]
arch = "#{arch}_60" if arch =~ /mswin32$/
@local ||= new(arch)
end
@@ -27,6 +27,8 @@ class Gem::Platform
def self.new(arch) # :nodoc:
case arch
+ when Gem::Platform::CURRENT then
+ Gem::Platform.local
when Gem::Platform::RUBY, nil, '' then
Gem::Platform::RUBY
else
@@ -71,7 +73,10 @@ class Gem::Platform
when /^java([\d.]*)/ then [ 'java', $1 ]
when /linux/ then [ 'linux', $1 ]
when /mingw32/ then [ 'mingw32', nil ]
- when /(mswin\d+)(\_(\d+))?/ then [ $1, $3 ]
+ when /(mswin\d+)(\_(\d+))?/ then
+ os, version = $1, $3
+ @cpu = 'x86' if @cpu.nil? and os =~ /32$/
+ [os, version]
when /netbsdelf/ then [ 'netbsdelf', nil ]
when /openbsd(\d+\.\d+)/ then [ 'openbsd', $1 ]
when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
diff --git a/lib/rubygems/require_paths_builder.rb b/lib/rubygems/require_paths_builder.rb
new file mode 100644
index 0000000000..fe4f593bf4
--- /dev/null
+++ b/lib/rubygems/require_paths_builder.rb
@@ -0,0 +1,15 @@
+module Gem
+ module RequirePathsBuilder
+ def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home)
+ return if spec.require_paths == ["lib"] && (spec.bindir.nil? || spec.bindir == "bin")
+ file_name = File.join(gem_home, 'gems', "#{@spec.full_name}", ".require_paths")
+ file_name.untaint
+ File.open(file_name, "w") do |file|
+ spec.require_paths.each do |path|
+ file.puts path
+ end
+ file.puts spec.bindir if spec.bindir
+ end
+ end
+ end
+end \ No newline at end of file