diff options
author | Matt Valentine-House <matt@eightbitraptor.com> | 2023-02-16 23:11:07 +0000 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2023-02-21 10:57:28 -0500 |
commit | 3c01342e19b31e21030deff5705b9427dca691ae (patch) | |
tree | f1b9c8cee86a3972b926370159dfb74dfe730cb3 | |
parent | a26a0af074a1f81223bb80b2f41c1b2c10ed7300 (diff) | |
download | ruby-3c01342e19b31e21030deff5705b9427dca691ae.tar.gz |
Fix detection of compiler_wd in tool/update-deps
-rwxr-xr-x | tool/update-deps | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/tool/update-deps b/tool/update-deps index fcd7373dbd..7f3a0c24ce 100755 --- a/tool/update-deps +++ b/tool/update-deps @@ -334,24 +334,25 @@ end # raise ArgumentError, "can not find #{filename} (hint: #{hint0})" #end -def read_single_cc_deps(path_i, cwd) +def read_single_cc_deps(path_i, cwd, fn_o) files = {} compiler_wd = nil path_i.each_line {|line| next if /\A\# \d+ "(.*)"/ !~ line dep = $1 + next if %r{\A<.*>\z} =~ dep # omit <command-line>, etc. next if /\.e?rb\z/ =~ dep - compiler_wd ||= dep + # gcc emits {# 1 "/absolute/directory/of/the/source/file//"} at 2nd line. + if /\/\/\z/ =~ dep + compiler_wd = Pathname(dep.sub(%r{//\z}, '')) + next + end + files[dep] = true } - # gcc emits {# 1 "/absolute/directory/of/the/source/file//"} at 2nd line. - if %r{\A/.*//\z} =~ compiler_wd - files.delete compiler_wd - compiler_wd = Pathname(compiler_wd.sub(%r{//\z}, '')) - elsif !(compiler_wd = yield) - raise "compiler working directory not found: #{path_i}" - end + compiler_wd ||= fn_o.to_s.start_with?("enc/") ? cwd : path_i.parent + deps = [] files.each_key {|dep| dep = Pathname(dep) @@ -383,13 +384,7 @@ def read_cc_deps(cwd) end path_o = cwd + fn_o path_i = cwd + fn_i - deps[path_o] = read_single_cc_deps(path_i, cwd) do - if fn_o.to_s.start_with?("enc/") - cwd - else - path_i.parent - end - end + deps[path_o] = read_single_cc_deps(path_i, cwd, fn_o) } deps end |