Merge "Change default DEFAULT_TIDY_HEADER_DIRS to empty"
This commit is contained in:
@@ -137,6 +137,16 @@ func HasAnyPrefix(s string, prefixList []string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if any string in the given list has the given substring.
|
||||||
|
func SubstringInList(list []string, substr string) bool {
|
||||||
|
for _, s := range list {
|
||||||
|
if strings.Contains(s, substr) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Returns true if any string in the given list has the given prefix.
|
// Returns true if any string in the given list has the given prefix.
|
||||||
func PrefixInList(list []string, prefix string) bool {
|
func PrefixInList(list []string, prefix string) bool {
|
||||||
for _, s := range list {
|
for _, s := range list {
|
||||||
|
@@ -87,27 +87,11 @@ func init() {
|
|||||||
}, ",")
|
}, ",")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Give warnings to header files only in selected directories.
|
// To reduce duplicate warnings from the same header files,
|
||||||
// Do not give warnings to external or vendor header files, which contain too
|
// header-filter will contain only the module directory and
|
||||||
// many warnings.
|
// those specified by DEFAULT_TIDY_HEADER_DIRS.
|
||||||
pctx.VariableFunc("TidyDefaultHeaderDirs", func(ctx android.PackageVarContext) string {
|
pctx.VariableFunc("TidyDefaultHeaderDirs", func(ctx android.PackageVarContext) string {
|
||||||
if override := ctx.Config().Getenv("DEFAULT_TIDY_HEADER_DIRS"); override != "" {
|
return ctx.Config().Getenv("DEFAULT_TIDY_HEADER_DIRS")
|
||||||
return override
|
|
||||||
}
|
|
||||||
return strings.Join([]string{
|
|
||||||
"art/",
|
|
||||||
"bionic/",
|
|
||||||
"bootable/",
|
|
||||||
"build/",
|
|
||||||
"cts/",
|
|
||||||
"dalvik/",
|
|
||||||
"developers/",
|
|
||||||
"development/",
|
|
||||||
"frameworks/",
|
|
||||||
"libcore/",
|
|
||||||
"libnativehelper/",
|
|
||||||
"system/",
|
|
||||||
}, "|")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Use WTIH_TIDY_FLAGS to pass extra global default clang-tidy flags.
|
// Use WTIH_TIDY_FLAGS to pass extra global default clang-tidy flags.
|
||||||
|
15
cc/tidy.go
15
cc/tidy.go
@@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
"android/soong/cc/config"
|
"android/soong/cc/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -75,9 +76,17 @@ func (tidy *tidyFeature) flags(ctx ModuleContext, flags Flags) Flags {
|
|||||||
}
|
}
|
||||||
esc := proptools.NinjaAndShellEscapeList
|
esc := proptools.NinjaAndShellEscapeList
|
||||||
flags.TidyFlags = append(flags.TidyFlags, esc(tidy.Properties.Tidy_flags)...)
|
flags.TidyFlags = append(flags.TidyFlags, esc(tidy.Properties.Tidy_flags)...)
|
||||||
// If TidyFlags is empty, add default header filter.
|
// If TidyFlags does not contain -header-filter, add default header filter.
|
||||||
if len(flags.TidyFlags) == 0 {
|
// Find the substring because the flag could also appear as --header-filter=...
|
||||||
headerFilter := "-header-filter=\"(" + ctx.ModuleDir() + "|${config.TidyDefaultHeaderDirs})\""
|
// and with or without single or double quotes.
|
||||||
|
if !android.SubstringInList(flags.TidyFlags, "-header-filter=") {
|
||||||
|
defaultDirs := ctx.Config().Getenv("DEFAULT_TIDY_HEADER_DIRS")
|
||||||
|
headerFilter := "-header-filter="
|
||||||
|
if defaultDirs == "" {
|
||||||
|
headerFilter += ctx.ModuleDir() + "/"
|
||||||
|
} else {
|
||||||
|
headerFilter += "\"(" + ctx.ModuleDir() + "/|" + defaultDirs + ")\""
|
||||||
|
}
|
||||||
flags.TidyFlags = append(flags.TidyFlags, headerFilter)
|
flags.TidyFlags = append(flags.TidyFlags, headerFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user