diff options
Diffstat (limited to 'tool/mkconfig.rb')
-rwxr-xr-x | tool/mkconfig.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb index c3d3230d34..ec39e5f8bd 100755 --- a/tool/mkconfig.rb +++ b/tool/mkconfig.rb @@ -310,6 +310,38 @@ print <<EOS RbConfig::expand(val) 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: # # RbConfig.ruby -> path |