diff options
author | Antoine Moynault <antoine.moynault@linaro.org> | 2022-11-15 16:47:59 +0100 |
---|---|---|
committer | Antoine Moynault <antoine.moynault@linaro.org> | 2022-12-02 15:56:16 +0000 |
commit | 16e78d41965ca61d7982b9d46f5823f8e9383c1b (patch) | |
tree | 94a4ef745e92008631354fa82fd6826c3dcc9df8 | |
parent | 5abb4bb729cd5524d4a611425b739a3cd008f694 (diff) |
wrappers/shadow-cc.sh: handle quoted filenames in rsp files
filenames containing special chars (like @) are single-quoted in aosp
response files (cf build/soong/response/response.go)
without handling this, compilation/link commands involving such files
will always use original object files (from orig_out dir) instead of
shadow ones, which can lead to wrong results
this patch also handles filenames containing spaces, even if there is
no such files in aosp tree for now
Change-Id: If0d734d8e7cbd85bf726102935ae83fe8aad698e
-rwxr-xr-x | wrappers/shadow-cc.sh | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/wrappers/shadow-cc.sh b/wrappers/shadow-cc.sh index 185a3bd..24f6a9a 100755 --- a/wrappers/shadow-cc.sh +++ b/wrappers/shadow-cc.sh @@ -232,15 +232,21 @@ generate_shadow_rsp () if [ "$(stat --format=%s "$orig_rsp")" = 0 ]; then touch "$shadow_rsp" else - local delim="" - while read -r orig_file; do + local quote delim="" + while read -d '' -r orig_file; do + # unquote orig + case "$orig_file" in + \'*\') quote="'"; orig_file=${orig_file:1:-1} ;; + *) quote="" ;; + esac shadow_file=$(print_shadow_path "$orig_file") if ! [ -e "$shadow_file" ]; then shadow_file="$orig_file" fi - echo -ne "$delim$shadow_file" >> "$shadow_rsp" + # quote shadow + echo -ne "$delim$quote$shadow_file$quote" >> "$shadow_rsp" delim=" " - done < <({ cat "$orig_rsp"; echo; } | tr ' ' '\n') + done < <({ cat "$orig_rsp"; echo; } | xargs printf '%s\0') fi echo "$shadow_rsp" |