aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2020-06-24 00:14:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-24 00:14:23 +0000
commit16e8b0492d25772c5fdae76265a1830c147dcf2e (patch)
treeec7794e2d5e951428edb82697c581d24964984ce /java
parent433ea2321a175260969d757bc8e90547466c30d0 (diff)
parent91edfc29c3fa54b8f55642724fc9e90397d225cc (diff)
downloadbuild_soong-16e8b0492d25772c5fdae76265a1830c147dcf2e.tar.gz
build_soong-16e8b0492d25772c5fdae76265a1830c147dcf2e.tar.bz2
build_soong-16e8b0492d25772c5fdae76265a1830c147dcf2e.zip
Merge changes Ie163a4da,I16375b88 into rvc-dev
* changes: Set root dir in lint project.xml Set ANDROID_SDK_HOME when running lint
Diffstat (limited to 'java')
-rw-r--r--java/lint.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/java/lint.go b/java/lint.go
index fac9a198..b73d6a51 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -88,7 +88,7 @@ func (l *linter) deps(ctx android.BottomUpMutatorContext) {
}
func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
- rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir android.WritablePath, deps android.Paths) {
+ rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir, homeDir android.WritablePath, deps android.Paths) {
var resourcesList android.WritablePath
if len(l.resources) > 0 {
@@ -106,6 +106,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
// Lint looks for a lint.xml file next to the project.xml file, give it one.
configXMLPath = android.PathForModuleOut(ctx, "lint", "lint.xml")
cacheDir = android.PathForModuleOut(ctx, "lint", "cache")
+ homeDir = android.PathForModuleOut(ctx, "lint", "home")
srcJarDir := android.PathForModuleOut(ctx, "lint-srcjars")
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, l.srcJars)
@@ -154,8 +155,11 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
cmd.FlagForEachArg("--extra_checks_jar ", l.extraLintCheckJars.Strings())
deps = append(deps, l.extraLintCheckJars...)
- // The cache tag in project.xml is relative to the project.xml file.
- cmd.FlagWithArg("--cache_dir ", "cache")
+ cmd.FlagWithArg("--root_dir ", "$PWD")
+
+ // The cache tag in project.xml is relative to the root dir, or the project.xml file if
+ // the root dir is not set.
+ cmd.FlagWithArg("--cache_dir ", cacheDir.String())
cmd.FlagWithInput("@",
android.PathForSource(ctx, "build/soong/java/lint_defaults.txt"))
@@ -165,7 +169,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext,
cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks)
cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks)
- return projectXMLPath, configXMLPath, cacheDir, deps
+ return projectXMLPath, configXMLPath, cacheDir, homeDir, deps
}
// generateManifest adds a command to the rule to write a dummy manifest cat contains the
@@ -207,18 +211,19 @@ func (l *linter) lint(ctx android.ModuleContext) {
l.manifest = manifest
}
- projectXML, lintXML, cacheDir, deps := l.writeLintProjectXML(ctx, rule)
+ projectXML, lintXML, cacheDir, homeDir, deps := l.writeLintProjectXML(ctx, rule)
l.outputs.html = android.PathForModuleOut(ctx, "lint-report.html")
l.outputs.text = android.PathForModuleOut(ctx, "lint-report.txt")
l.outputs.xml = android.PathForModuleOut(ctx, "lint-report.xml")
- rule.Command().Text("rm -rf").Flag(cacheDir.String())
- rule.Command().Text("mkdir -p").Flag(cacheDir.String())
+ rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())
+ rule.Command().Text("mkdir -p").Flag(cacheDir.String()).Flag(homeDir.String())
rule.Command().
Text("(").
Flag("JAVA_OPTS=-Xmx2048m").
+ FlagWithArg("ANDROID_SDK_HOME=", homeDir.String()).
FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath(ctx)).
FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXmlPath(ctx)).
Tool(android.PathForSource(ctx, "prebuilts/cmdline-tools/tools/bin/lint")).
@@ -239,7 +244,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
Text("|| (").Text("cat").Input(l.outputs.text).Text("; exit 7)").
Text(")")
- rule.Command().Text("rm -rf").Flag(cacheDir.String())
+ rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())
rule.Build(pctx, ctx, "lint", "lint")
}