Merge "No clang-tidy by default for external and vendor"
This commit is contained in:
commit
cedd4117a8
2 changed files with 21 additions and 8 deletions
|
@ -164,19 +164,21 @@ const tidyExternalVendor = "${config.TidyExternalVendorChecks}"
|
||||||
const tidyDefaultNoAnalyzer = "${config.TidyDefaultGlobalChecks},-clang-analyzer-*"
|
const tidyDefaultNoAnalyzer = "${config.TidyDefaultGlobalChecks},-clang-analyzer-*"
|
||||||
|
|
||||||
// This is a map of local path prefixes to the set of default clang-tidy checks
|
// This is a map of local path prefixes to the set of default clang-tidy checks
|
||||||
// to be used.
|
// to be used. This is like android.IsThirdPartyPath, but with more patterns.
|
||||||
// The last matched local_path_prefix should be the most specific to be used.
|
// The last matched local_path_prefix should be the most specific to be used.
|
||||||
var DefaultLocalTidyChecks = []PathBasedTidyCheck{
|
var DefaultLocalTidyChecks = []PathBasedTidyCheck{
|
||||||
{"external/", tidyExternalVendor},
|
{"external/", tidyExternalVendor},
|
||||||
{"external/google", tidyDefault},
|
|
||||||
{"external/webrtc", tidyDefault},
|
|
||||||
{"external/googletest/", tidyExternalVendor},
|
|
||||||
{"frameworks/compile/mclinker/", tidyExternalVendor},
|
{"frameworks/compile/mclinker/", tidyExternalVendor},
|
||||||
{"hardware/qcom", tidyExternalVendor},
|
{"hardware/", tidyExternalVendor},
|
||||||
|
{"hardware/google/", tidyDefault},
|
||||||
|
{"hardware/interfaces/", tidyDefault},
|
||||||
|
{"hardware/ril/", tidyDefault},
|
||||||
|
{"hardware/libhardware", tidyDefault}, // all 'hardware/libhardware*'
|
||||||
{"vendor/", tidyExternalVendor},
|
{"vendor/", tidyExternalVendor},
|
||||||
{"vendor/google", tidyDefault},
|
{"vendor/google", tidyDefault}, // all 'vendor/google*'
|
||||||
|
{"vendor/google/external/", tidyExternalVendor},
|
||||||
{"vendor/google_arc/libs/org.chromium.arc.mojom", tidyExternalVendor},
|
{"vendor/google_arc/libs/org.chromium.arc.mojom", tidyExternalVendor},
|
||||||
{"vendor/google_devices", tidyExternalVendor},
|
{"vendor/google_devices/", tidyExternalVendor}, // many have vendor code
|
||||||
}
|
}
|
||||||
|
|
||||||
var reversedDefaultLocalTidyChecks = reverseTidyChecks(DefaultLocalTidyChecks)
|
var reversedDefaultLocalTidyChecks = reverseTidyChecks(DefaultLocalTidyChecks)
|
||||||
|
@ -199,6 +201,13 @@ func TidyChecksForDir(dir string) string {
|
||||||
return tidyDefault
|
return tidyDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NoClangTidyForDir(dir string) bool {
|
||||||
|
// This function depends on TidyChecksForDir, which selects tidyExternalVendor
|
||||||
|
// checks for external/vendor projects. For those projects we disable clang-tidy
|
||||||
|
// by default, unless some modules enable clang-tidy with tidy:true.
|
||||||
|
return TidyChecksForDir(dir) == tidyExternalVendor
|
||||||
|
}
|
||||||
|
|
||||||
// Returns a globally disabled tidy checks, overriding locally selected checks.
|
// Returns a globally disabled tidy checks, overriding locally selected checks.
|
||||||
func TidyGlobalNoChecks() string {
|
func TidyGlobalNoChecks() string {
|
||||||
if len(globalNoCheckList) > 0 {
|
if len(globalNoCheckList) > 0 {
|
||||||
|
|
|
@ -76,7 +76,11 @@ func (tidy *tidyFeature) flags(ctx ModuleContext, flags Flags) Flags {
|
||||||
if tidy.Properties.Tidy != nil && !*tidy.Properties.Tidy {
|
if tidy.Properties.Tidy != nil && !*tidy.Properties.Tidy {
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
// Some projects like external/* and vendor/* have clang-tidy disabled by default.
|
||||||
|
// They can enable clang-tidy explicitly with the "tidy:true" property.
|
||||||
|
if config.NoClangTidyForDir(ctx.ModuleDir()) && !proptools.Bool(tidy.Properties.Tidy) {
|
||||||
|
return flags
|
||||||
|
}
|
||||||
// If not explicitly disabled, set flags.Tidy to generate .tidy rules.
|
// If not explicitly disabled, set flags.Tidy to generate .tidy rules.
|
||||||
// Note that libraries and binaries will depend on .tidy files ONLY if
|
// Note that libraries and binaries will depend on .tidy files ONLY if
|
||||||
// the global WITH_TIDY or module 'tidy' property is true.
|
// the global WITH_TIDY or module 'tidy' property is true.
|
||||||
|
|
Loading…
Reference in a new issue