Android Lint: allow local override of --exitcode flag

The --exitcode flag tells lint to exit with an error code if any
incidents at ERROR level or above are found.  Unfortunately, that means
an invocation of lint against the entire tree will fail with whichever
module fails first. This covers up any other failures and makes updating
lint in AOSP more cumbersome.

This change allows one to set `ANDROID_LINT_SUPPRESS_EXIT_CODE=true` to
modify this behavior and collect full lint results even if there are
errors in some modules.

Bug: 274780888
Test: Tested manually by changing code to trigger lint errors, and
settig/unsetting this flag.

Change-Id: I71ab89c9bffafe6eb83171102c2c253171450266
This commit is contained in:
mattgilbride
2023-03-22 17:44:18 +00:00
parent ff8c95b610
commit b597abdeb1

View File

@@ -496,7 +496,6 @@ func (l *linter) lint(ctx android.ModuleContext) {
FlagWithArg("--java-language-level ", l.javaLanguageLevel).
FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel).
FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())).
Flag("--exitcode").
Flag("--apply-suggestions"). // applies suggested fixes to files in the sandbox
Flags(l.properties.Lint.Flags).
Implicit(annotationsZipPath).
@@ -505,6 +504,10 @@ func (l *linter) lint(ctx android.ModuleContext) {
rule.Temporary(lintPaths.projectXML)
rule.Temporary(lintPaths.configXML)
if exitCode := ctx.Config().Getenv("ANDROID_LINT_SUPPRESS_EXIT_CODE"); exitCode == "" {
cmd.Flag("--exitcode")
}
if checkOnly := ctx.Config().Getenv("ANDROID_LINT_CHECK"); checkOnly != "" {
cmd.FlagWithArg("--check ", checkOnly)
}