Skip to content

Commit

Permalink
Make the workaround for absolute paths in depfiles compatible with ma…
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Jan 5, 2024
1 parent 5dad8ac commit 0cb1087
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions build/toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,20 @@ template("gcc_toolchain") {
coverage_flags = "-fprofile-instr-generate -fcoverage-mapping"
}

if (host_os == "mac") {
sed_in_place_flag = "-i ''"
} else {
sed_in_place_flag = "-i"
}

tool("cc") {
depfile = "{{output}}.d"
command = "$cc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $coverage_flags -c {{source}} -o {{output}}"
if (use_rbe || use_goma) {
# The depfile generated on an RBE worker can contain absolute paths.
# This sed command strips off the prefix, and rewrites to be
# relative to the buildroot.
command += " && sed -i 's@/b/f/w@../..@g' $depfile"
command += " && sed $sed_in_place_flag 's@/b/f/w@../..@g' $depfile"
}
depsformat = "gcc"
description = "CC {{output}}"
Expand All @@ -141,7 +147,7 @@ template("gcc_toolchain") {
depfile = "{{output}}.d"
command = "$cxx -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $coverage_flags -c {{source}} -o {{output}}"
if (use_rbe || use_goma) {
command += " && sed -i 's@/b/f/w@../..@g' $depfile"
command += " && sed $sed_in_place_flag 's@/b/f/w@../..@g' $depfile"
}
depsformat = "gcc"
description = "CXX {{output}}"
Expand All @@ -153,7 +159,7 @@ template("gcc_toolchain") {
depfile = "{{output}}.d"
command = "$asm -MD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} $coverage_flags -c {{source}} -o {{output}}"
if (use_rbe || use_goma) {
command += " && sed -i 's@/b/f/w@../..@g' $depfile"
command += " && sed $sed_in_place_flag 's@/b/f/w@../..@g' $depfile"
}
depsformat = "gcc"
description = "ASM {{output}}"
Expand Down

0 comments on commit 0cb1087

Please sign in to comment.