From 2b9c5f0c95c74eb5dfbea9bacd57c56de83a16f7 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 6 Jul 2020 11:45:51 -0700 Subject: Support lint on unbundled builds Use prebuilts of the annotations.zip and api-versions.xml files when running lint in an unbundled build. Bug: 153485543 Test: m TARGET_BUILD_APPS=Gallery2 lint-check Change-Id: Idacf3758a2769678a635941486183673e95b43f8 Merged-In: Idacf3758a2769678a635941486183673e95b43f8 (cherry picked from commit 8a6ed3750df5ce7fb4a8f2b1b623bfa1071449cb) --- java/lint.go | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/java/lint.go b/java/lint.go index b73d6a51..6fbef18c 100644 --- a/java/lint.go +++ b/java/lint.go @@ -220,12 +220,21 @@ func (l *linter) lint(ctx android.ModuleContext) { rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String()) rule.Command().Text("mkdir -p").Flag(cacheDir.String()).Flag(homeDir.String()) + var annotationsZipPath, apiVersionsXMLPath android.Path + if ctx.Config().UnbundledBuildUsePrebuiltSdks() { + annotationsZipPath = android.PathForSource(ctx, "prebuilts/sdk/current/public/data/annotations.zip") + apiVersionsXMLPath = android.PathForSource(ctx, "prebuilts/sdk/current/public/data/api-versions.xml") + } else { + annotationsZipPath = copiedAnnotationsZipPath(ctx) + apiVersionsXMLPath = copiedAPIVersionsXmlPath(ctx) + } + 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)). + FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath). + FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXMLPath). Tool(android.PathForSource(ctx, "prebuilts/cmdline-tools/tools/bin/lint")). Implicit(android.PathForSource(ctx, "prebuilts/cmdline-tools/tools/lib/lint-classpath.jar")). Flag("--quiet"). @@ -271,7 +280,7 @@ func (l *lintSingleton) GenerateBuildActions(ctx android.SingletonContext) { } func (l *lintSingleton) copyLintDependencies(ctx android.SingletonContext) { - if ctx.Config().UnbundledBuild() { + if ctx.Config().UnbundledBuildUsePrebuiltSdks() { return } @@ -297,25 +306,29 @@ func (l *lintSingleton) copyLintDependencies(ctx android.SingletonContext) { ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, Input: android.OutputFileForModule(ctx, frameworkDocStubs, ".annotations.zip"), - Output: annotationsZipPath(ctx), + Output: copiedAnnotationsZipPath(ctx), }) ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, Input: android.OutputFileForModule(ctx, frameworkDocStubs, ".api_versions.xml"), - Output: apiVersionsXmlPath(ctx), + Output: copiedAPIVersionsXmlPath(ctx), }) } -func annotationsZipPath(ctx android.PathContext) android.WritablePath { +func copiedAnnotationsZipPath(ctx android.PathContext) android.WritablePath { return android.PathForOutput(ctx, "lint", "annotations.zip") } -func apiVersionsXmlPath(ctx android.PathContext) android.WritablePath { +func copiedAPIVersionsXmlPath(ctx android.PathContext) android.WritablePath { return android.PathForOutput(ctx, "lint", "api_versions.xml") } func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) { + if ctx.Config().UnbundledBuild() { + return + } + var outputs []*lintOutputs var dirs []string ctx.VisitAllModules(func(m android.Module) { @@ -370,7 +383,9 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) { } func (l *lintSingleton) MakeVars(ctx android.MakeVarsContext) { - ctx.DistForGoal("lint-check", l.htmlZip, l.textZip, l.xmlZip) + if !ctx.Config().UnbundledBuild() { + ctx.DistForGoal("lint-check", l.htmlZip, l.textZip, l.xmlZip) + } } var _ android.SingletonMakeVarsProvider = (*lintSingleton)(nil) -- cgit v1.2.3