Add TIDY_EXTERNAL_VENDOR
Allow external/vendor owners and toolchain developers
to run clang-tidy with external/vendor files,
by setting TIDY_EXTERNAL_VENDOR=1 or true
instead of touching .bp or .go files.
Bug: 244631413
Test: TIDY_EXTERNAL_VENDOR=1 make tidy-soong_subset
Change-Id: I0c903f32eb0e5daa0f8dfa2f6dc892b8f8c4ebcc
diff --git a/cc/tidy.go b/cc/tidy.go
index 082cf88..2ba13ca 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -76,9 +76,12 @@
if tidy.Properties.Tidy != nil && !*tidy.Properties.Tidy {
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) {
+ // Some projects like external/* and vendor/* have clang-tidy disabled by default,
+ // unless they are enabled explicitly with the "tidy:true" property or
+ // when TIDY_EXTERNAL_VENDOR is set to true.
+ if !ctx.Config().IsEnvTrue("TIDY_EXTERNAL_VENDOR") &&
+ !proptools.Bool(tidy.Properties.Tidy) &&
+ config.NoClangTidyForDir(ctx.ModuleDir()) {
return flags
}
// If not explicitly disabled, set flags.Tidy to generate .tidy rules.