diff options
author | Yi Kong <yikong@google.com> | 2018-05-24 19:42:51 -0400 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2018-06-05 19:32:02 +0000 |
commit | 6a350878d87d76bcfcd35697fb5c2598117e5a11 (patch) | |
tree | 0d590ef37727dbc091f591d72e75ad096bf9be28 | |
parent | 85b1e39ffe85147a26c05ab0fc1204d63d365e42 (diff) | |
download | build_soong-6a350878d87d76bcfcd35697fb5c2598117e5a11.tar.gz build_soong-6a350878d87d76bcfcd35697fb5c2598117e5a11.tar.bz2 build_soong-6a350878d87d76bcfcd35697fb5c2598117e5a11.zip |
Add external projects only CFlags option
Every time the toolchain adds a new warning, we had to suppress the
warning in every external projects that violates it, or disable it
globally -- which we end up doing most of the time since the first
option is way too time consuming.
Add a separate cflags option for external projects and move existing
-Wno-* flags there so that we can enforce better code quality for
internal projects.
TODO: Move more -Wno-* flags to ClangExtraExternalCflags
Test: m checkbuild
Change-Id: If3dee491616a1e7ba6223c2f522d100e10c5ee76
-rw-r--r-- | cc/compiler.go | 6 | ||||
-rw-r--r-- | cc/config/clang.go | 11 | ||||
-rw-r--r-- | cc/config/global.go | 2 |
3 files changed, 15 insertions, 4 deletions
diff --git a/cc/compiler.go b/cc/compiler.go index 8f119cf3..10cec8ce 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -392,6 +392,12 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps 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 ba1cd3c0..69668b67 100644 --- a/cc/config/clang.go +++ b/cc/config/clang.go @@ -173,14 +173,17 @@ func init() { // this new warning are fixed. "-Wno-null-pointer-arithmetic", + // Disable c++98-specific warning since Android is not concerned with C++98 + // compatibility. + "-Wno-c++98-compat-extra-semi", + }, " ")) + + // Extra cflags for projects under external/ directory + pctx.StaticVariable("ClangExtraExternalCflags", strings.Join([]string{ // http://b/72330874 Disable -Wenum-compare until the instances detected by this new // warning are fixed. "-Wno-enum-compare", "-Wno-enum-compare-switch", - - // Disable c++98-specific warning since Android is not concerned with C++98 - // compatibility. - "-Wno-c++98-compat-extra-semi", }, " ")) } diff --git a/cc/config/global.go b/cc/config/global.go index 06f6f9ae..c734c2ee 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -170,6 +170,8 @@ func init() { 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", |