aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/androidmk.go18
-rwxr-xr-xjava/app.go44
-rw-r--r--java/java.go9
-rw-r--r--java/lint.go138
4 files changed, 157 insertions, 52 deletions
diff --git a/java/androidmk.go b/java/androidmk.go
index 8953c31c..62f97067 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -131,6 +131,10 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
}
entries.SetString("LOCAL_MODULE_STEM", library.Stem())
+
+ entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", library.linter.outputs.transitiveHTMLZip)
+ entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", library.linter.outputs.transitiveTextZip)
+ entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", library.linter.outputs.transitiveXMLZip)
},
},
}
@@ -370,9 +374,15 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
- for _, jniLib := range app.installJniLibs {
- entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
+ if app.embeddedJniLibs {
+ jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
+ entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
+ } else {
+ for _, jniLib := range app.jniLibs {
+ entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
+ }
}
+
if len(app.jniCoverageOutputs) > 0 {
entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
}
@@ -383,6 +393,10 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
install := app.onDeviceDir + "/" + extra.Base()
entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
}
+
+ entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", app.linter.outputs.transitiveHTMLZip)
+ entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", app.linter.outputs.transitiveTextZip)
+ entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", app.linter.outputs.transitiveXMLZip)
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{
diff --git a/java/app.go b/java/app.go
index 5af89b9c..e75d8749 100755
--- a/java/app.go
+++ b/java/app.go
@@ -291,8 +291,10 @@ type AndroidApp struct {
overridableAppProperties overridableAppProperties
- installJniLibs []jniLib
- jniCoverageOutputs android.Paths
+ jniLibs []jniLib
+ installPathForJNISymbols android.Path
+ embeddedJniLibs bool
+ jniCoverageOutputs android.Paths
bundleFile android.Path
@@ -567,8 +569,7 @@ func (a *AndroidApp) proguardBuildActions(ctx android.ModuleContext) {
a.Module.extraProguardFlagFiles = append(a.Module.extraProguardFlagFiles, a.proguardOptionsFile)
}
-func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) android.Path {
-
+func (a *AndroidApp) installPath(ctx android.ModuleContext) android.InstallPath {
var installDir string
if ctx.ModuleName() == "framework-res" {
// framework-res.apk is installed as system/framework/framework-res.apk
@@ -578,7 +579,12 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) android.Path {
} else {
installDir = filepath.Join("app", a.installApkName)
}
- a.dexpreopter.installPath = android.PathForModuleInstall(ctx, installDir, a.installApkName+".apk")
+
+ return android.PathForModuleInstall(ctx, installDir, a.installApkName+".apk")
+}
+
+func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) android.Path {
+ a.dexpreopter.installPath = a.installPath(ctx)
if a.deviceProperties.Uncompress_dex == nil {
// If the value was not force-set by the user, use reasonable default based on the module.
a.deviceProperties.Uncompress_dex = proptools.BoolPtr(a.shouldUncompressDex(ctx))
@@ -600,8 +606,10 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) android.Path {
func (a *AndroidApp) jniBuildActions(jniLibs []jniLib, ctx android.ModuleContext) android.WritablePath {
var jniJarFile android.WritablePath
if len(jniLibs) > 0 {
+ a.jniLibs = jniLibs
if a.shouldEmbedJnis(ctx) {
jniJarFile = android.PathForModuleOut(ctx, "jnilibs.zip")
+ a.installPathForJNISymbols = a.installPath(ctx).ToMakePath()
TransformJniLibsToJar(ctx, jniJarFile, jniLibs, a.useEmbeddedNativeLibs(ctx))
for _, jni := range jniLibs {
if jni.coverageFile.Valid() {
@@ -619,13 +627,25 @@ func (a *AndroidApp) jniBuildActions(jniLibs []jniLib, ctx android.ModuleContext
}
}
}
- } else {
- a.installJniLibs = jniLibs
+ a.embeddedJniLibs = true
}
}
return jniJarFile
}
+func (a *AndroidApp) JNISymbolsInstalls(installPath string) android.RuleBuilderInstalls {
+ var jniSymbols android.RuleBuilderInstalls
+ for _, jniLib := range a.jniLibs {
+ if jniLib.unstrippedFile != nil {
+ jniSymbols = append(jniSymbols, android.RuleBuilderInstall{
+ From: jniLib.unstrippedFile,
+ To: filepath.Join(installPath, targetToJniDir(jniLib.target), jniLib.unstrippedFile.Base()),
+ })
+ }
+ }
+ return jniSymbols
+}
+
func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext) {
// Collect NOTICE files from all dependencies.
seenModules := make(map[android.Module]bool)
@@ -749,6 +769,7 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.linter.mergedManifest = a.aapt.mergedManifestFile
a.linter.manifest = a.aapt.manifestPath
a.linter.resources = a.aapt.resourceFiles
+ a.linter.buildModuleReportZip = ctx.Config().UnbundledBuild()
dexJarFile := a.dexBuildActions(ctx)
@@ -851,10 +872,11 @@ func collectAppDeps(ctx android.ModuleContext, app appDepsInterface,
if lib.Valid() {
jniLibs = append(jniLibs, jniLib{
- name: ctx.OtherModuleName(module),
- path: path,
- target: module.Target(),
- coverageFile: dep.CoverageOutputFile(),
+ name: ctx.OtherModuleName(module),
+ path: path,
+ target: module.Target(),
+ coverageFile: dep.CoverageOutputFile(),
+ unstrippedFile: dep.UnstrippedOutputFile(),
})
} else {
ctx.ModuleErrorf("dependency %q missing output file", otherName)
diff --git a/java/java.go b/java/java.go
index 72c91a5e..0a764e63 100644
--- a/java/java.go
+++ b/java/java.go
@@ -626,10 +626,11 @@ func (s sdkDep) hasFrameworkLibs() bool {
}
type jniLib struct {
- name string
- path android.Path
- target android.Target
- coverageFile android.OptionalPath
+ name string
+ path android.Path
+ target android.Target
+ coverageFile android.OptionalPath
+ unstrippedFile android.Path
}
func (j *Module) shouldInstrument(ctx android.BaseModuleContext) bool {
diff --git a/java/lint.go b/java/lint.go
index b73d6a51..20a7dc49 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -67,12 +67,32 @@ type linter struct {
kotlinLanguageLevel string
outputs lintOutputs
properties LintProperties
+
+ buildModuleReportZip bool
}
type lintOutputs struct {
html android.ModuleOutPath
text android.ModuleOutPath
xml android.ModuleOutPath
+
+ transitiveHTML *android.DepSet
+ transitiveText *android.DepSet
+ transitiveXML *android.DepSet
+
+ transitiveHTMLZip android.OptionalPath
+ transitiveTextZip android.OptionalPath
+ transitiveXMLZip android.OptionalPath
+}
+
+type lintOutputIntf interface {
+ lintOutputs() *lintOutputs
+}
+
+var _ lintOutputIntf = (*linter)(nil)
+
+func (l *linter) lintOutputs() *lintOutputs {
+ return &l.outputs
}
func (l *linter) enabled() bool {
@@ -213,27 +233,49 @@ func (l *linter) lint(ctx android.ModuleContext) {
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")
+ html := android.PathForModuleOut(ctx, "lint-report.html")
+ text := android.PathForModuleOut(ctx, "lint-report.txt")
+ xml := android.PathForModuleOut(ctx, "lint-report.xml")
+
+ htmlDeps := android.NewDepSetBuilder(android.POSTORDER).Direct(html)
+ textDeps := android.NewDepSetBuilder(android.POSTORDER).Direct(text)
+ xmlDeps := android.NewDepSetBuilder(android.POSTORDER).Direct(xml)
+
+ ctx.VisitDirectDepsWithTag(staticLibTag, func(dep android.Module) {
+ if depLint, ok := dep.(lintOutputIntf); ok {
+ depLintOutputs := depLint.lintOutputs()
+ htmlDeps.Transitive(depLintOutputs.transitiveHTML)
+ textDeps.Transitive(depLintOutputs.transitiveText)
+ xmlDeps.Transitive(depLintOutputs.transitiveXML)
+ }
+ })
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").
FlagWithInput("--project ", projectXML).
FlagWithInput("--config ", lintXML).
- FlagWithOutput("--html ", l.outputs.html).
- FlagWithOutput("--text ", l.outputs.text).
- FlagWithOutput("--xml ", l.outputs.xml).
+ FlagWithOutput("--html ", html).
+ FlagWithOutput("--text ", text).
+ FlagWithOutput("--xml ", xml).
FlagWithArg("--compile-sdk-version ", l.compileSdkVersion).
FlagWithArg("--java-language-level ", l.javaLanguageLevel).
FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel).
@@ -241,23 +283,37 @@ func (l *linter) lint(ctx android.ModuleContext) {
Flag("--exitcode").
Flags(l.properties.Lint.Flags).
Implicits(deps).
- Text("|| (").Text("cat").Input(l.outputs.text).Text("; exit 7)").
+ Text("|| (").Text("cat").Input(text).Text("; exit 7)").
Text(")")
rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())
rule.Build(pctx, ctx, "lint", "lint")
-}
-func (l *linter) lintOutputs() *lintOutputs {
- return &l.outputs
-}
+ l.outputs = lintOutputs{
+ html: html,
+ text: text,
+ xml: xml,
-type lintOutputIntf interface {
- lintOutputs() *lintOutputs
-}
+ transitiveHTML: htmlDeps.Build(),
+ transitiveText: textDeps.Build(),
+ transitiveXML: xmlDeps.Build(),
+ }
-var _ lintOutputIntf = (*linter)(nil)
+ if l.buildModuleReportZip {
+ htmlZip := android.PathForModuleOut(ctx, "lint-report-html.zip")
+ l.outputs.transitiveHTMLZip = android.OptionalPathForPath(htmlZip)
+ lintZip(ctx, l.outputs.transitiveHTML.ToSortedList(), htmlZip)
+
+ textZip := android.PathForModuleOut(ctx, "lint-report-text.zip")
+ l.outputs.transitiveTextZip = android.OptionalPathForPath(textZip)
+ lintZip(ctx, l.outputs.transitiveText.ToSortedList(), textZip)
+
+ xmlZip := android.PathForModuleOut(ctx, "lint-report-xml.zip")
+ l.outputs.transitiveXMLZip = android.OptionalPathForPath(xmlZip)
+ lintZip(ctx, l.outputs.transitiveXML.ToSortedList(), xmlZip)
+ }
+}
type lintSingleton struct {
htmlZip android.WritablePath
@@ -271,7 +327,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 +353,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) {
@@ -343,18 +403,7 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) {
paths = append(paths, get(output))
}
- sort.Slice(paths, func(i, j int) bool {
- return paths[i].String() < paths[j].String()
- })
-
- rule := android.NewRuleBuilder()
-
- rule.Command().BuiltTool(ctx, "soong_zip").
- FlagWithOutput("-o ", outputPath).
- FlagWithArg("-C ", android.PathForIntermediates(ctx).String()).
- FlagWithRspFileInputList("-l ", paths)
-
- rule.Build(pctx, ctx, outputPath.Base(), outputPath.Base())
+ lintZip(ctx, paths, outputPath)
}
l.htmlZip = android.PathForOutput(ctx, "lint-report-html.zip")
@@ -370,7 +419,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)
@@ -379,3 +430,20 @@ func init() {
android.RegisterSingletonType("lint",
func() android.Singleton { return &lintSingleton{} })
}
+
+func lintZip(ctx android.BuilderContext, paths android.Paths, outputPath android.WritablePath) {
+ paths = android.SortedUniquePaths(android.CopyOfPaths(paths))
+
+ sort.Slice(paths, func(i, j int) bool {
+ return paths[i].String() < paths[j].String()
+ })
+
+ rule := android.NewRuleBuilder()
+
+ rule.Command().BuiltTool(ctx, "soong_zip").
+ FlagWithOutput("-o ", outputPath).
+ FlagWithArg("-C ", android.PathForIntermediates(ctx).String()).
+ FlagWithRspFileInputList("-l ", paths)
+
+ rule.Build(pctx, ctx, outputPath.Base(), outputPath.Base())
+}