Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-i'' that is, an empty string with no space after the -i should work on both, but maybe it's better to be explicit like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my local testing on macOS -i'' did not work.

It looked like it was being parsed as equivalent to -i, causing the next argument (the sed command) to be used as the backup file extension.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, maybe it only works with -e before the command to delineate the empty string from the command like: sed -i'' -e 's@/b/f/w@../..@g' $depfile.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that originally but found that it was creating a backup file with the extension -e added to the filename

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha. Okay. I'm glad you checked =)

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