aboutsummaryrefslogtreecommitdiffstats
path: root/cc/compiler.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-09-29 14:06:02 -0700
committerColin Cross <ccross@android.com>2016-09-29 15:57:59 -0700
commit4b963f8d6a7bff85327b81aa0038190bd7dc630d (patch)
tree26cf21146d8008ba2a0996fca01f122451efb913 /cc/compiler.go
parent81ef084a00baf503103232dedbdf55a9192e3215 (diff)
downloadbuild_soong-4b963f8d6a7bff85327b81aa0038190bd7dc630d.tar.gz
build_soong-4b963f8d6a7bff85327b81aa0038190bd7dc630d.tar.bz2
build_soong-4b963f8d6a7bff85327b81aa0038190bd7dc630d.zip
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
Diffstat (limited to 'cc/compiler.go')
-rw-r--r--cc/compiler.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/cc/compiler.go b/cc/compiler.go
index 37dc7449..db4c076c 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -19,6 +19,8 @@ import (
"path/filepath"
"strings"
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
"android/soong/cc/config"
)
@@ -130,11 +132,13 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
CheckBadCompilerFlags(ctx, "conlyflags", compiler.Properties.Conlyflags)
CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags)
- flags.CFlags = append(flags.CFlags, compiler.Properties.Cflags...)
- flags.CppFlags = append(flags.CppFlags, compiler.Properties.Cppflags...)
- flags.ConlyFlags = append(flags.ConlyFlags, compiler.Properties.Conlyflags...)
- flags.AsFlags = append(flags.AsFlags, compiler.Properties.Asflags...)
- flags.YaccFlags = append(flags.YaccFlags, compiler.Properties.Yaccflags...)
+ esc := proptools.NinjaAndShellEscape
+
+ flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Cflags)...)
+ flags.CppFlags = append(flags.CppFlags, esc(compiler.Properties.Cppflags)...)
+ flags.ConlyFlags = append(flags.ConlyFlags, esc(compiler.Properties.Conlyflags)...)
+ flags.AsFlags = append(flags.AsFlags, esc(compiler.Properties.Asflags)...)
+ flags.YaccFlags = append(flags.YaccFlags, esc(compiler.Properties.Yaccflags)...)
// Include dir cflags
rootIncludeDirs := android.PathsForSource(ctx, compiler.Properties.Include_dirs)
@@ -198,15 +202,15 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
CheckBadCompilerFlags(ctx, "release.cflags", compiler.Properties.Release.Cflags)
// TODO: debug
- flags.CFlags = append(flags.CFlags, compiler.Properties.Release.Cflags...)
+ flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Release.Cflags)...)
if flags.Clang {
CheckBadCompilerFlags(ctx, "clang_cflags", compiler.Properties.Clang_cflags)
CheckBadCompilerFlags(ctx, "clang_asflags", compiler.Properties.Clang_asflags)
flags.CFlags = config.ClangFilterUnknownCflags(flags.CFlags)
- flags.CFlags = append(flags.CFlags, compiler.Properties.Clang_cflags...)
- flags.AsFlags = append(flags.AsFlags, compiler.Properties.Clang_asflags...)
+ flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Clang_cflags)...)
+ flags.AsFlags = append(flags.AsFlags, esc(compiler.Properties.Clang_asflags)...)
flags.CppFlags = config.ClangFilterUnknownCflags(flags.CppFlags)
flags.ConlyFlags = config.ClangFilterUnknownCflags(flags.ConlyFlags)
flags.LdFlags = config.ClangFilterUnknownCflags(flags.LdFlags)