Add global C flags to compile_commands
This solves linter warnings in editor by adding flags to ignore errors
we don't care about. This also means that compile_commands.json is
closer to the flags we actually use for compilation.
Test: Checked generated compile_commands for new flags.
Change-Id: Id583da6eb5151a9baa9a47771f5f937c88bc43f7
diff --git a/cc/builder.go b/cc/builder.go
index e4d5be2..f28f47f 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -375,13 +375,14 @@
localCppFlags string
localLdFlags string
- libFlags string // Flags to add to the linker directly after specifying libraries to link.
- extraLibFlags string // Flags to add to the linker last.
- tidyFlags string // Flags that apply to clang-tidy
- sAbiFlags string // Flags that apply to header-abi-dumps
- aidlFlags string // Flags that apply to aidl source files
- rsFlags string // Flags that apply to renderscript source files
- toolchain config.Toolchain
+ noOverrideFlags string // Flags appended at the end so they are not overridden.
+ libFlags string // Flags to add to the linker directly after specifying libraries to link.
+ extraLibFlags string // Flags to add to the linker last.
+ tidyFlags string // Flags that apply to clang-tidy
+ sAbiFlags string // Flags that apply to header-abi-dumps
+ aidlFlags string // Flags that apply to aidl source files
+ rsFlags string // Flags that apply to renderscript source files
+ toolchain config.Toolchain
// True if these extra features are enabled.
tidy bool
@@ -485,7 +486,8 @@
flags.localCommonFlags + " " +
flags.localToolingCFlags + " " +
flags.localConlyFlags + " " +
- flags.systemIncludeFlags
+ flags.systemIncludeFlags + " " +
+ flags.noOverrideFlags
cflags := flags.globalCommonFlags + " " +
flags.globalCFlags + " " +
@@ -493,7 +495,8 @@
flags.localCommonFlags + " " +
flags.localCFlags + " " +
flags.localConlyFlags + " " +
- flags.systemIncludeFlags
+ flags.systemIncludeFlags + " " +
+ flags.noOverrideFlags
toolingCppflags := flags.globalCommonFlags + " " +
flags.globalToolingCFlags + " " +
@@ -501,7 +504,8 @@
flags.localCommonFlags + " " +
flags.localToolingCFlags + " " +
flags.localToolingCppFlags + " " +
- flags.systemIncludeFlags
+ flags.systemIncludeFlags + " " +
+ flags.noOverrideFlags
cppflags := flags.globalCommonFlags + " " +
flags.globalCFlags + " " +
@@ -509,7 +513,8 @@
flags.localCommonFlags + " " +
flags.localCFlags + " " +
flags.localCppFlags + " " +
- flags.systemIncludeFlags
+ flags.systemIncludeFlags + " " +
+ flags.noOverrideFlags
asflags := flags.globalCommonFlags + " " +
flags.globalAsFlags + " " +
@@ -522,26 +527,6 @@
sAbiDumpFiles = make(android.Paths, 0, len(srcFiles))
}
- cflags += " ${config.NoOverrideGlobalCflags}"
- toolingCflags += " ${config.NoOverrideGlobalCflags}"
- cppflags += " ${config.NoOverrideGlobalCflags}"
- toolingCppflags += " ${config.NoOverrideGlobalCflags}"
-
- if flags.toolchain.Is64Bit() {
- cflags += " ${config.NoOverride64GlobalCflags}"
- toolingCflags += " ${config.NoOverride64GlobalCflags}"
- cppflags += " ${config.NoOverride64GlobalCflags}"
- toolingCppflags += " ${config.NoOverride64GlobalCflags}"
- }
-
- modulePath := ctx.ModuleDir()
- if android.IsThirdPartyPath(modulePath) {
- cflags += " ${config.NoOverrideExternalGlobalCflags}"
- toolingCflags += " ${config.NoOverrideExternalGlobalCflags}"
- cppflags += " ${config.NoOverrideExternalGlobalCflags}"
- toolingCppflags += " ${config.NoOverrideExternalGlobalCflags}"
- }
-
// Multiple source files have build rules usually share the same cFlags or tidyFlags.
// Define only one version in this module and share it in multiple build rules.
// To simplify the code, the shared variables are all named as $flags<nnn>.