Add RbConfig.fire_update!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7a823be8d0
commit
f34e8ff672
35
tool/fake.rb
35
tool/fake.rb
@ -12,20 +12,9 @@ end
|
|||||||
static = !!(defined?($static) && $static)
|
static = !!(defined?($static) && $static)
|
||||||
$:.unshift(builddir)
|
$:.unshift(builddir)
|
||||||
posthook = proc do
|
posthook = proc do
|
||||||
config = RbConfig::CONFIG
|
RbConfig.fire_update!("top_srcdir", $top_srcdir)
|
||||||
mkconfig = RbConfig::MAKEFILE_CONFIG
|
RbConfig.fire_update!("topdir", $topdir)
|
||||||
[
|
$hdrdir.sub!(/\A#{Regexp.quote($top_srcdir)}(?=\/)/, "$(top_srcdir)")
|
||||||
["top_srcdir", $top_srcdir],
|
|
||||||
["topdir", $topdir],
|
|
||||||
].each do |var, val|
|
|
||||||
next unless val
|
|
||||||
mkconfig[var] = config[var] = val
|
|
||||||
t = /\A#{Regexp.quote(val)}(?=\/)/
|
|
||||||
$hdrdir.sub!(t) {"$(#{var})"}
|
|
||||||
mkconfig.keys.grep(/dir\z/) do |k|
|
|
||||||
mkconfig[k] = "$(#{var})#$'" if t =~ mkconfig[k]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if $extmk
|
if $extmk
|
||||||
$ruby = "$(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'"
|
$ruby = "$(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'"
|
||||||
else
|
else
|
||||||
@ -54,16 +43,14 @@ prehook = proc do |extmk|
|
|||||||
$extout_prefix = '$(extout)$(target_prefix)/'
|
$extout_prefix = '$(extout)$(target_prefix)/'
|
||||||
config = RbConfig::CONFIG
|
config = RbConfig::CONFIG
|
||||||
mkconfig = RbConfig::MAKEFILE_CONFIG
|
mkconfig = RbConfig::MAKEFILE_CONFIG
|
||||||
mkconfig["builddir"] = config["builddir"] = builddir
|
RbConfig.fire_update!("builddir", builddir)
|
||||||
mkconfig["buildlibdir"] = config["buildlibdir"] = builddir
|
RbConfig.fire_update!("buildlibdir", builddir)
|
||||||
mkconfig["libdir"] = config["libdir"] = builddir
|
RbConfig.fire_update!("libdir", builddir)
|
||||||
mkconfig["top_srcdir"] = $top_srcdir if $top_srcdir
|
RbConfig.fire_update!("top_srcdir", $top_srcdir ||= top_srcdir)
|
||||||
mkconfig["extout"] ||= $extout
|
RbConfig.fire_update!("extout", $extout)
|
||||||
config["top_srcdir"] = File.expand_path($top_srcdir ||= top_srcdir)
|
RbConfig.fire_update!("rubyhdrdir", "$(top_srcdir)/include")
|
||||||
config["rubyhdrdir"] = join[$top_srcdir, "include"]
|
RbConfig.fire_update!("rubyarchhdrdir", "$(extout)/include/$(arch)")
|
||||||
config["rubyarchhdrdir"] = join[builddir, config["EXTOUT"], "include", config["arch"]]
|
RbConfig.fire_update!("libdirname", "buildlibdir")
|
||||||
config["extout"] ||= join[$topdir, ".ext"]
|
|
||||||
mkconfig["libdirname"] = "buildlibdir"
|
|
||||||
trace_var(:$ruby, posthook)
|
trace_var(:$ruby, posthook)
|
||||||
untrace_var(:$extmk, prehook)
|
untrace_var(:$extmk, prehook)
|
||||||
end
|
end
|
||||||
|
@ -310,6 +310,38 @@ print <<EOS
|
|||||||
RbConfig::expand(val)
|
RbConfig::expand(val)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# call-seq:
|
||||||
|
#
|
||||||
|
# RbConfig.fire_update!(key, val) -> string
|
||||||
|
# RbConfig.fire_update!(key, val, mkconf, conf) -> string
|
||||||
|
#
|
||||||
|
# updates +key+ in +mkconf+ with +val+, and all values depending on
|
||||||
|
# the +key+ in +mkconf+.
|
||||||
|
#
|
||||||
|
# RbConfig::MAKEFILE_CONFIG.values_at("CC", "LDSHARED") # => ["gcc", "$(CC) -shared"]
|
||||||
|
# RbConfig::CONFIG.values_at("CC", "LDSHARED") # => ["gcc", "gcc -shared"]
|
||||||
|
# RbConfig.fire_update!("CC", "gcc-8") # => ["CC", "LDSHARED"]
|
||||||
|
# RbConfig::MAKEFILE_CONFIG.values_at("CC", "LDSHARED") # => ["gcc-8", "$(CC) -shared"]
|
||||||
|
# RbConfig::CONFIG.values_at("CC", "LDSHARED") # => ["gcc-8", "gcc-8 -shared"]
|
||||||
|
#
|
||||||
|
# returns updated keys list, or +nil+ if nothing changed.
|
||||||
|
def RbConfig.fire_update!(key, val, mkconf = MAKEFILE_CONFIG, conf = CONFIG)
|
||||||
|
return if (old = mkconf[key]) == val
|
||||||
|
mkconf[key] = val
|
||||||
|
keys = [key]
|
||||||
|
deps = []
|
||||||
|
begin
|
||||||
|
re = Regexp.new("\\\\$\\\\((?:%1$s)\\\\)|\\\\$\\\\{(?:%1$s)\\\\}" % keys.join('|'))
|
||||||
|
deps |= keys
|
||||||
|
keys.clear
|
||||||
|
mkconf.each {|k,v| keys << k if re =~ v}
|
||||||
|
end until keys.empty?
|
||||||
|
deps.each {|k| conf[k] = mkconf[k].dup}
|
||||||
|
deps.each {|k| expand(conf[k])}
|
||||||
|
deps
|
||||||
|
end
|
||||||
|
|
||||||
# call-seq:
|
# call-seq:
|
||||||
#
|
#
|
||||||
# RbConfig.ruby -> path
|
# RbConfig.ruby -> path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user