Ninja and shell escape command line flags
Strings like cflags in Android.bp files are parsed by blueprint,
written to build.ninja files, parsed by ninja, and then passed to
/bin/sh -c. This had resulted in a combination of blueprint
(\"), ninja ($$), and shell (\$) escaping being necessary.
Update Soong to automatically handle ninja and shell escaping in
cflags and ldflags.
Bug: 31221587
Test: m -j
Change-Id: Ibe087b2788b355b73c3225b5928870619a0a53bc
diff --git a/cc/linker.go b/cc/linker.go
index 2c4c250..399074d 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -17,6 +17,8 @@
import (
"android/soong/android"
"fmt"
+
+ "github.com/google/blueprint/proptools"
)
// This file contains the basic functionality for linking against static libraries and shared
@@ -167,7 +169,7 @@
CheckBadLinkerFlags(ctx, "ldflags", linker.Properties.Ldflags)
- flags.LdFlags = append(flags.LdFlags, linker.Properties.Ldflags...)
+ flags.LdFlags = append(flags.LdFlags, proptools.NinjaAndShellEscape(linker.Properties.Ldflags)...)
if ctx.Host() {
rpath_prefix := `\$$ORIGIN/`