Generate tidy-* rules unless tidy is disabled
* make tidy-soong_subset, or make tidy-<any_directory>,
should trigger the same clang-tidy compilations
with or without global WITH_TIDY=1.
* Normal make should not trigger clang-tidy compilations
unless global WITH_TIDY=1 or a module has set tidy:true.
Bug: 213918926
Test: NINJA_ARGS="-n" make tidy-soong_subset
Test: NINJA_ARGS="-n" make <some-library>
Change-Id: Iafffd3894abe137c9584c2c01830898422f9a677
diff --git a/cc/cc.go b/cc/cc.go
index 72adefd..9c35348 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -210,11 +210,12 @@
// These must be after any module include flags, which will be in CommonFlags.
SystemIncludeFlags []string
- Toolchain config.Toolchain
- Tidy bool // True if clang-tidy is enabled.
- GcovCoverage bool // True if coverage files should be generated.
- SAbiDump bool // True if header abi dumps should be generated.
- EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
+ Toolchain config.Toolchain
+ Tidy bool // True if ninja .tidy rules should be generated.
+ NeedTidyFiles bool // True if module link should depend on .tidy files
+ GcovCoverage bool // True if coverage files should be generated.
+ SAbiDump bool // True if header abi dumps should be generated.
+ EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
// The instruction set required for clang ("arm" or "thumb").
RequiredInstructionSet string
@@ -516,6 +517,12 @@
directlyInAnyApex() bool
isPreventInstall() bool
isCfiAssemblySupportEnabled() bool
+ getSharedFlags() *SharedFlags
+}
+
+type SharedFlags struct {
+ numSharedFlags int
+ flagsMap map[string]string
}
type ModuleContext interface {
@@ -827,6 +834,9 @@
// Flags used to compile this module
flags Flags
+ // Shared flags among build rules of this module
+ sharedFlags SharedFlags
+
// only non-nil when this is a shared library that reuses the objects of a static library
staticAnalogue *StaticLibraryInfo
@@ -1605,6 +1615,15 @@
return ctx.mod.Properties.PreventInstall
}
+func (ctx *moduleContextImpl) getSharedFlags() *SharedFlags {
+ shared := &ctx.mod.sharedFlags
+ if shared.flagsMap == nil {
+ shared.numSharedFlags = 0
+ shared.flagsMap = make(map[string]string)
+ }
+ return shared
+}
+
func (ctx *moduleContextImpl) isCfiAssemblySupportEnabled() bool {
return ctx.mod.isCfiAssemblySupportEnabled()
}