Support adding extra lint checks
Add a lint.extra_check_modules property to list modules to use as
plugins to Lint.
Bug: 153485543
Test: m checkbuild
Change-Id: I25c7799438cfec43163e757637c65b8657488d36
Merged-In: I25c7799438cfec43163e757637c65b8657488d36
(cherry picked from commit 92e4b46af5
)
This commit is contained in:
@@ -574,6 +574,7 @@ var (
|
|||||||
certificateTag = dependencyTag{name: "certificate"}
|
certificateTag = dependencyTag{name: "certificate"}
|
||||||
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
|
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
|
||||||
usesLibTag = dependencyTag{name: "uses-library"}
|
usesLibTag = dependencyTag{name: "uses-library"}
|
||||||
|
extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
|
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
|
||||||
@@ -668,6 +669,8 @@ func (j *Module) AvailableFor(what string) bool {
|
|||||||
|
|
||||||
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
|
j.linter.deps(ctx)
|
||||||
|
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||||
if sdkDep.useDefaultLibs {
|
if sdkDep.useDefaultLibs {
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||||
|
21
java/lint.go
21
java/lint.go
@@ -42,6 +42,9 @@ type LintProperties struct {
|
|||||||
|
|
||||||
// Checks that should be skipped.
|
// Checks that should be skipped.
|
||||||
Disabled_checks []string
|
Disabled_checks []string
|
||||||
|
|
||||||
|
// Modules that provide extra lint checks
|
||||||
|
Extra_check_modules []string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +79,14 @@ func (l *linter) enabled() bool {
|
|||||||
return BoolDefault(l.properties.Lint.Enabled, true)
|
return BoolDefault(l.properties.Lint.Enabled, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *linter) deps(ctx android.BottomUpMutatorContext) {
|
||||||
|
if !l.enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), extraLintCheckTag, l.properties.Lint.Extra_check_modules...)
|
||||||
|
}
|
||||||
|
|
||||||
func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
|
func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
|
||||||
rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir android.WritablePath, deps android.Paths) {
|
rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir android.WritablePath, deps android.Paths) {
|
||||||
|
|
||||||
@@ -179,6 +190,16 @@ func (l *linter) lint(ctx android.ModuleContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag)
|
||||||
|
for _, extraLintCheckModule := range extraLintCheckModules {
|
||||||
|
if dep, ok := extraLintCheckModule.(Dependency); ok {
|
||||||
|
l.extraLintCheckJars = append(l.extraLintCheckJars, dep.ImplementationAndResourcesJars()...)
|
||||||
|
} else {
|
||||||
|
ctx.PropertyErrorf("lint.extra_check_modules",
|
||||||
|
"%s is not a java module", ctx.OtherModuleName(extraLintCheckModule))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rule := android.NewRuleBuilder()
|
rule := android.NewRuleBuilder()
|
||||||
|
|
||||||
if l.manifest == nil {
|
if l.manifest == nil {
|
||||||
|
Reference in New Issue
Block a user