diff --git a/android/config.go b/android/config.go index ed90c3181..396b1a66b 100644 --- a/android/config.go +++ b/android/config.go @@ -821,6 +821,12 @@ func (c *config) UnbundledBuildApps() bool { return Bool(c.productVariables.Unbundled_build_apps) } +// Returns true if building image that aren't bundled with the platform. +// UnbundledBuild() is always true when this is true. +func (c *config) UnbundledBuildImage() bool { + return Bool(c.productVariables.Unbundled_build_image) +} + // Returns true if building modules against prebuilt SDKs. func (c *config) AlwaysUsePrebuiltSdks() bool { return Bool(c.productVariables.Always_use_prebuilt_sdks) diff --git a/android/variable.go b/android/variable.go index 75f4b9450..dc16a6f44 100644 --- a/android/variable.go +++ b/android/variable.go @@ -226,6 +226,7 @@ type productVariables struct { Allow_missing_dependencies *bool `json:",omitempty"` Unbundled_build *bool `json:",omitempty"` Unbundled_build_apps *bool `json:",omitempty"` + Unbundled_build_image *bool `json:",omitempty"` Always_use_prebuilt_sdks *bool `json:",omitempty"` Skip_boot_jars_check *bool `json:",omitempty"` Malloc_not_svelte *bool `json:",omitempty"` diff --git a/java/app.go b/java/app.go index fc1ace07b..fc6e183e6 100755 --- a/java/app.go +++ b/java/app.go @@ -1213,7 +1213,7 @@ func (u *usesLibrary) addLib(lib string, optional bool) { } func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs bool) { - if !ctx.Config().UnbundledBuild() { + if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() { ctx.AddVariationDependencies(nil, usesLibTag, u.usesLibraryProperties.Uses_libs...) ctx.AddVariationDependencies(nil, usesLibTag, u.presentOptionalUsesLibs(ctx)...) // Only add these extra dependencies if the module depends on framework libs. This avoids @@ -1249,15 +1249,16 @@ func replaceInList(list []string, oldstr, newstr string) { // to their dex jars on host and on device. func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext) dexpreopt.ClassLoaderContextMap { clcMap := make(dexpreopt.ClassLoaderContextMap) - - if !ctx.Config().UnbundledBuild() { + // Skip when UnbundledBuild() is true, but UnbundledBuildImage() is false. + // Added UnbundledBuildImage() condition to generate dexpreopt.config even though unbundled image is built. + if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() { ctx.VisitDirectDeps(func(m android.Module) { if tag, ok := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag); ok { dep := ctx.OtherModuleName(m) if lib, ok := m.(UsesLibraryDependency); ok { - libName := dep + libName := android.RemoveOptionalPrebuiltPrefix(dep) if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil { - libName = *ulib.ProvidesUsesLib() + libName = android.RemoveOptionalPrebuiltPrefix(*ulib.ProvidesUsesLib()) // Replace module name with library name in `uses_libs`/`optional_uses_libs` // in order to pass verify_uses_libraries check (which compares these // properties against library names written in the manifest). diff --git a/java/dexpreopt.go b/java/dexpreopt.go index 2e46d74fa..0faae36ba 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -141,10 +141,9 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr } } - // If it is neither app nor test, make config files regardless of its dexpreopt setting. + // If it is test, make config files regardless of its dexpreopt setting. // The config files are required for apps defined in make which depend on the lib. - // TODO(b/158843648): The config for apps should be generated as well regardless of setting. - if (d.isApp || d.isTest) && d.dexpreoptDisabled(ctx) { + if d.isTest && d.dexpreoptDisabled(ctx) { return }