diff options
author | Dan Willemsen <dwillemsen@google.com> | 2016-11-02 14:50:21 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2016-11-02 15:47:20 -0700 |
commit | 318af8be27ee681db5c72792065788f050f94735 (patch) | |
tree | d5f686a94f1ea02a4b6c7828dc2a9ff44e323a58 /cc/config | |
parent | 9194d8076cfbd53f0c08cfd8cc4d8ceccf0f6552 (diff) | |
download | build_soong-318af8be27ee681db5c72792065788f050f94735.tar.gz build_soong-318af8be27ee681db5c72792065788f050f94735.tar.bz2 build_soong-318af8be27ee681db5c72792065788f050f94735.zip |
Allow overriding tidy configs using environment variables
This matches what Make did.
Bug: 32244182
Test: WITH_TIDY=1 m -j
Test: WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=* m -j
Test: WITH_TIDY=1 DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS=* m -j
Change-Id: I12ee413829d35e20f21f8ca49bb315ea831a6506
Diffstat (limited to 'cc/config')
-rw-r--r-- | cc/config/tidy.go | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/cc/config/tidy.go b/cc/config/tidy.go index dd394216..a2fa5a2e 100644 --- a/cc/config/tidy.go +++ b/cc/config/tidy.go @@ -16,6 +16,8 @@ package config import ( "strings" + + "android/soong/android" ) func init() { @@ -23,27 +25,37 @@ func init() { // Global tidy checks include only google*, performance*, // and misc-macro-parentheses, but not google-readability* // or google-runtime-references. - pctx.StaticVariable("TidyDefaultGlobalChecks", strings.Join([]string{ - "-*", - "google*", - "misc-macro-parentheses", - "performance*", - "-google-readability*", - "-google-runtime-references", - }, ",")) + pctx.VariableFunc("TidyDefaultGlobalChecks", func(config interface{}) (string, error) { + if override := config.(android.Config).Getenv("DEFAULT_GLOBAL_TIDY_CHECKS"); override != "" { + return override, nil + } + return strings.Join([]string{ + "-*", + "google*", + "misc-macro-parentheses", + "performance*", + "-google-readability*", + "-google-runtime-references", + }, ","), nil + }) // There are too many clang-tidy warnings in external and vendor projects. // Enable only some google checks for these projects. - pctx.StaticVariable("TidyExternalVendorChecks", strings.Join([]string{ - "-*", - "google*", - "-google-build-using-namespace", - "-google-default-arguments", - "-google-explicit-constructor", - "-google-readability*", - "-google-runtime-int", - "-google-runtime-references", - }, ",")) + pctx.VariableFunc("TidyExternalVendorChecks", func(config interface{}) (string, error) { + if override := config.(android.Config).Getenv("DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS"); override != "" { + return override, nil + } + return strings.Join([]string{ + "-*", + "google*", + "-google-build-using-namespace", + "-google-default-arguments", + "-google-explicit-constructor", + "-google-readability*", + "-google-runtime-int", + "-google-runtime-references", + }, ","), nil + }) // Give warnings to header files only in selected directories. // Do not give warnings to external or vendor header files, which contain too |