Fix detection of compiler_wd in tool/update-deps
This commit is contained in:
parent
a26a0af074
commit
3c01342e19
Notes:
git
2023-02-21 15:57:47 +00:00
@ -334,24 +334,25 @@ end
|
|||||||
# raise ArgumentError, "can not find #{filename} (hint: #{hint0})"
|
# raise ArgumentError, "can not find #{filename} (hint: #{hint0})"
|
||||||
#end
|
#end
|
||||||
|
|
||||||
def read_single_cc_deps(path_i, cwd)
|
def read_single_cc_deps(path_i, cwd, fn_o)
|
||||||
files = {}
|
files = {}
|
||||||
compiler_wd = nil
|
compiler_wd = nil
|
||||||
path_i.each_line {|line|
|
path_i.each_line {|line|
|
||||||
next if /\A\# \d+ "(.*)"/ !~ line
|
next if /\A\# \d+ "(.*)"/ !~ line
|
||||||
dep = $1
|
dep = $1
|
||||||
|
|
||||||
next if %r{\A<.*>\z} =~ dep # omit <command-line>, etc.
|
next if %r{\A<.*>\z} =~ dep # omit <command-line>, etc.
|
||||||
next if /\.e?rb\z/ =~ dep
|
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
|
files[dep] = true
|
||||||
}
|
}
|
||||||
# gcc emits {# 1 "/absolute/directory/of/the/source/file//"} at 2nd line.
|
compiler_wd ||= fn_o.to_s.start_with?("enc/") ? cwd : path_i.parent
|
||||||
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
|
|
||||||
deps = []
|
deps = []
|
||||||
files.each_key {|dep|
|
files.each_key {|dep|
|
||||||
dep = Pathname(dep)
|
dep = Pathname(dep)
|
||||||
@ -383,13 +384,7 @@ def read_cc_deps(cwd)
|
|||||||
end
|
end
|
||||||
path_o = cwd + fn_o
|
path_o = cwd + fn_o
|
||||||
path_i = cwd + fn_i
|
path_i = cwd + fn_i
|
||||||
deps[path_o] = read_single_cc_deps(path_i, cwd) do
|
deps[path_o] = read_single_cc_deps(path_i, cwd, fn_o)
|
||||||
if fn_o.to_s.start_with?("enc/")
|
|
||||||
cwd
|
|
||||||
else
|
|
||||||
path_i.parent
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
deps
|
deps
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user