diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/app.go | 4 | ||||
| -rw-r--r-- | java/app_import.go | 8 | ||||
| -rw-r--r-- | java/base.go | 37 | ||||
| -rw-r--r-- | java/bootclasspath_fragment.go | 5 | ||||
| -rw-r--r-- | java/classpath_fragment.go | 4 | ||||
| -rw-r--r-- | java/dex.go | 9 | ||||
| -rw-r--r-- | java/droiddoc.go | 1 | ||||
| -rw-r--r-- | java/droidstubs.go | 22 | ||||
| -rw-r--r-- | java/java.go | 3 | ||||
| -rw-r--r-- | java/java_test.go | 1 | ||||
| -rw-r--r-- | java/rro.go | 6 | ||||
| -rw-r--r-- | java/sdk_library.go | 6 | ||||
| -rw-r--r-- | java/systemserver_classpath_fragment.go | 5 | ||||
| -rw-r--r-- | java/testing.go | 3 |
14 files changed, 53 insertions, 61 deletions
diff --git a/java/app.go b/java/app.go index 8bb73cb38..7f80160a3 100644 --- a/java/app.go +++ b/java/app.go @@ -164,7 +164,7 @@ type appProperties struct { type overridableAppProperties struct { // The name of a certificate in the default certificate directory, blank to use the default product certificate, // or an android_app_certificate module name in the form ":module". - Certificate *string + Certificate proptools.Configurable[string] `android:"replace_instead_of_append"` // Name of the signing certificate lineage file or filegroup module. Lineage *string `android:"path"` @@ -1252,7 +1252,7 @@ func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string { if overridden { return ":" + certificate } - return String(a.overridableAppProperties.Certificate) + return a.overridableAppProperties.Certificate.GetOrDefault(ctx, "") } func (a *AndroidApp) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { diff --git a/java/app_import.go b/java/app_import.go index f044c6848..8951c7d9c 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -97,7 +97,7 @@ type AndroidAppImportProperties struct { // The name of a certificate in the default certificate directory or an android_app_certificate // module name in the form ":module". Should be empty if presigned or default_dev_cert is set. - Certificate *string + Certificate proptools.Configurable[string] `android:"replace_instead_of_append"` // Names of extra android_app_certificate modules to sign the apk with in the form ":module". Additional_certificates []string @@ -240,7 +240,7 @@ func disablePrebuiltsWithoutApkMutator(ctx android.BottomUpMutatorContext) { } func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) { - cert := android.SrcIsModule(String(a.properties.Certificate)) + cert := android.SrcIsModule(a.properties.Certificate.GetOrDefault(ctx, "")) if cert != "" { ctx.AddDependency(ctx.Module(), certificateTag, cert) } @@ -323,7 +323,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext } numCertPropsSet := 0 - if String(a.properties.Certificate) != "" { + if a.properties.Certificate.GetOrDefault(ctx, "") != "" { numCertPropsSet++ } if Bool(a.properties.Presigned) { @@ -406,7 +406,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext // If the certificate property is empty at this point, default_dev_cert must be set to true. // Which makes processMainCert's behavior for the empty cert string WAI. _, _, certificates := collectAppDeps(ctx, a, false, false) - a.certificate, certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx) + a.certificate, certificates = processMainCert(a.ModuleBase, a.properties.Certificate.GetOrDefault(ctx, ""), certificates, ctx) signed := android.PathForModuleOut(ctx, "signed", apkFilename) var lineageFile android.Path if lineage := String(a.properties.Lineage); lineage != "" { diff --git a/java/base.go b/java/base.go index 8dad2d9ad..3bf2e23d8 100644 --- a/java/base.go +++ b/java/base.go @@ -714,10 +714,10 @@ func (j *Module) provideHiddenAPIPropertyInfo(ctx android.ModuleContext) { // helper method for java modules to set OutputFilesProvider func setOutputFiles(ctx android.ModuleContext, m Module) { - ctx.SetOutputFiles(append(android.Paths{m.outputFile}, m.extraOutputFiles...), "") - ctx.SetOutputFiles(android.Paths{m.outputFile}, android.DefaultDistTag) - ctx.SetOutputFiles(android.Paths{m.implementationAndResourcesJar}, ".jar") - ctx.SetOutputFiles(android.Paths{m.headerJarFile}, ".hjar") + ctx.SetOutputFiles(append(android.PathsIfNonNil(m.outputFile), m.extraOutputFiles...), "") + ctx.SetOutputFiles(android.PathsIfNonNil(m.outputFile), android.DefaultDistTag) + ctx.SetOutputFiles(android.PathsIfNonNil(m.implementationAndResourcesJar), ".jar") + ctx.SetOutputFiles(android.PathsIfNonNil(m.headerJarFile), ".hjar") if m.dexer.proguardDictionary.Valid() { ctx.SetOutputFiles(android.Paths{m.dexer.proguardDictionary.Path()}, ".proguard_map") } @@ -766,7 +766,8 @@ func (j *Module) shouldInstrumentInApex(ctx android.BaseModuleContext) bool { apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider) isJacocoAgent := ctx.ModuleName() == "jacocoagent" - if j.DirectlyInAnyApex() && !isJacocoAgent && !apexInfo.IsForPlatform() { + compileDex := Bool(j.dexProperties.Compile_dex) || Bool(j.properties.Installable) + if compileDex && !isJacocoAgent && !apexInfo.IsForPlatform() { if !inList(ctx.ModuleName(), config.InstrumentFrameworkModules) { return true } else if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { @@ -1735,7 +1736,12 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath completeStaticLibsImplementationJarsToCombine := completeStaticLibsImplementationJars - if j.shouldInstrument(ctx) { + apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider) + + // Enable dex compilation for the APEX variants, unless it is disabled explicitly + compileDex := Bool(j.dexProperties.Compile_dex) || Bool(j.properties.Installable) + + if j.shouldInstrument(ctx) && (!ctx.Device() || compileDex) { instrumentedOutputFile := j.instrument(ctx, flags, outputFile, jarName, specs) completeStaticLibsImplementationJarsToCombine = depset.New(depset.PREORDER, android.Paths{instrumentedOutputFile}, nil) outputFile = instrumentedOutputFile @@ -1764,19 +1770,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath j.implementationAndResourcesJar = outputFile - // Enable dex compilation for the APEX variants, unless it is disabled explicitly - compileDex := j.dexProperties.Compile_dex - apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider) - if j.DirectlyInAnyApex() && !apexInfo.IsForPlatform() { - if compileDex == nil { - compileDex = proptools.BoolPtr(true) - } - if j.deviceProperties.Hostdex == nil { - j.deviceProperties.Hostdex = proptools.BoolPtr(true) - } - } - - if ctx.Device() && (Bool(j.properties.Installable) || Bool(compileDex)) { + if ctx.Device() && compileDex { if j.hasCode(ctx) { if j.shouldInstrumentStatic(ctx) { j.dexer.extraProguardFlagsFiles = append(j.dexer.extraProguardFlagsFiles, @@ -2328,7 +2322,10 @@ func (m *Module) getSdkLinkType(ctx android.BaseModuleContext, name string) (ret "stable.core.platform.api.stubs", "stub-annotations", "private-stub-annotations-jar", "core-lambda-stubs", - "core-generated-annotation-stubs": + "core-generated-annotation-stubs", + // jacocoagent only uses core APIs, but has to specify a non-core sdk_version so it can use + // a prebuilt SDK to avoid circular dependencies when it statically included in the bootclasspath. + "jacocoagent": return javaCore, true case android.SdkPublic.DefaultJavaLibraryName(): return javaSdk, true diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index c778f0404..375a1aaf1 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -83,10 +83,6 @@ func (b bootclasspathFragmentContentDependencyTag) ExportMember() bool { return true } -// Contents of bootclasspath fragments in an apex are considered to be directly in the apex, as if -// they were listed in java_libs. -func (b bootclasspathFragmentContentDependencyTag) CopyDirectlyInAnyApex() {} - // Contents of bootclasspath fragments require files from prebuilt apex files. func (b bootclasspathFragmentContentDependencyTag) RequiresFilesFromPrebuiltApex() {} @@ -96,7 +92,6 @@ var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyT var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathFragmentContentDepTag var _ android.ReplaceSourceWithPrebuilt = bootclasspathFragmentContentDepTag var _ android.SdkMemberDependencyTag = bootclasspathFragmentContentDepTag -var _ android.CopyDirectlyInAnyApexTag = bootclasspathFragmentContentDepTag var _ android.RequiresFilesFromPrebuiltApexTag = bootclasspathFragmentContentDepTag func IsBootclasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool { diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index fdccd3a84..88a8fb80a 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -105,6 +105,10 @@ func gatherPossibleApexModuleNamesAndStems(ctx android.ModuleContext, contents [ set := map[string]struct{}{} for _, name := range contents { dep := ctx.GetDirectDepWithTag(name, tag) + if dep == nil && ctx.Config().AllowMissingDependencies() { + // Ignore apex boot jars from dexpreopt if it does not exist, and missing deps are allowed. + continue + } set[ModuleStemForDeapexing(dep)] = struct{}{} if m, ok := dep.(ModuleWithStem); ok { set[m.Stem()] = struct{}{} diff --git a/java/dex.go b/java/dex.go index dea71f538..983377ead 100644 --- a/java/dex.go +++ b/java/dex.go @@ -295,7 +295,7 @@ func (d *dexer) d8Flags(ctx android.ModuleContext, dexParams *compileDexParams) return d8Flags, d8Deps, artProfileOutput } -func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams) (r8Flags []string, r8Deps android.Paths, artProfileOutput *android.OutputPath) { +func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams, debugMode bool) (r8Flags []string, r8Deps android.Paths, artProfileOutput *android.OutputPath) { flags := dexParams.flags opt := d.dexProperties.Optimize @@ -363,7 +363,9 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams) r8Flags = append(r8Flags, "--force-proguard-compatibility") } - if Bool(opt.Optimize) || Bool(opt.Obfuscate) { + // Avoid unnecessary stack frame noise by only injecting source map ids for non-debug + // optimized or obfuscated targets. + if (Bool(opt.Optimize) || Bool(opt.Obfuscate)) && !debugMode { // TODO(b/213833843): Allow configuration of the prefix via a build variable. var sourceFilePrefix = "go/retraceme " var sourceFileTemplate = "\"" + sourceFilePrefix + "%MAP_ID\"" @@ -483,7 +485,8 @@ func (d *dexer) compileDex(ctx android.ModuleContext, dexParams *compileDexParam proguardUsageZip, proguardConfiguration, } - r8Flags, r8Deps, r8ArtProfileOutputPath := d.r8Flags(ctx, dexParams) + debugMode := android.InList("--debug", commonFlags) + r8Flags, r8Deps, r8ArtProfileOutputPath := d.r8Flags(ctx, dexParams, debugMode) rule := r8 args := map[string]string{ "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "), diff --git a/java/droiddoc.go b/java/droiddoc.go index 82713920d..2dda72b0e 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -578,7 +578,6 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { rule.Build("javadoc", "javadoc") - ctx.SetOutputFiles(android.Paths{j.stubsSrcJar}, "") ctx.SetOutputFiles(android.Paths{j.docZip}, ".docs.zip") } diff --git a/java/droidstubs.go b/java/droidstubs.go index cf3e21925..e955949af 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -769,15 +769,6 @@ func addMetalavaConfigFilesToCmd(cmd *android.RuleBuilderCommand, configFiles an // property is defined, apply transformations and only revert the flagged apis that are not // enabled via release configurations and are not specified in aconfig_declarations func generateRevertAnnotationArgs(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, aconfigFlagsPaths android.Paths) { - - if len(aconfigFlagsPaths) == 0 { - cmd.Flag("--revert-annotation android.annotation.FlaggedApi") - return - } - - releasedFlaggedApisFile := android.PathForModuleOut(ctx, fmt.Sprintf("released-flagged-apis-%s.txt", stubsType.String())) - revertAnnotationsFile := android.PathForModuleOut(ctx, fmt.Sprintf("revert-annotations-%s.txt", stubsType.String())) - var filterArgs string switch stubsType { // No flagged apis specific flags need to be passed to metalava when generating @@ -799,6 +790,15 @@ func generateRevertAnnotationArgs(ctx android.ModuleContext, cmd *android.RuleBu } } + if len(aconfigFlagsPaths) == 0 { + // This argument should not be added for "everything" stubs + cmd.Flag("--revert-annotation android.annotation.FlaggedApi") + return + } + + releasedFlaggedApisFile := android.PathForModuleOut(ctx, fmt.Sprintf("released-flagged-apis-%s.txt", stubsType.String())) + revertAnnotationsFile := android.PathForModuleOut(ctx, fmt.Sprintf("revert-annotations-%s.txt", stubsType.String())) + ctx.Build(pctx, android.BuildParams{ Rule: gatherReleasedFlaggedApisRule, Inputs: aconfigFlagsPaths, @@ -1011,7 +1011,7 @@ func (d *Droidstubs) everythingOptionalCmd(ctx android.ModuleContext, cmd *andro cmd.FlagWithOutput("--update-baseline:api-lint ", updatedBaselineOutput) msg += fmt.Sprintf(``+ - `3. FOR LSC ONLY: You can update the baseline by executing\n` + + `3. FOR LSC ONLY: You can update the baseline by executing\n`+ ` the following command:\n`+ ` (cd $ANDROID_BUILD_TOP && cp \\\n`+ ` "%s" \\\n`+ @@ -1374,7 +1374,7 @@ func (d *Droidstubs) setOutputFiles(ctx android.ModuleContext) { for _, stubType := range android.SortedKeys(stubsTypeToPrefix) { tagWithPrefix := stubsTypeToPrefix[stubType] + tag outputFile, err := tagToOutputFileFunc[tag](stubType) - if err == nil { + if err == nil && outputFile != nil { ctx.SetOutputFiles(android.Paths{outputFile}, tagWithPrefix) } } diff --git a/java/java.go b/java/java.go index 64ef782f5..260d33610 100644 --- a/java/java.go +++ b/java/java.go @@ -2311,14 +2311,17 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { case libTag: if provider, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok { classPaths = append(classPaths, provider.HeaderJars...) + al.aconfigProtoFiles = append(al.aconfigProtoFiles, provider.AconfigIntermediateCacheOutputPaths...) } case bootClasspathTag: if provider, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok { bootclassPaths = append(bootclassPaths, provider.HeaderJars...) + al.aconfigProtoFiles = append(al.aconfigProtoFiles, provider.AconfigIntermediateCacheOutputPaths...) } case staticLibTag: if provider, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok { staticLibs = append(staticLibs, provider.HeaderJars...) + al.aconfigProtoFiles = append(al.aconfigProtoFiles, provider.AconfigIntermediateCacheOutputPaths...) } case systemModulesTag: if sm, ok := android.OtherModuleProvider(ctx, dep, SystemModulesProvider); ok { diff --git a/java/java_test.go b/java/java_test.go index 54eb3e14e..d415679bd 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -3050,6 +3050,7 @@ func TestCoverage(t *testing.T) { java_library { name: "android.car", srcs: ["android.car.java"], + installable: true, } `) diff --git a/java/rro.go b/java/rro.go index 8bb9be2eb..f225e1f4e 100644 --- a/java/rro.go +++ b/java/rro.go @@ -50,7 +50,7 @@ type RuntimeResourceOverlay struct { type RuntimeResourceOverlayProperties struct { // the name of a certificate in the default certificate directory or an android_app_certificate // module name in the form ":module". - Certificate *string + Certificate proptools.Configurable[string] `android:"replace_instead_of_append"` // Name of the signing certificate lineage file. Lineage *string @@ -119,7 +119,7 @@ func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext) r.aapt.deps(ctx, sdkDep) } - cert := android.SrcIsModule(String(r.properties.Certificate)) + cert := android.SrcIsModule(r.properties.Certificate.GetOrDefault(ctx, "")) if cert != "" { ctx.AddDependency(ctx.Module(), certificateTag, cert) } @@ -166,7 +166,7 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC // Sign the built package _, _, certificates := collectAppDeps(ctx, r, false, false) - r.certificate, certificates = processMainCert(r.ModuleBase, String(r.properties.Certificate), certificates, ctx) + r.certificate, certificates = processMainCert(r.ModuleBase, r.properties.Certificate.GetOrDefault(ctx, ""), certificates, ctx) signed := android.PathForModuleOut(ctx, "signed", r.Name()+".apk") var lineageFile android.Path if lineage := String(r.properties.Lineage); lineage != "" { diff --git a/java/sdk_library.go b/java/sdk_library.go index f6dfcdd19..78917768b 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1314,12 +1314,6 @@ var implLibraryTag = sdkLibraryComponentTag{name: "impl-library"} var _ android.InstallNeededDependencyTag = sdkLibraryComponentTag{} -// To satisfy the CopyDirectlyInAnyApexTag interface. Implementation library of the sdk library -// in an apex is considered to be directly in the apex, as if it was listed in java_libs. -func (t sdkLibraryComponentTag) CopyDirectlyInAnyApex() {} - -var _ android.CopyDirectlyInAnyApexTag = implLibraryTag - func (t sdkLibraryComponentTag) InstallDepNeeded() bool { return t.name == "xml-permissions-file" || t.name == "impl-library" } diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index 608a61628..3176ad94c 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -218,16 +218,11 @@ func (b systemServerClasspathFragmentContentDependencyTag) ExportMember() bool { return true } -// Contents of system server fragments in an apex are considered to be directly in the apex, as if -// they were listed in java_libs. -func (systemServerClasspathFragmentContentDependencyTag) CopyDirectlyInAnyApex() {} - // Contents of system server fragments require files from prebuilt apex files. func (systemServerClasspathFragmentContentDependencyTag) RequiresFilesFromPrebuiltApex() {} var _ android.ReplaceSourceWithPrebuilt = systemServerClasspathFragmentContentDepTag var _ android.SdkMemberDependencyTag = systemServerClasspathFragmentContentDepTag -var _ android.CopyDirectlyInAnyApexTag = systemServerClasspathFragmentContentDepTag var _ android.RequiresFilesFromPrebuiltApexTag = systemServerClasspathFragmentContentDepTag // The tag used for the dependency between the systemserverclasspath_fragment module and its contents. diff --git a/java/testing.go b/java/testing.go index 988514dea..0ea4e6408 100644 --- a/java/testing.go +++ b/java/testing.go @@ -190,6 +190,7 @@ var PrepareForTestWithJacocoInstrumentation = android.GroupFixturePreparers( "//apex_available:anyapex", "//apex_available:platform", ], + compile_dex: true, } `)), ) @@ -427,7 +428,7 @@ func gatherRequiredDepsForTest() string { "stub-annotations", "aconfig-annotations-lib", - "aconfig_storage_reader_java", + "aconfig_storage_stub", "unsupportedappusage", } |