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
This commit is contained in:
parent
683d7316cd
commit
342fa6b927
5 changed files with 42 additions and 45 deletions
|
@ -375,13 +375,14 @@ type builderFlags struct {
|
||||||
localCppFlags string
|
localCppFlags string
|
||||||
localLdFlags string
|
localLdFlags string
|
||||||
|
|
||||||
libFlags string // Flags to add to the linker directly after specifying libraries to link.
|
noOverrideFlags string // Flags appended at the end so they are not overridden.
|
||||||
extraLibFlags string // Flags to add to the linker last.
|
libFlags string // Flags to add to the linker directly after specifying libraries to link.
|
||||||
tidyFlags string // Flags that apply to clang-tidy
|
extraLibFlags string // Flags to add to the linker last.
|
||||||
sAbiFlags string // Flags that apply to header-abi-dumps
|
tidyFlags string // Flags that apply to clang-tidy
|
||||||
aidlFlags string // Flags that apply to aidl source files
|
sAbiFlags string // Flags that apply to header-abi-dumps
|
||||||
rsFlags string // Flags that apply to renderscript source files
|
aidlFlags string // Flags that apply to aidl source files
|
||||||
toolchain config.Toolchain
|
rsFlags string // Flags that apply to renderscript source files
|
||||||
|
toolchain config.Toolchain
|
||||||
|
|
||||||
// True if these extra features are enabled.
|
// True if these extra features are enabled.
|
||||||
tidy bool
|
tidy bool
|
||||||
|
@ -485,7 +486,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
||||||
flags.localCommonFlags + " " +
|
flags.localCommonFlags + " " +
|
||||||
flags.localToolingCFlags + " " +
|
flags.localToolingCFlags + " " +
|
||||||
flags.localConlyFlags + " " +
|
flags.localConlyFlags + " " +
|
||||||
flags.systemIncludeFlags
|
flags.systemIncludeFlags + " " +
|
||||||
|
flags.noOverrideFlags
|
||||||
|
|
||||||
cflags := flags.globalCommonFlags + " " +
|
cflags := flags.globalCommonFlags + " " +
|
||||||
flags.globalCFlags + " " +
|
flags.globalCFlags + " " +
|
||||||
|
@ -493,7 +495,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
||||||
flags.localCommonFlags + " " +
|
flags.localCommonFlags + " " +
|
||||||
flags.localCFlags + " " +
|
flags.localCFlags + " " +
|
||||||
flags.localConlyFlags + " " +
|
flags.localConlyFlags + " " +
|
||||||
flags.systemIncludeFlags
|
flags.systemIncludeFlags + " " +
|
||||||
|
flags.noOverrideFlags
|
||||||
|
|
||||||
toolingCppflags := flags.globalCommonFlags + " " +
|
toolingCppflags := flags.globalCommonFlags + " " +
|
||||||
flags.globalToolingCFlags + " " +
|
flags.globalToolingCFlags + " " +
|
||||||
|
@ -501,7 +504,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
||||||
flags.localCommonFlags + " " +
|
flags.localCommonFlags + " " +
|
||||||
flags.localToolingCFlags + " " +
|
flags.localToolingCFlags + " " +
|
||||||
flags.localToolingCppFlags + " " +
|
flags.localToolingCppFlags + " " +
|
||||||
flags.systemIncludeFlags
|
flags.systemIncludeFlags + " " +
|
||||||
|
flags.noOverrideFlags
|
||||||
|
|
||||||
cppflags := flags.globalCommonFlags + " " +
|
cppflags := flags.globalCommonFlags + " " +
|
||||||
flags.globalCFlags + " " +
|
flags.globalCFlags + " " +
|
||||||
|
@ -509,7 +513,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
||||||
flags.localCommonFlags + " " +
|
flags.localCommonFlags + " " +
|
||||||
flags.localCFlags + " " +
|
flags.localCFlags + " " +
|
||||||
flags.localCppFlags + " " +
|
flags.localCppFlags + " " +
|
||||||
flags.systemIncludeFlags
|
flags.systemIncludeFlags + " " +
|
||||||
|
flags.noOverrideFlags
|
||||||
|
|
||||||
asflags := flags.globalCommonFlags + " " +
|
asflags := flags.globalCommonFlags + " " +
|
||||||
flags.globalAsFlags + " " +
|
flags.globalAsFlags + " " +
|
||||||
|
@ -522,26 +527,6 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
||||||
sAbiDumpFiles = make(android.Paths, 0, len(srcFiles))
|
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.
|
// 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.
|
// 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>.
|
// To simplify the code, the shared variables are all named as $flags<nnn>.
|
||||||
|
|
3
cc/cc.go
3
cc/cc.go
|
@ -215,7 +215,8 @@ type Flags struct {
|
||||||
// Local flags (which individual modules are responsible for). These may override global flags.
|
// Local flags (which individual modules are responsible for). These may override global flags.
|
||||||
Local LocalOrGlobalFlags
|
Local LocalOrGlobalFlags
|
||||||
// Global flags (which build system or toolchain is responsible for).
|
// Global flags (which build system or toolchain is responsible for).
|
||||||
Global LocalOrGlobalFlags
|
Global LocalOrGlobalFlags
|
||||||
|
NoOverrideFlags []string // Flags applied to the end of list of flags so they are not overridden
|
||||||
|
|
||||||
aidlFlags []string // Flags that apply to aidl source files
|
aidlFlags []string // Flags that apply to aidl source files
|
||||||
rsFlags []string // Flags that apply to renderscript source files
|
rsFlags []string // Flags that apply to renderscript source files
|
||||||
|
|
|
@ -164,6 +164,7 @@ func getArguments(src android.Path, ctx android.SingletonContext, ccModule *Modu
|
||||||
args = append(args, expandAllVars(ctx, ccModule.flags.Local.ConlyFlags)...)
|
args = append(args, expandAllVars(ctx, ccModule.flags.Local.ConlyFlags)...)
|
||||||
}
|
}
|
||||||
args = append(args, expandAllVars(ctx, ccModule.flags.SystemIncludeFlags)...)
|
args = append(args, expandAllVars(ctx, ccModule.flags.SystemIncludeFlags)...)
|
||||||
|
args = append(args, expandAllVars(ctx, ccModule.flags.NoOverrideFlags)...)
|
||||||
args = append(args, src.String())
|
args = append(args, src.String())
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,7 +539,6 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
||||||
flags.Global.CommonFlags = append(flags.Global.CommonFlags, tc.ToolchainCflags())
|
flags.Global.CommonFlags = append(flags.Global.CommonFlags, tc.ToolchainCflags())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cStd := parseCStd(compiler.Properties.C_std)
|
cStd := parseCStd(compiler.Properties.C_std)
|
||||||
cppStd := parseCppStd(compiler.Properties.Cpp_std)
|
cppStd := parseCppStd(compiler.Properties.Cpp_std)
|
||||||
|
|
||||||
|
@ -671,6 +670,16 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
||||||
flags.Local.CFlags = append(flags.Local.CFlags, "-DDO_NOT_CHECK_MANUAL_BINDER_INTERFACES")
|
flags.Local.CFlags = append(flags.Local.CFlags, "-DDO_NOT_CHECK_MANUAL_BINDER_INTERFACES")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flags.NoOverrideFlags = append(flags.NoOverrideFlags, "${config.NoOverrideGlobalCflags}")
|
||||||
|
|
||||||
|
if flags.Toolchain.Is64Bit() {
|
||||||
|
flags.NoOverrideFlags = append(flags.NoOverrideFlags, "${config.NoOverride64GlobalCflags}")
|
||||||
|
}
|
||||||
|
|
||||||
|
if android.IsThirdPartyPath(ctx.ModuleDir()) {
|
||||||
|
flags.NoOverrideFlags = append(flags.NoOverrideFlags, "${config.NoOverrideExternalGlobalCflags}")
|
||||||
|
}
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
cc/util.go
25
cc/util.go
|
@ -56,18 +56,19 @@ func flagsToBuilderFlags(in Flags) builderFlags {
|
||||||
localCppFlags: strings.Join(in.Local.CppFlags, " "),
|
localCppFlags: strings.Join(in.Local.CppFlags, " "),
|
||||||
localLdFlags: strings.Join(in.Local.LdFlags, " "),
|
localLdFlags: strings.Join(in.Local.LdFlags, " "),
|
||||||
|
|
||||||
aidlFlags: strings.Join(in.aidlFlags, " "),
|
noOverrideFlags: strings.Join(in.NoOverrideFlags, " "),
|
||||||
rsFlags: strings.Join(in.rsFlags, " "),
|
aidlFlags: strings.Join(in.aidlFlags, " "),
|
||||||
libFlags: strings.Join(in.libFlags, " "),
|
rsFlags: strings.Join(in.rsFlags, " "),
|
||||||
extraLibFlags: strings.Join(in.extraLibFlags, " "),
|
libFlags: strings.Join(in.libFlags, " "),
|
||||||
tidyFlags: strings.Join(in.TidyFlags, " "),
|
extraLibFlags: strings.Join(in.extraLibFlags, " "),
|
||||||
sAbiFlags: strings.Join(in.SAbiFlags, " "),
|
tidyFlags: strings.Join(in.TidyFlags, " "),
|
||||||
toolchain: in.Toolchain,
|
sAbiFlags: strings.Join(in.SAbiFlags, " "),
|
||||||
gcovCoverage: in.GcovCoverage,
|
toolchain: in.Toolchain,
|
||||||
tidy: in.Tidy,
|
gcovCoverage: in.GcovCoverage,
|
||||||
needTidyFiles: in.NeedTidyFiles,
|
tidy: in.Tidy,
|
||||||
sAbiDump: in.SAbiDump,
|
needTidyFiles: in.NeedTidyFiles,
|
||||||
emitXrefs: in.EmitXrefs,
|
sAbiDump: in.SAbiDump,
|
||||||
|
emitXrefs: in.EmitXrefs,
|
||||||
|
|
||||||
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
|
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue