From 8f1b033cf7e8a2d8f18adbb1f8e58ece82eaac40 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 25 Jan 2024 13:39:06 -0800 Subject: [PATCH] Add build flag to enable ResourceProcessorBusyBox by default Setting the RELEASE_USE_RESOURCE_PROCESSOR_BY_DEFAULT build flag will change the default for use_resource_processor from false to true. Bug: 294256649 Test: builds Change-Id: If643bf8db9e2e039200f63f4aac226ed5b44d9e0 --- android/config.go | 4 ++++ java/aar.go | 20 ++++++++++---------- java/app.go | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/android/config.go b/android/config.go index eb1e647d4..7cb30c57e 100644 --- a/android/config.go +++ b/android/config.go @@ -1970,6 +1970,10 @@ func (c *config) GetBuildFlag(name string) (string, bool) { return val, ok } +func (c *config) UseResourceProcessorByDefault() bool { + return c.productVariables.GetBuildFlagBool("RELEASE_USE_RESOURCE_PROCESSOR_BY_DEFAULT") +} + var ( mainlineApexContributionBuildFlags = []string{ "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", diff --git a/java/aar.go b/java/aar.go index b162ef639..f61fc8374 100644 --- a/java/aar.go +++ b/java/aar.go @@ -159,8 +159,8 @@ func propagateRROEnforcementMutator(ctx android.TopDownMutatorContext) { } } -func (a *aapt) useResourceProcessorBusyBox() bool { - return BoolDefault(a.aaptProperties.Use_resource_processor, false) +func (a *aapt) useResourceProcessorBusyBox(ctx android.BaseModuleContext) bool { + return BoolDefault(a.aaptProperties.Use_resource_processor, ctx.Config().UseResourceProcessorByDefault()) } func (a *aapt) filterProduct() string { @@ -414,7 +414,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio linkFlags = append(linkFlags, "--static-lib") } - if a.isLibrary && a.useResourceProcessorBusyBox() { + if a.isLibrary && a.useResourceProcessorBusyBox(ctx) { // When building an android_library using ResourceProcessorBusyBox the resources are merged into // package-res.apk with --merge-only, but --no-static-lib-packages is not used so that R.txt only // contains resources from this library. @@ -453,7 +453,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio // of transitiveStaticLibs. transitiveStaticLibs := android.ReversePaths(staticDeps.resPackages()) - if a.isLibrary && a.useResourceProcessorBusyBox() { + if a.isLibrary && a.useResourceProcessorBusyBox(ctx) { // When building an android_library with ResourceProcessorBusyBox enabled treat static library dependencies // as imports. The resources from dependencies will not be merged into this module's package-res.apk, and // instead modules depending on this module will reference package-res.apk from all transitive static @@ -515,7 +515,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio }) } - if !a.useResourceProcessorBusyBox() { + if !a.useResourceProcessorBusyBox(ctx) { // the subdir "android" is required to be filtered by package names srcJar = android.PathForModuleGen(ctx, "android", "R.srcjar") } @@ -542,7 +542,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio a.assetPackage = android.OptionalPathForPath(assets) } - if a.useResourceProcessorBusyBox() { + if a.useResourceProcessorBusyBox(ctx) { rJar := android.PathForModuleOut(ctx, "busybox/R.jar") resourceProcessorBusyBoxGenerateBinaryR(ctx, rTxt, a.mergedManifestFile, rJar, staticDeps, a.isLibrary, a.aaptProperties.Aaptflags) aapt2ExtractExtraPackages(ctx, extraPackages, rJar) @@ -577,7 +577,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio rJar: a.rJar, assets: a.assetPackage, - usedResourceProcessor: a.useResourceProcessorBusyBox(), + usedResourceProcessor: a.useResourceProcessorBusyBox(ctx), }). Transitive(staticResourcesNodesDepSet).Build() a.rroDirsDepSet = android.NewDepSetBuilder[rroDir](android.TOPOLOGICAL). @@ -823,7 +823,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) ctx.CheckbuildFile(a.aapt.proguardOptionsFile) ctx.CheckbuildFile(a.aapt.exportPackage) - if a.useResourceProcessorBusyBox() { + if a.useResourceProcessorBusyBox(ctx) { ctx.CheckbuildFile(a.aapt.rJar) } else { ctx.CheckbuildFile(a.aapt.aaptSrcJar) @@ -849,7 +849,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) var extraSrcJars android.Paths var extraCombinedJars android.Paths var extraClasspathJars android.Paths - if a.useResourceProcessorBusyBox() { + if a.useResourceProcessorBusyBox(ctx) { // When building a library with ResourceProcessorBusyBox enabled ResourceProcessorBusyBox for this // library and each of the transitive static android_library dependencies has already created an // R.class file for the appropriate package. Add all of those R.class files to the classpath. @@ -889,7 +889,7 @@ func (a *AndroidLibrary) IDEInfo(dpInfo *android.IdeInfo) { } func (a *aapt) IDEInfo(dpInfo *android.IdeInfo) { - if a.useResourceProcessorBusyBox() { + if a.rJar != nil { dpInfo.Jars = append(dpInfo.Jars, a.rJar.String()) } } diff --git a/java/app.go b/java/app.go index cb05807b8..894a301bb 100755 --- a/java/app.go +++ b/java/app.go @@ -588,7 +588,7 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) (android.Path, a var extraSrcJars android.Paths var extraClasspathJars android.Paths var extraCombinedJars android.Paths - if a.useResourceProcessorBusyBox() { + if a.useResourceProcessorBusyBox(ctx) { // When building an app with ResourceProcessorBusyBox enabled ResourceProcessorBusyBox has already // created R.class files that provide IDs for resources in busybox/R.jar. Pass that file in the // classpath when compiling everything else, and add it to the final classes jar.