diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/app.go | 31 | ||||
-rw-r--r-- | java/app_import.go | 4 | ||||
-rw-r--r-- | java/base.go | 2 | ||||
-rw-r--r-- | java/dexpreopt.go | 2 | ||||
-rw-r--r-- | java/java.go | 2 | ||||
-rw-r--r-- | java/platform_bootclasspath_test.go | 4 | ||||
-rw-r--r-- | java/sdk_library_internal.go | 8 |
7 files changed, 26 insertions, 27 deletions
diff --git a/java/app.go b/java/app.go index dd9967516..69fdc4772 100644 --- a/java/app.go +++ b/java/app.go @@ -30,7 +30,6 @@ import ( "android/soong/android" "android/soong/cc" "android/soong/dexpreopt" - "android/soong/genrule" "android/soong/tradefed" ) @@ -679,7 +678,7 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) (android.Path, a a.dexProperties.Uncompress_dex = proptools.BoolPtr(a.shouldUncompressDex(ctx)) } a.dexpreopter.uncompressedDex = *a.dexProperties.Uncompress_dex - a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries() + a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries(ctx) a.dexpreopter.classLoaderContexts = a.classLoaderContexts a.dexpreopter.manifestFile = a.mergedManifestFile a.dexpreopter.preventInstall = a.appProperties.PreventInstall @@ -908,10 +907,10 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { // Process all building blocks, from AAPT to certificates. a.aaptBuildActions(ctx) // The decision to enforce <uses-library> checks is made before adding implicit SDK libraries. - a.usesLibrary.freezeEnforceUsesLibraries() + a.usesLibrary.freezeEnforceUsesLibraries(ctx) // Check that the <uses-library> list is coherent with the manifest. - if a.usesLibrary.enforceUsesLibraries() { + if a.usesLibrary.enforceUsesLibraries(ctx) { manifestCheckFile := a.usesLibrary.verifyUsesLibrariesManifest( ctx, a.mergedManifestFile, &a.classLoaderContexts) apkDeps = append(apkDeps, manifestCheckFile) @@ -1333,7 +1332,7 @@ func AndroidAppFactory() android.Module { Srcs: []string{":" + a.Name() + "{.apk}"}, Cmd: proptools.StringPtr("$(location characteristics_rro_generator) $$($(location aapt2) dump packagename $(in)) $(out)"), } - ctx.CreateModule(genrule.GenRuleFactory, &rroManifestProperties) + ctx.CreateModule(GenRuleFactory, &rroManifestProperties) rroProperties := struct { Name *string @@ -1687,11 +1686,11 @@ func OverrideAndroidTestModuleFactory() android.Module { type UsesLibraryProperties struct { // A list of shared library modules that will be listed in uses-library tags in the AndroidManifest.xml file. - Uses_libs []string + Uses_libs proptools.Configurable[[]string] // A list of shared library modules that will be listed in uses-library tags in the AndroidManifest.xml file with // required=false. - Optional_uses_libs []string + Optional_uses_libs proptools.Configurable[[]string] // If true, the list of uses_libs and optional_uses_libs modules must match the AndroidManifest.xml file. Defaults // to true if either uses_libs or optional_uses_libs is set. Will unconditionally default to true in the future. @@ -1739,7 +1738,7 @@ type usesLibrary struct { func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, addCompatDeps bool) { if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() { - ctx.AddVariationDependencies(nil, usesLibReqTag, u.usesLibraryProperties.Uses_libs...) + ctx.AddVariationDependencies(nil, usesLibReqTag, u.usesLibraryProperties.Uses_libs.GetOrDefault(ctx, nil)...) presentOptionalUsesLibs := u.presentOptionalUsesLibs(ctx) ctx.AddVariationDependencies(nil, usesLibOptTag, presentOptionalUsesLibs...) // Only add these extra dependencies if the module is an app that depends on framework @@ -1752,17 +1751,17 @@ func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, addCompatDeps boo ctx.AddVariationDependencies(nil, usesLibCompat28OptTag, dexpreopt.OptionalCompatUsesLibs28...) ctx.AddVariationDependencies(nil, usesLibCompat30OptTag, dexpreopt.OptionalCompatUsesLibs30...) } - _, diff, _ := android.ListSetDifference(u.usesLibraryProperties.Optional_uses_libs, presentOptionalUsesLibs) + _, diff, _ := android.ListSetDifference(u.usesLibraryProperties.Optional_uses_libs.GetOrDefault(ctx, nil), presentOptionalUsesLibs) u.usesLibraryProperties.Missing_optional_uses_libs = diff } else { - ctx.AddVariationDependencies(nil, r8LibraryJarTag, u.usesLibraryProperties.Uses_libs...) + ctx.AddVariationDependencies(nil, r8LibraryJarTag, u.usesLibraryProperties.Uses_libs.GetOrDefault(ctx, nil)...) ctx.AddVariationDependencies(nil, r8LibraryJarTag, u.presentOptionalUsesLibs(ctx)...) } } // presentOptionalUsesLibs returns optional_uses_libs after filtering out libraries that don't exist in the source tree. func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []string { - optionalUsesLibs := android.FilterListPred(u.usesLibraryProperties.Optional_uses_libs, func(s string) bool { + optionalUsesLibs := android.FilterListPred(u.usesLibraryProperties.Optional_uses_libs.GetOrDefault(ctx, nil), func(s string) bool { exists := ctx.OtherModuleExists(s) if !exists && !android.InList(ctx.ModuleName(), ctx.Config().BuildWarningBadOptionalUsesLibsAllowlist()) { fmt.Printf("Warning: Module '%s' depends on non-existing optional_uses_libs '%s'\n", ctx.ModuleName(), s) @@ -1828,15 +1827,15 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext // enforceUsesLibraries returns true of <uses-library> tags should be checked against uses_libs and optional_uses_libs // properties. Defaults to true if either of uses_libs or optional_uses_libs is specified. Will default to true // unconditionally in the future. -func (u *usesLibrary) enforceUsesLibraries() bool { - defaultEnforceUsesLibs := len(u.usesLibraryProperties.Uses_libs) > 0 || - len(u.usesLibraryProperties.Optional_uses_libs) > 0 +func (u *usesLibrary) enforceUsesLibraries(ctx android.ModuleContext) bool { + defaultEnforceUsesLibs := len(u.usesLibraryProperties.Uses_libs.GetOrDefault(ctx, nil)) > 0 || + len(u.usesLibraryProperties.Optional_uses_libs.GetOrDefault(ctx, nil)) > 0 return BoolDefault(u.usesLibraryProperties.Enforce_uses_libs, u.enforce || defaultEnforceUsesLibs) } // Freeze the value of `enforce_uses_libs` based on the current values of `uses_libs` and `optional_uses_libs`. -func (u *usesLibrary) freezeEnforceUsesLibraries() { - enforce := u.enforceUsesLibraries() +func (u *usesLibrary) freezeEnforceUsesLibraries(ctx android.ModuleContext) { + enforce := u.enforceUsesLibraries(ctx) u.usesLibraryProperties.Enforce_uses_libs = &enforce } diff --git a/java/app_import.go b/java/app_import.go index f5d9f3e79..6b88f1c43 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -364,13 +364,13 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext a.dexpreopter.isPresignedPrebuilt = Bool(a.properties.Presigned) a.dexpreopter.uncompressedDex = a.shouldUncompressDex(ctx) - a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries() + a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries(ctx) a.dexpreopter.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx) if a.usesLibrary.shouldDisableDexpreopt { a.dexpreopter.disableDexpreopt() } - if a.usesLibrary.enforceUsesLibraries() { + if a.usesLibrary.enforceUsesLibraries(ctx) { a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk, &a.dexpreopter.classLoaderContexts) } diff --git a/java/base.go b/java/base.go index 19f6c5d09..f075dbd21 100644 --- a/java/base.go +++ b/java/base.go @@ -865,7 +865,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { // explicitly listed in the optional_uses_libs property. tag := usesLibReqTag if android.InList(*lib, dexpreopt.OptionalCompatUsesLibs) || - android.InList(*lib, j.usesLibrary.usesLibraryProperties.Optional_uses_libs) { + android.InList(*lib, j.usesLibrary.usesLibraryProperties.Optional_uses_libs.GetOrDefault(ctx, nil)) { tag = usesLibOptTag } ctx.AddVariationDependencies(nil, tag, *lib) diff --git a/java/dexpreopt.go b/java/dexpreopt.go index 637da363c..5928446e3 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -562,7 +562,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa // TODO(b/346662300): Let dexpreopter generate the installPath for dexpreopt files instead of // using the dex location to generate the installPath. if isApexSystemServerJar { - dexpreoptPartition = "system" + dexpreoptPartition = dexpreoptConfig.ApexPartition } for _, install := range dexpreoptRule.Installs() { // Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT. diff --git a/java/java.go b/java/java.go index 288042b42..8b3026269 100644 --- a/java/java.go +++ b/java/java.go @@ -3343,7 +3343,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module, if sdkLib != nil { optional := false if module, ok := ctx.Module().(ModuleWithUsesLibrary); ok { - if android.InList(*sdkLib, module.UsesLibrary().usesLibraryProperties.Optional_uses_libs) { + if android.InList(*sdkLib, module.UsesLibrary().usesLibraryProperties.Optional_uses_libs.GetOrDefault(ctx, nil)) { optional = true } } diff --git a/java/platform_bootclasspath_test.go b/java/platform_bootclasspath_test.go index 7fa6ddb38..0d2acaea0 100644 --- a/java/platform_bootclasspath_test.go +++ b/java/platform_bootclasspath_test.go @@ -298,10 +298,10 @@ func TestPlatformBootclasspath_Dist(t *testing.T) { platformBootclasspath := result.Module("platform-bootclasspath", "android_common").(*platformBootclasspathModule) entries := android.AndroidMkEntriesForTest(t, result.TestContext, platformBootclasspath) goals := entries[0].GetDistForGoals(platformBootclasspath) - android.AssertStringEquals(t, "platform dist goals phony", ".PHONY: droidcore", goals[0]) + android.AssertStringEquals(t, "platform dist goals phony", ".PHONY: droidcore\n", goals[0]) android.AssertStringDoesContain(t, "platform dist goals meta check", goals[1], "$(if $(strip $(ALL_TARGETS.") android.AssertStringDoesContain(t, "platform dist goals meta assign", goals[1], "),,$(eval ALL_TARGETS.") - android.AssertStringEquals(t, "platform dist goals call", "$(call dist-for-goals,droidcore,out/soong/hiddenapi/hiddenapi-flags.csv:hiddenapi-flags.csv)", android.StringRelativeToTop(result.Config, goals[2])) + android.AssertStringEquals(t, "platform dist goals call", "$(call dist-for-goals,droidcore,out/soong/hiddenapi/hiddenapi-flags.csv:hiddenapi-flags.csv)\n", android.StringRelativeToTop(result.Config, goals[2])) } func TestPlatformBootclasspath_HiddenAPIMonolithicFiles(t *testing.T) { diff --git a/java/sdk_library_internal.go b/java/sdk_library_internal.go index ca088cf68..768e57a11 100644 --- a/java/sdk_library_internal.go +++ b/java/sdk_library_internal.go @@ -566,7 +566,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { Min_device_sdk *string Max_device_sdk *string Sdk_library_min_api_level *string - Uses_libs_dependencies []string + Uses_libs_dependencies proptools.Configurable[[]string] }{ Name: proptools.StringPtr(module.xmlPermissionsModuleName()), Enabled: module.EnabledProperty(), @@ -577,7 +577,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, Sdk_library_min_api_level: &moduleMinApiLevelStr, - Uses_libs_dependencies: module.usesLibraryProperties.Uses_libs, + Uses_libs_dependencies: module.usesLibraryProperties.Uses_libs.Clone(), } mctx.CreateModule(sdkLibraryXmlFactory, &props) @@ -742,7 +742,7 @@ type sdkLibraryXmlProperties struct { // Uses-libs dependencies that the shared library requires to work correctly. // // This will add dependency="foo:bar" to the <library> section. - Uses_libs_dependencies []string + Uses_libs_dependencies proptools.Configurable[[]string] } // java_sdk_library_xml builds the permission xml file for a java_sdk_library. @@ -864,7 +864,7 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-before", module.properties.On_bootclasspath_before) minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min-device-sdk", module.properties.Min_device_sdk) maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max-device-sdk", module.properties.Max_device_sdk) - dependenciesAttr := formattedDependenciesAttribute(module.properties.Uses_libs_dependencies) + dependenciesAttr := formattedDependenciesAttribute(module.properties.Uses_libs_dependencies.GetOrDefault(ctx, nil)) // <library> is understood in all android versions whereas <apex-library> is only understood from API T (and ignored before that). // similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the apex-library to make sure this library is not loaded before T var libraryTag string |