Revert "Revert "Add external projects only CFlags option""
This reverts commit a9ccbb7b87b9f7f30e38f1f79c1de064ffbcc392.
Test: m
Change-Id: I92d7b7707f73ef3af5824d3e8cb6da0465b5e07d
diff --git a/cc/compiler.go b/cc/compiler.go
index 8f119cf..10cec8c 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -392,6 +392,12 @@
fmt.Sprintf("${config.%sGlobalCflags}", hod))
}
+ if flags.Clang {
+ if strings.HasPrefix(android.PathForModuleSrc(ctx).String(), "external/") {
+ flags.GlobalFlags = append([]string{"${config.ClangExternalCflags}"}, flags.GlobalFlags...)
+ }
+ }
+
if ctx.Device() {
if Bool(compiler.Properties.Rtti) {
flags.CppFlags = append(flags.CppFlags, "-frtti")
diff --git a/cc/config/clang.go b/cc/config/clang.go
index ba1cd3c..22e428f 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -182,6 +182,11 @@
// compatibility.
"-Wno-c++98-compat-extra-semi",
}, " "))
+
+ // Extra cflags for projects under external/ directory
+ pctx.StaticVariable("ClangExtraExternalCflags", strings.Join([]string{
+ // TODO(yikong): Move -Wno flags here
+ }, " "))
}
func ClangFilterUnknownCflags(cflags []string) []string {
diff --git a/cc/config/global.go b/cc/config/global.go
index 06f6f9a..c734c2e 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -170,6 +170,8 @@
pctx.StaticVariable("CommonClangGlobalCppflags",
strings.Join(append(ClangFilterUnknownCflags(commonGlobalCppflags), "${ClangExtraCppflags}"), " "))
+ pctx.StaticVariable("ClangExternalCflags", "${ClangExtraExternalCflags}")
+
// Everything in these lists is a crime against abstraction and dependency tracking.
// Do not add anything to this list.
pctx.PrefixedExistentPathsForSourcesVariable("CommonGlobalIncludes", "-I",
diff --git a/cc/makevars.go b/cc/makevars.go
index c95bad2..d036bb6 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -83,6 +83,7 @@
ctx.Strict("RS_LLVM_AS", "${config.RSLLVMPrebuiltsPath}/llvm-as")
ctx.Strict("RS_LLVM_LINK", "${config.RSLLVMPrebuiltsPath}/llvm-link")
+ ctx.Strict("CLANG_EXTERNAL_CFLAGS", "${config.ClangExternalCflags}")
ctx.Strict("GLOBAL_CFLAGS_NO_OVERRIDE", "${config.NoOverrideGlobalCflags}")
ctx.Strict("GLOBAL_CLANG_CFLAGS_NO_OVERRIDE", "${config.ClangExtraNoOverrideCflags}")
ctx.Strict("GLOBAL_CPPFLAGS_NO_OVERRIDE", "")