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
This commit is contained in:
Chih-Hung Hsieh
2022-01-08 19:56:09 -08:00
parent 443703ab32
commit 7540a78a35
7 changed files with 57 additions and 26 deletions

View File

@@ -210,11 +210,12 @@ type Flags struct {
// 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 @@ type ModuleContextIntf interface {
directlyInAnyApex() bool
isPreventInstall() bool
isCfiAssemblySupportEnabled() bool
getSharedFlags() *SharedFlags
}
type SharedFlags struct {
numSharedFlags int
flagsMap map[string]string
}
type ModuleContext interface {
@@ -827,6 +834,9 @@ type Module struct {
// 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 @@ func (ctx *moduleContextImpl) isPreventInstall() bool {
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()
}