Use DEFAULT_TIDY_HEADER_DIRS env variable.
This variable is a regular expression to be passed as
additional patterns to the -header-filter flag for clang-tidy.
For example, when make with WITH_TIDY=1 DEFAULT_TIDY_HEADER_DIRS="d1/d2|mydir/*"
for a project in external/xyz, clang-tidy will be called with additional flag
-header-filter=\"(external/xyz|d1/d2|mydir/*)\"
Test: make with WITH_TIDY=1 DEFAULT_TIDY_HEADER_DIRS="d1/d2|mydir/*"
Bug: 32668284
Change-Id: I6051f4f80bc6dbab882bd81435ccbc772772ac63
diff --git a/cc/config/tidy.go b/cc/config/tidy.go
index 67f92a2..3a858cd 100644
--- a/cc/config/tidy.go
+++ b/cc/config/tidy.go
@@ -61,20 +61,25 @@
// Give warnings to header files only in selected directories.
// Do not give warnings to external or vendor header files, which contain too
// many warnings.
- pctx.StaticVariable("TidyDefaultHeaderDirs", strings.Join([]string{
- "art/",
- "bionic/",
- "bootable/",
- "build/",
- "cts/",
- "dalvik/",
- "developers/",
- "development/",
- "frameworks/",
- "libcore/",
- "libnativehelper/",
- "system/",
- }, "|"))
+ pctx.VariableFunc("TidyDefaultHeaderDirs", func(ctx android.PackageVarContext) string {
+ if override := ctx.Config().Getenv("DEFAULT_TIDY_HEADER_DIRS"); override != "" {
+ return override
+ }
+ return strings.Join([]string{
+ "art/",
+ "bionic/",
+ "bootable/",
+ "build/",
+ "cts/",
+ "dalvik/",
+ "developers/",
+ "development/",
+ "frameworks/",
+ "libcore/",
+ "libnativehelper/",
+ "system/",
+ }, "|")
+ })
}
type PathBasedTidyCheck struct {