Skip to content
This repository
Browse code

Use RbConfig instead of Config

  • Loading branch information...
commit bd6aef7fcda541f3da68677688aa1d05f923d5f7 1 parent b3033b4
Dirkjan Bussink dbussink authored
2  Rakefile
@@ -33,7 +33,7 @@ unless BUILD_CONFIG[:which_ruby] == :ruby or BUILD_CONFIG[:which_ruby] == :rbx
33 33 exit 1
34 34 end
35 35
36   -$dlext = Config::CONFIG["DLEXT"]
  36 +$dlext = RbConfig::CONFIG["DLEXT"]
37 37
38 38 task :default => %w[build vm:test] do
39 39 unless File.directory? BUILD_CONFIG[:runtime]
4 benchmark/yarv/report.rb
@@ -25,8 +25,8 @@ def exec_command type, file, w
25 25
26 26 def benchmark cmd
27 27 rubybin = ENV['RUBY'] || File.join(
28   - Config::CONFIG["bindir"],
29   - Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"])
  28 + RbConfig::CONFIG["bindir"],
  29 + RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"])
30 30
31 31 IO.popen(rubybin, 'r+'){|io|
32 32 io.write cmd
4 benchmark/yarv/runc.rb
@@ -6,8 +6,8 @@
6 6 require 'rbconfig'
7 7
8 8 $rubybin = ENV['RUBY'] || File.join(
9   - Config::CONFIG["bindir"],
10   - Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"])
  9 + RbConfig::CONFIG["bindir"],
  10 + RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"])
11 11
12 12 def runfile file
13 13 puts file
8 configure
@@ -70,7 +70,7 @@ class Configure
70 70 end
71 71
72 72 # TODO: add conditionals for platforms
73   - if Config::CONFIG["build_os"] =~ /darwin/
  73 + if RbConfig::CONFIG["build_os"] =~ /darwin/
74 74 @ldshared = "cc -dynamic -bundle -undefined suppress -flat_namespace"
75 75 else
76 76 @ldshared = "cc -shared"
@@ -571,9 +571,9 @@ class Configure
571 571 # script. That path will be made available to the rest of the build system
572 572 # so the same version of ruby is invoked as needed.
573 573 def build_ruby
574   - bin = Config::CONFIG["RUBY_INSTALL_NAME"] || Config::CONFIG["ruby_install_name"]
575   - bin << (Config::CONFIG['EXEEXT'] || Config::CONFIG['exeext'] || '')
576   - File.join(Config::CONFIG['bindir'], bin)
  574 + bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
  575 + bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
  576 + File.join(RbConfig::CONFIG['bindir'], bin)
577 577 end
578 578
579 579 def get_system_name
2  lib/ext/dl/extconf.rb
@@ -22,7 +22,7 @@
22 22
23 23 ($CPPFLAGS || $CFLAGS) << " -I."
24 24
25   -if (Config::CONFIG['CC'] =~ /gcc/) # from Win32API
  25 +if (RbConfig::CONFIG['CC'] =~ /gcc/) # from Win32API
26 26 $CFLAGS << " -fno-defer-pop -fno-omit-frame-pointer"
27 27 end
28 28
4 lib/ext/melbourne/Rakefile
@@ -46,8 +46,8 @@ when ["build:mri"]
46 46 puts "Building Melbourne for MRI"
47 47 add_mri_capi
48 48 set_ext_dir "ruby"
49   - add_link_dir Config::CONFIG["libdir"]
50   - add_ldflag Config::CONFIG["LIBRUBYARG"]
  49 + add_link_dir RbConfig::CONFIG["libdir"]
  50 + add_ldflag RbConfig::CONFIG["LIBRUBYARG"]
51 51 end
52 52
53 53 add_objects project_files, ext_dir
52 lib/mkmf.rb
@@ -5,7 +5,7 @@
5 5 require 'fileutils'
6 6 require 'shellwords'
7 7
8   -CONFIG = Config::MAKEFILE_CONFIG
  8 +CONFIG = RbConfig::MAKEFILE_CONFIG
9 9 ORIG_LIBPATH = ENV['LIB']
10 10
11 11 CXX_EXT = %w[cc cxx cpp]
@@ -326,28 +326,28 @@ def try_do(src, command, &b)
326 326 end
327 327
328 328 def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
329   - conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote,
330   - 'src' => CONFTEST_C,
331   - 'INCFLAGS' => $INCFLAGS,
332   - 'CPPFLAGS' => $CPPFLAGS,
333   - 'CFLAGS' => "#$CFLAGS",
334   - 'ARCH_FLAG' => "#$ARCH_FLAG",
335   - 'LDFLAGS' => "#$LDFLAGS #{ldflags}",
336   - 'LIBPATH' => libpathflag(libpath),
337   - 'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
338   - 'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
339   - Config::expand(TRY_LINK.dup, conf)
  329 + conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote,
  330 + 'src' => CONFTEST_C,
  331 + 'INCFLAGS' => $INCFLAGS,
  332 + 'CPPFLAGS' => $CPPFLAGS,
  333 + 'CFLAGS' => "#$CFLAGS",
  334 + 'ARCH_FLAG' => "#$ARCH_FLAG",
  335 + 'LDFLAGS' => "#$LDFLAGS #{ldflags}",
  336 + 'LIBPATH' => libpathflag(libpath),
  337 + 'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
  338 + 'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
  339 + RbConfig::expand(TRY_LINK.dup, conf)
340 340 end
341 341
342 342 def cc_command(opt="")
343   - conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
344   - Config::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
  343 + conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
  344 + RbConfig::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
345 345 conf)
346 346 end
347 347
348 348 def cpp_command(outfile, opt="")
349   - conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
350   - Config::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
  349 + conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
  350 + RbConfig::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
351 351 conf)
352 352 end
353 353
@@ -551,7 +551,7 @@ def install_files(mfile, ifiles, map = nil, srcprefix = nil)
551 551 ifiles or return
552 552 ifiles.empty? and return
553 553 srcprefix ||= '$(srcdir)'
554   - Config::expand(srcdir = srcprefix.dup)
  554 + RbConfig::expand(srcdir = srcprefix.dup)
555 555 dirs = []
556 556 path = Hash.new {|h, i| h[i] = dirs.push([i])[-1]}
557 557 ifiles.each do |files, dir, prefix|
@@ -1338,7 +1338,7 @@ def configuration(srcdir)
1338 1338 RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']}
1339 1339 arch = #{CONFIG['arch']}
1340 1340 sitearch = #{CONFIG['sitearch']}
1341   -ruby_version = #{Config::CONFIG['ruby_version']}
  1341 +ruby_version = #{RbConfig::CONFIG['ruby_version']}
1342 1342 ruby = #{$ruby}
1343 1343 RUBY = $(ruby#{sep})
1344 1344 RM = #{config_string('RM') || '$(RUBY) -run -e rm -- -f'}
@@ -1401,7 +1401,7 @@ def dummy_makefile(srcdir)
1401 1401 # Makefile.
1402 1402 #
1403 1403 # Setting the +target_prefix+ will, in turn, install the generated binary in
1404   -# a directory under your Config::CONFIG['sitearchdir'] that mimics your local
  1404 +# a directory under your RbConfig::CONFIG['sitearchdir'] that mimics your local
1405 1405 # filesystem when you run 'make install'.
1406 1406 #
1407 1407 # For example, given the following file tree:
@@ -1449,7 +1449,7 @@ def create_makefile(target, srcprefix = nil)
1449 1449 end
1450 1450
1451 1451 srcprefix ||= '$(srcdir)'
1452   - Config::expand(srcdir = srcprefix.dup)
  1452 + RbConfig::expand(srcdir = srcprefix.dup)
1453 1453
1454 1454 if not $objs
1455 1455 $objs = []
@@ -1721,7 +1721,7 @@ def init_mkmf(config = CONFIG)
1721 1721 $objs = nil
1722 1722 $srcs = nil
1723 1723 $libs = ""
1724   - if $enable_shared or Config.expand(config["LIBRUBY"].dup) != Config.expand(config["LIBRUBY_A"].dup)
  1724 + if $enable_shared or RbConfig.expand(config["LIBRUBY"].dup) != RbConfig.expand(config["LIBRUBY_A"].dup)
1725 1725 $LIBRUBYARG = config['LIBRUBYARG']
1726 1726 end
1727 1727
@@ -1772,20 +1772,20 @@ def mkmf_failed(path)
1772 1772 $nmake = ?b if /Borland/i =~ `#{make} -h`
1773 1773 end
1774 1774
1775   -Config::CONFIG["srcdir"] = CONFIG["srcdir"] =
  1775 +RbConfig::CONFIG["srcdir"] = CONFIG["srcdir"] =
1776 1776 $srcdir = arg_config("--srcdir", File.dirname($0))
1777 1777 $configure_args["--topsrcdir"] ||= $srcdir
1778 1778 if $curdir = arg_config("--curdir")
1779   - Config.expand(curdir = $curdir.dup)
  1779 + RbConfig.expand(curdir = $curdir.dup)
1780 1780 else
1781 1781 curdir = $curdir = "."
1782 1782 end
1783   -unless File.expand_path(Config::CONFIG["topdir"]) == File.expand_path(curdir)
  1783 +unless File.expand_path(RbConfig::CONFIG["topdir"]) == File.expand_path(curdir)
1784 1784 CONFIG["topdir"] = $curdir
1785   - Config::CONFIG["topdir"] = curdir
  1785 + RbConfig::CONFIG["topdir"] = curdir
1786 1786 end
1787 1787 $configure_args["--topdir"] ||= $curdir
1788   -$ruby = arg_config("--ruby", File.join(Config::CONFIG["bindir"], CONFIG["ruby_install_name"]))
  1788 +$ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"]))
1789 1789
1790 1790 split = Shellwords.method(:shellwords).to_proc
1791 1791
10 lib/rbconfig.rb
... ... @@ -1,6 +1,6 @@
1 1 require 'rubinius/build_config'
2 2
3   -module Config
  3 +module RbConfig
4 4 unless defined? RUBY_ENGINE and RUBY_ENGINE == "rbx" then
5 5 raise "Looks like you loaded the Rubinius rbconfig, but this is not Rubinius."
6 6 end
@@ -168,7 +168,7 @@ module Config
168 168 MAKEFILE_CONFIG = {}
169 169 CONFIG.each { |k,v| MAKEFILE_CONFIG[k] = v.kind_of?(String) ? v.dup : v }
170 170
171   - def Config.expand(val, config = CONFIG)
  171 + def RbConfig.expand(val, config = CONFIG)
172 172 return val unless val.kind_of? String
173 173
174 174 val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var|
@@ -177,7 +177,7 @@ def Config.expand(val, config = CONFIG)
177 177 elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
178 178 pat, sub = $1, $2
179 179 config[v] = false
180   - Config.expand(key, config)
  180 + RbConfig.expand(key, config)
181 181 config[v] = key
182 182 key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
183 183 key
@@ -189,9 +189,9 @@ def Config.expand(val, config = CONFIG)
189 189 end
190 190
191 191 CONFIG.each_value do |val|
192   - Config.expand(val)
  192 + RbConfig.expand(val)
193 193 end
194 194 end
195 195
196 196 CROSS_COMPILING = nil unless defined? CROSS_COMPILING
197   -RbConfig = Config
  197 +Config = RbConfig
2  rakelib/ext_helper.rb
@@ -9,7 +9,7 @@ def env(name, default = "")
9 9 # Common settings. These can be augmented or overridden
10 10 # by the particular extension Rakefile.
11 11 #
12   -DEFAULT = Config::CONFIG
  12 +DEFAULT = RbConfig::CONFIG
13 13
14 14 # Don't like the globals? Too bad, they are simple and the
15 15 # duration of this process is supposed to be short.
18 spec/library/config/rbconfig_spec.rb
@@ -6,7 +6,7 @@
6 6 # However, the specs are valuable in that they will ensure
7 7 # that rbconfig loads and contains required values.
8 8 #
9   -# The Config entries fall into two general categories:
  9 +# The RbConfig entries fall into two general categories:
10 10 # 1) the static-value entries; and 2) the configured-
11 11 # value entries. For the second one, the specs check
12 12 # only for the existence of a key.
@@ -39,14 +39,14 @@ def it_has_entries(name, entries)
39 39 end
40 40 end
41 41
42   -describe "RbConfig" do
43   - it "is equal to Config" do
44   - RbConfig.should eql(Config)
  42 +describe "Config" do
  43 + it "is equal to RbConfig" do
  44 + Config.should eql(RbConfig)
45 45 end
46 46 end
47 47
48 48 # TODO: many more specs needed
49   -describe "Config::CONFIG" do
  49 +describe "RbConfig::CONFIG" do
50 50 keys = [
51 51 "LDSHARED",
52 52 "DLEXT",
@@ -61,7 +61,7 @@ def it_has_entries(name, entries)
61 61 "bindir"
62 62 ]
63 63
64   - it_has_keys 'Config::CONFIG', keys
  64 + it_has_keys 'RbConfig::CONFIG', keys
65 65
66 66 entries = {
67 67 "RUBY_SO_NAME" => "rubinius-#{Rubinius::VERSION}",
@@ -69,10 +69,10 @@ def it_has_entries(name, entries)
69 69 "ruby_version" => "1.8",
70 70 }
71 71
72   - it_has_entries 'Config::CONFIG', entries
  72 + it_has_entries 'RbConfig::CONFIG', entries
73 73 end
74 74
75   -describe "Config::MAKEFILE_CONFIG" do
  75 +describe "RbConfig::MAKEFILE_CONFIG" do
76 76 sitedir = Rubinius::SITE_PATH
77 77 sitelibdir = Rubinius::SITE_PATH
78 78 arch = "#{Rubinius::CPU}-#{Rubinius::OS}"
@@ -105,5 +105,5 @@ def it_has_entries(name, entries)
105 105 "rubyhdrdir" => "#{Rubinius::HDR_PATH}"
106 106 }
107 107
108   - it_has_entries 'Config::MAKEFILE_CONFIG', entries
  108 + it_has_entries 'RbConfig::MAKEFILE_CONFIG', entries
109 109 end
14 spec/ruby/optional/capi/spec_helper.rb
@@ -6,14 +6,14 @@ def compile_extension(path, name)
6 6 ext = File.join(path, "#{name}_spec")
7 7 source = "#{ext}.c"
8 8 obj = "#{ext}.o"
9   - lib = "#{ext}.#{Config::CONFIG['DLEXT']}"
  9 + lib = "#{ext}.#{RbConfig::CONFIG['DLEXT']}"
10 10 signature = "#{ext}.sig"
11 11
12 12 # TODO use rakelib/ext_helper.rb?
13 13 if RUBY_NAME == 'rbx'
14 14 hdrdir = Rubinius::HDR_PATH
15 15 elsif RUBY_NAME =~ /^ruby/
16   - hdrdir = Config::CONFIG["archdir"]
  16 + hdrdir = RbConfig::CONFIG["archdir"]
17 17 else
18 18 raise "Don't know how to build C extensions with #{RUBY_NAME}"
19 19 end
@@ -30,17 +30,17 @@ def compile_extension(path, name)
30 30 # avoid problems where compilation failed but previous shlib exists
31 31 File.delete lib if File.exists? lib
32 32
33   - cc = Config::CONFIG["CC"]
34   - cflags = (ENV["CFLAGS"] || Config::CONFIG["CFLAGS"]).dup
  33 + cc = RbConfig::CONFIG["CC"]
  34 + cflags = (ENV["CFLAGS"] || RbConfig::CONFIG["CFLAGS"]).dup
35 35 cflags += " -fPIC" unless cflags.include?("-fPIC")
36 36 incflags = "-I#{path} -I#{hdrdir}"
37 37
38 38 `#{cc} #{incflags} #{cflags} -c #{source} -o #{obj}`
39 39
40   - ldshared = Config::CONFIG["LDSHARED"]
  40 + ldshared = RbConfig::CONFIG["LDSHARED"]
41 41 libpath = "-L#{path}"
42   - libs = Config::CONFIG["LIBS"]
43   - dldflags = Config::CONFIG["DLDFLAGS"]
  42 + libs = RbConfig::CONFIG["LIBS"]
  43 + dldflags = RbConfig::CONFIG["DLDFLAGS"]
44 44
45 45 `#{ldshared} #{obj} #{libpath} #{dldflags} #{libs} -o #{lib}`
46 46

0 comments on commit bd6aef7

Please sign in to comment.
Something went wrong with that request. Please try again.