Add environment variables to control lint checks
Set ANDROID_LINT_CHECK to a comma-separated list of lint issues that should be checked instead of the defaults. This will disable all lint checks and enable only the given list. Set ANDROID_LINT_CHECK_EXTRA_MODULES to a list of modules that provide lint checks that should added to all modules when ANDROID_LINT_CHECK is specified. Bug: 153485543 Test: m ANDROID_LINT_CHECK=JavaKotlinApiUsedByModule ANDROID_LINT_CHECK_EXTRA_MODULES=JavaKotlinApiFinder TARGET_BUILD_APPS=Gallery2 lint-check dist Change-Id: Ifdf9bf972b8550104315b0f5e98b34ad699dcb67
This commit is contained in:
24
java/lint.go
24
java/lint.go
@@ -17,6 +17,7 @@ package java
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
@@ -104,7 +105,16 @@ func (l *linter) deps(ctx android.BottomUpMutatorContext) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), extraLintCheckTag, l.properties.Lint.Extra_check_modules...)
|
||||
extraCheckModules := l.properties.Lint.Extra_check_modules
|
||||
|
||||
if checkOnly := ctx.Config().Getenv("ANDROID_LINT_CHECK"); checkOnly != "" {
|
||||
if checkOnlyModules := ctx.Config().Getenv("ANDROID_LINT_CHECK_EXTRA_MODULES"); checkOnlyModules != "" {
|
||||
extraCheckModules = strings.Split(checkOnlyModules, ",")
|
||||
}
|
||||
}
|
||||
|
||||
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(),
|
||||
extraLintCheckTag, extraCheckModules...)
|
||||
}
|
||||
|
||||
func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
|
||||
@@ -262,7 +272,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
|
||||
apiVersionsXMLPath = copiedAPIVersionsXmlPath(ctx)
|
||||
}
|
||||
|
||||
rule.Command().
|
||||
cmd := rule.Command().
|
||||
Text("(").
|
||||
Flag("JAVA_OPTS=-Xmx2048m").
|
||||
FlagWithArg("ANDROID_SDK_HOME=", homeDir.String()).
|
||||
@@ -282,9 +292,13 @@ func (l *linter) lint(ctx android.ModuleContext) {
|
||||
FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())).
|
||||
Flag("--exitcode").
|
||||
Flags(l.properties.Lint.Flags).
|
||||
Implicits(deps).
|
||||
Text("|| (").Text("cat").Input(text).Text("; exit 7)").
|
||||
Text(")")
|
||||
Implicits(deps)
|
||||
|
||||
if checkOnly := ctx.Config().Getenv("ANDROID_LINT_CHECK"); checkOnly != "" {
|
||||
cmd.FlagWithArg("--check ", checkOnly)
|
||||
}
|
||||
|
||||
cmd.Text("|| (").Text("cat").Input(text).Text("; exit 7)").Text(")")
|
||||
|
||||
rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())
|
||||
|
||||
|
Reference in New Issue
Block a user