diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/android_manifest.go | 7 | ||||
| -rw-r--r-- | java/app.go | 29 | ||||
| -rw-r--r-- | java/app_test.go | 1 | ||||
| -rw-r--r-- | java/dex.go | 22 | ||||
| -rw-r--r-- | java/droiddoc.go | 28 | ||||
| -rw-r--r-- | java/droidstubs.go | 16 | ||||
| -rw-r--r-- | java/hiddenapi_modular.go | 3 | ||||
| -rw-r--r-- | java/java.go | 1 | ||||
| -rw-r--r-- | java/platform_bootclasspath.go | 32 | ||||
| -rw-r--r-- | java/platform_compat_config.go | 28 | ||||
| -rw-r--r-- | java/robolectric.go | 7 | ||||
| -rw-r--r-- | java/sdk_library.go | 32 |
12 files changed, 88 insertions, 118 deletions
diff --git a/java/android_manifest.go b/java/android_manifest.go index 859900376..0c77968e6 100644 --- a/java/android_manifest.go +++ b/java/android_manifest.go @@ -71,12 +71,15 @@ func shouldReturnFinalOrFutureInt(ctx android.ModuleContext, targetSdkVersionLev return targetSdkVersionLevel.IsPreview() && (ctx.Config().UnbundledBuildApps() || includedInMts(ctx.Module())) } -// Helper function that casts android.Module to java.androidTestApp -// If this type conversion is possible, it queries whether the test app is included in an MTS suite +// Helper function that returns true if android_test, android_test_helper_app, java_test are in an MTS suite. func includedInMts(module android.Module) bool { if test, ok := module.(androidTestApp); ok { return test.includedInTestSuite("mts") } + // java_test + if test, ok := module.(*Test); ok { + return android.PrefixInList(test.testProperties.Test_suites, "mts") + } return false } diff --git a/java/app.go b/java/app.go index 739ef1a50..f35e4c3d4 100644 --- a/java/app.go +++ b/java/app.go @@ -345,7 +345,35 @@ func (a *AndroidApp) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato } } +// TODO(b/156476221): Remove this allowlist +var ( + missingMinSdkVersionMtsAllowlist = []string{ + "CellBroadcastReceiverGoogleUnitTests", + "CellBroadcastReceiverUnitTests", + "CtsBatterySavingTestCases", + "CtsDeviceAndProfileOwnerApp23", + "CtsDeviceAndProfileOwnerApp30", + "CtsIntentSenderApp", + "CtsJobSchedulerTestCases", + "CtsMimeMapTestCases", + "CtsTareTestCases", + "LibStatsPullTests", + "MediaProviderClientTests", + "TeleServiceTests", + "TestExternalImsServiceApp", + "TestSmsRetrieverApp", + "TetheringPrivilegedTests", + } +) + +func checkMinSdkVersionMts(ctx android.ModuleContext, minSdkVersion android.ApiLevel) { + if includedInMts(ctx.Module()) && !minSdkVersion.Specified() && !android.InList(ctx.ModuleName(), missingMinSdkVersionMtsAllowlist) { + ctx.PropertyErrorf("min_sdk_version", "min_sdk_version is a required property for tests included in MTS") + } +} + func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleContext) { + checkMinSdkVersionMts(ctx, a.MinSdkVersion(ctx)) applicationId := a.appTestHelperAppProperties.Manifest_values.ApplicationId if applicationId != nil { if a.overridableAppProperties.Package_name != nil { @@ -1366,6 +1394,7 @@ func (a *AndroidTestHelperApp) includedInTestSuite(searchPrefix string) bool { } func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { + checkMinSdkVersionMts(ctx, a.MinSdkVersion(ctx)) var configs []tradefed.Config if a.appTestProperties.Instrumentation_target_package != nil { a.additionalAaptFlags = append(a.additionalAaptFlags, diff --git a/java/app_test.go b/java/app_test.go index 1a862fa54..9e2d19ee8 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -4146,6 +4146,7 @@ func TestTargetSdkVersionMtsTests(t *testing.T) { bpTemplate := ` %v { name: "mytest", + min_sdk_version: "34", target_sdk_version: "%v", test_suites: ["othersuite", "%v"], } diff --git a/java/dex.go b/java/dex.go index 32546d985..c75e7749b 100644 --- a/java/dex.go +++ b/java/dex.go @@ -180,7 +180,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", "$r8Template": &remoteexec.REParams{ Labels: map[string]string{"type": "compile", "compiler": "r8"}, Inputs: []string{"$implicits", "${config.R8Jar}"}, - OutputFiles: []string{"${outUsage}", "${outConfig}", "${outDict}", "${resourcesOutput}"}, + OutputFiles: []string{"${outUsage}", "${outConfig}", "${outDict}", "${resourcesOutput}", "${outR8ArtProfile}"}, ExecStrategy: "${config.RER8ExecStrategy}", ToolchainInputs: []string{"${config.JavaCmd}"}, Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, @@ -200,7 +200,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, }, []string{"outDir", "outDict", "outConfig", "outUsage", "outUsageZip", "outUsageDir", - "r8Flags", "zipFlags", "mergeZipsFlags", "resourcesOutput"}, []string{"implicits"}) + "r8Flags", "zipFlags", "mergeZipsFlags", "resourcesOutput", "outR8ArtProfile"}, []string{"implicits"}) func (d *dexer) dexCommonFlags(ctx android.ModuleContext, dexParams *compileDexParams) (flags []string, deps android.Paths) { @@ -463,13 +463,6 @@ func (d *dexer) compileDex(ctx android.ModuleContext, dexParams *compileDexParam proguardConfiguration, } r8Flags, r8Deps, r8ArtProfileOutputPath := d.r8Flags(ctx, dexParams) - if r8ArtProfileOutputPath != nil { - artProfileOutputPath = r8ArtProfileOutputPath - implicitOutputs = append( - implicitOutputs, - artProfileOutputPath, - ) - } rule := r8 args := map[string]string{ "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "), @@ -482,6 +475,17 @@ func (d *dexer) compileDex(ctx android.ModuleContext, dexParams *compileDexParam "outDir": outDir.String(), "mergeZipsFlags": mergeZipsFlags, } + if r8ArtProfileOutputPath != nil { + artProfileOutputPath = r8ArtProfileOutputPath + implicitOutputs = append( + implicitOutputs, + artProfileOutputPath, + ) + // Add the implicit r8 Art profile output to args so that r8RE knows + // about this implicit output + args["outR8ArtProfile"] = artProfileOutputPath.String() + } + if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_R8") { rule = r8RE args["implicits"] = strings.Join(r8Deps.Strings(), ",") diff --git a/java/droiddoc.go b/java/droiddoc.go index 176779eb4..730f23696 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -223,17 +223,6 @@ type Javadoc struct { exportableStubsSrcJar android.WritablePath } -func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) { - switch tag { - case "": - return android.Paths{j.stubsSrcJar}, nil - case ".docs.zip": - return android.Paths{j.docZip}, nil - default: - return nil, fmt.Errorf("unsupported module reference tag %q", tag) - } -} - // javadoc converts .java source files to documentation using javadoc. func JavadocFactory() android.Module { module := &Javadoc{} @@ -254,8 +243,6 @@ func JavadocHostFactory() android.Module { return module } -var _ android.OutputFileProducer = (*Javadoc)(nil) - func (j *Javadoc) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { return android.SdkSpecFrom(ctx, String(j.properties.Sdk_version)) } @@ -585,6 +572,9 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { zipSyncCleanupCmd(rule, srcJarDir) rule.Build("javadoc", "javadoc") + + ctx.SetOutputFiles(android.Paths{j.stubsSrcJar}, "") + ctx.SetOutputFiles(android.Paths{j.docZip}, ".docs.zip") } // Droiddoc @@ -616,15 +606,6 @@ func DroiddocHostFactory() android.Module { return module } -func (d *Droiddoc) OutputFiles(tag string) (android.Paths, error) { - switch tag { - case "", ".docs.zip": - return android.Paths{d.Javadoc.docZip}, nil - default: - return nil, fmt.Errorf("unsupported module reference tag %q", tag) - } -} - func (d *Droiddoc) DepsMutator(ctx android.BottomUpMutatorContext) { d.Javadoc.addDeps(ctx) @@ -876,6 +857,9 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { zipSyncCleanupCmd(rule, srcJarDir) rule.Build("javadoc", desc) + + ctx.SetOutputFiles(android.Paths{d.Javadoc.docZip}, "") + ctx.SetOutputFiles(android.Paths{d.Javadoc.docZip}, ".docs.zip") } // Exported Droiddoc Directory diff --git a/java/droidstubs.go b/java/droidstubs.go index b32b754d3..01571858c 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -1453,17 +1453,6 @@ type PrebuiltStubsSources struct { stubsSrcJar android.Path } -func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) { - switch tag { - // prebuilt droidstubs does not output "exportable" stubs. - // Output the "everything" stubs srcjar file if the tag is ".exportable". - case "", ".exportable": - return android.Paths{p.stubsSrcJar}, nil - default: - return nil, fmt.Errorf("unsupported module reference tag %q", tag) - } -} - func (d *PrebuiltStubsSources) StubsSrcJar(_ StubsType) (android.Path, error) { return d.stubsSrcJar, nil } @@ -1502,6 +1491,11 @@ func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleCon rule.Build("zip src", "Create srcjar from prebuilt source") p.stubsSrcJar = outPath } + + ctx.SetOutputFiles(android.Paths{p.stubsSrcJar}, "") + // prebuilt droidstubs does not output "exportable" stubs. + // Output the "everything" stubs srcjar file if the tag is ".exportable". + ctx.SetOutputFiles(android.Paths{p.stubsSrcJar}, ".exportable") } func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt { diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index cab5402e9..4144de82b 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -1255,8 +1255,9 @@ func buildRuleToGenerateRemovedDexSignatures(ctx android.ModuleContext, suffix s rule := android.NewRuleBuilder(pctx, ctx) rule.Command(). BuiltTool("metalava"). + Text("signature-to-dex"). Inputs(removedTxtFiles). - FlagWithOutput("--dex-api ", output) + FlagWithOutput("--out ", output) rule.Build("modular-hiddenapi-removed-dex-signatures"+suffix, "modular hiddenapi removed dex signatures"+suffix) return android.OptionalPathForPath(output) } diff --git a/java/java.go b/java/java.go index 6fee7ce9a..a2fc5fbd1 100644 --- a/java/java.go +++ b/java/java.go @@ -1510,6 +1510,7 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) { } func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) { + checkMinSdkVersionMts(ctx, j.MinSdkVersion(ctx)) j.generateAndroidBuildActionsWithConfig(ctx, nil) android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{}) } diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index 8d4cf6823..38553a61b 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -15,8 +15,6 @@ package java import ( - "fmt" - "android/soong/android" "android/soong/dexpreopt" ) @@ -57,9 +55,6 @@ type platformBootclasspathModule struct { // Path to the monolithic hiddenapi-unsupported.csv file. hiddenAPIMetadataCSV android.OutputPath - - // Path to a srcjar containing all the transitive sources of the bootclasspath. - srcjar android.OutputPath } type platformBootclasspathProperties struct { @@ -76,8 +71,6 @@ func platformBootclasspathFactory() android.SingletonModule { return m } -var _ android.OutputFileProducer = (*platformBootclasspathModule)(nil) - func (b *platformBootclasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) { entries = append(entries, android.AndroidMkEntries{ Class: "FAKE", @@ -89,22 +82,6 @@ func (b *platformBootclasspathModule) AndroidMkEntries() (entries []android.Andr return } -// Make the hidden API files available from the platform-bootclasspath module. -func (b *platformBootclasspathModule) OutputFiles(tag string) (android.Paths, error) { - switch tag { - case "hiddenapi-flags.csv": - return android.Paths{b.hiddenAPIFlagsCSV}, nil - case "hiddenapi-index.csv": - return android.Paths{b.hiddenAPIIndexCSV}, nil - case "hiddenapi-metadata.csv": - return android.Paths{b.hiddenAPIMetadataCSV}, nil - case ".srcjar": - return android.Paths{b.srcjar}, nil - } - - return nil, fmt.Errorf("unknown tag %s", tag) -} - func (b *platformBootclasspathModule) DepsMutator(ctx android.BottomUpMutatorContext) { // Create a dependency on all_apex_contributions to determine the selected mainline module ctx.AddDependency(ctx.Module(), apexContributionsMetadataDepTag, "all_apex_contributions") @@ -198,8 +175,8 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo } jarArgs := resourcePathsToJarArgs(transitiveSrcFiles) jarArgs = append(jarArgs, "-srcjar") // Move srcfiles to the right package - b.srcjar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-transitive.srcjar").OutputPath - TransformResourcesToJar(ctx, b.srcjar, jarArgs, transitiveSrcFiles) + srcjar := android.PathForModuleOut(ctx, ctx.ModuleName()+"-transitive.srcjar").OutputPath + TransformResourcesToJar(ctx, srcjar, jarArgs, transitiveSrcFiles) // Gather all the fragments dependencies. b.fragments = gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag) @@ -213,6 +190,11 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo bootDexJarByModule := b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments) buildRuleForBootJarsPackageCheck(ctx, bootDexJarByModule) + + ctx.SetOutputFiles(android.Paths{b.hiddenAPIFlagsCSV}, "hiddenapi-flags.csv") + ctx.SetOutputFiles(android.Paths{b.hiddenAPIIndexCSV}, "hiddenapi-index.csv") + ctx.SetOutputFiles(android.Paths{b.hiddenAPIMetadataCSV}, "hiddenapi-metadata.csv") + ctx.SetOutputFiles(android.Paths{srcjar}, ".srcjar") } // Generate classpaths.proto config diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 45b994498..67ed84e1d 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -15,7 +15,6 @@ package java import ( - "fmt" "path/filepath" "android/soong/android" @@ -110,23 +109,13 @@ func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleCon p.installDirPath = android.PathForModuleInstall(ctx, "etc", "compatconfig") p.installConfigFile = android.PathForModuleInstall(ctx, "etc", "compatconfig", p.configFile.Base()) rule.Build(configFileName, "Extract compat/compat_config.xml and install it") -} - -func (p *platformCompatConfig) FilesToInstall() android.InstallPaths { - return android.InstallPaths{p.installConfigFile} + ctx.InstallFile(p.installDirPath, p.configFile.Base(), p.configFile) } func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries { return []android.AndroidMkEntries{android.AndroidMkEntries{ Class: "ETC", OutputFile: android.OptionalPathForPath(p.configFile), - Include: "$(BUILD_PREBUILT)", - ExtraEntries: []android.AndroidMkExtraEntriesFunc{ - func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { - entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.String()) - entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.configFile.Base()) - }, - }, }} } @@ -290,32 +279,23 @@ type globalCompatConfig struct { android.ModuleBase properties globalCompatConfigProperties - - outputFilePath android.OutputPath } func (c *globalCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) { filename := String(c.properties.Filename) inputPath := platformCompatConfigPath(ctx) - c.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath + outputFilePath := android.PathForModuleOut(ctx, filename).OutputPath // This ensures that outputFilePath has the correct name for others to // use, as the source file may have a different name. ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, - Output: c.outputFilePath, + Output: outputFilePath, Input: inputPath, }) -} -func (h *globalCompatConfig) OutputFiles(tag string) (android.Paths, error) { - switch tag { - case "": - return android.Paths{h.outputFilePath}, nil - default: - return nil, fmt.Errorf("unsupported module reference tag %q", tag) - } + ctx.SetOutputFiles(android.Paths{outputFilePath}, "") } // global_compat_config provides access to the merged compat config xml file generated by the build. diff --git a/java/robolectric.go b/java/robolectric.go index 18386c90c..cb22fa0db 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -116,7 +116,7 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { if v := String(r.robolectricProperties.Robolectric_prebuilt_version); v != "" { ctx.AddVariationDependencies(nil, libTag, fmt.Sprintf(robolectricPrebuiltLibPattern, v)) - } else if !proptools.Bool(r.robolectricProperties.Strict_mode) { + } else if !proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { if proptools.Bool(r.robolectricProperties.Upstream) { ctx.AddVariationDependencies(nil, libTag, robolectricCurrentLib+"_upstream") } else { @@ -124,8 +124,11 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { } } - if proptools.Bool(r.robolectricProperties.Strict_mode) { + if proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { ctx.AddVariationDependencies(nil, roboRuntimeOnlyTag, robolectricCurrentLib+"_upstream") + } else { + // opting out from strict mode, robolectric_non_strict_mode_permission lib should be added + ctx.AddVariationDependencies(nil, libTag, "robolectric_non_strict_mode_permission") } ctx.AddVariationDependencies(nil, libTag, robolectricDefaultLibs...) diff --git a/java/sdk_library.go b/java/sdk_library.go index c19b07bb6..e6cb6c49b 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -118,9 +118,6 @@ type apiScope struct { // The tag to use to depend on the stubs source module (if separate from the API module). stubsSourceTag scopeDependencyTag - // The tag to use to depend on the API file generating module (if separate from the stubs source module). - apiFileTag scopeDependencyTag - // The tag to use to depend on the stubs source and API module. stubsSourceAndApiTag scopeDependencyTag @@ -195,11 +192,6 @@ func initApiScope(scope *apiScope) *apiScope { apiScope: scope, depInfoExtractor: (*scopePaths).extractStubsSourceInfoFromDep, } - scope.apiFileTag = scopeDependencyTag{ - name: name + "-api", - apiScope: scope, - depInfoExtractor: (*scopePaths).extractApiInfoFromDep, - } scope.stubsSourceAndApiTag = scopeDependencyTag{ name: name + "-stubs-source-and-api", apiScope: scope, @@ -804,12 +796,6 @@ func (paths *scopePaths) extractApiInfoFromApiStubsProvider(provider ApiStubsPro return combinedError } -func (paths *scopePaths) extractApiInfoFromDep(ctx android.ModuleContext, dep android.Module) error { - return paths.treatDepAsApiStubsProvider(dep, func(provider ApiStubsProvider) error { - return paths.extractApiInfoFromApiStubsProvider(provider, Everything) - }) -} - func (paths *scopePaths) extractStubsSourceInfoFromApiStubsProviders(provider ApiStubsSrcProvider, stubsType StubsType) error { stubsSrcJar, err := provider.StubsSrcJar(stubsType) if err == nil { @@ -819,22 +805,23 @@ func (paths *scopePaths) extractStubsSourceInfoFromApiStubsProviders(provider Ap } func (paths *scopePaths) extractStubsSourceInfoFromDep(ctx android.ModuleContext, dep android.Module) error { + stubsType := Everything + if ctx.Config().ReleaseHiddenApiExportableStubs() { + stubsType = Exportable + } return paths.treatDepAsApiStubsSrcProvider(dep, func(provider ApiStubsSrcProvider) error { - return paths.extractStubsSourceInfoFromApiStubsProviders(provider, Everything) + return paths.extractStubsSourceInfoFromApiStubsProviders(provider, stubsType) }) } func (paths *scopePaths) extractStubsSourceAndApiInfoFromApiStubsProvider(ctx android.ModuleContext, dep android.Module) error { + stubsType := Everything if ctx.Config().ReleaseHiddenApiExportableStubs() { - return paths.treatDepAsApiStubsProvider(dep, func(provider ApiStubsProvider) error { - extractApiInfoErr := paths.extractApiInfoFromApiStubsProvider(provider, Exportable) - extractStubsSourceInfoErr := paths.extractStubsSourceInfoFromApiStubsProviders(provider, Exportable) - return errors.Join(extractApiInfoErr, extractStubsSourceInfoErr) - }) + stubsType = Exportable } return paths.treatDepAsApiStubsProvider(dep, func(provider ApiStubsProvider) error { - extractApiInfoErr := paths.extractApiInfoFromApiStubsProvider(provider, Everything) - extractStubsSourceInfoErr := paths.extractStubsSourceInfoFromApiStubsProviders(provider, Everything) + extractApiInfoErr := paths.extractApiInfoFromApiStubsProvider(provider, stubsType) + extractStubsSourceInfoErr := paths.extractStubsSourceInfoFromApiStubsProviders(provider, stubsType) return errors.Join(extractApiInfoErr, extractStubsSourceInfoErr) }) } @@ -1679,6 +1666,7 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) module.dexer.proguardDictionary = module.implLibraryModule.dexer.proguardDictionary module.dexer.proguardUsageZip = module.implLibraryModule.dexer.proguardUsageZip module.linter.reports = module.implLibraryModule.linter.reports + module.linter.outputs.depSets = module.implLibraryModule.LintDepSets() if !module.Host() { module.hostdexInstallFile = module.implLibraryModule.hostdexInstallFile |