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
This commit is contained in:
Colin Cross
2024-01-25 13:39:06 -08:00
parent d9e4b24877
commit 8f1b033cf7
3 changed files with 15 additions and 11 deletions

View File

@@ -1970,6 +1970,10 @@ func (c *config) GetBuildFlag(name string) (string, bool) {
return val, ok return val, ok
} }
func (c *config) UseResourceProcessorByDefault() bool {
return c.productVariables.GetBuildFlagBool("RELEASE_USE_RESOURCE_PROCESSOR_BY_DEFAULT")
}
var ( var (
mainlineApexContributionBuildFlags = []string{ mainlineApexContributionBuildFlags = []string{
"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES",

View File

@@ -159,8 +159,8 @@ func propagateRROEnforcementMutator(ctx android.TopDownMutatorContext) {
} }
} }
func (a *aapt) useResourceProcessorBusyBox() bool { func (a *aapt) useResourceProcessorBusyBox(ctx android.BaseModuleContext) bool {
return BoolDefault(a.aaptProperties.Use_resource_processor, false) return BoolDefault(a.aaptProperties.Use_resource_processor, ctx.Config().UseResourceProcessorByDefault())
} }
func (a *aapt) filterProduct() string { func (a *aapt) filterProduct() string {
@@ -414,7 +414,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio
linkFlags = append(linkFlags, "--static-lib") 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 // 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 // package-res.apk with --merge-only, but --no-static-lib-packages is not used so that R.txt only
// contains resources from this library. // contains resources from this library.
@@ -453,7 +453,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio
// of transitiveStaticLibs. // of transitiveStaticLibs.
transitiveStaticLibs := android.ReversePaths(staticDeps.resPackages()) 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 // 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 // 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 // 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 // the subdir "android" is required to be filtered by package names
srcJar = android.PathForModuleGen(ctx, "android", "R.srcjar") 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) a.assetPackage = android.OptionalPathForPath(assets)
} }
if a.useResourceProcessorBusyBox() { if a.useResourceProcessorBusyBox(ctx) {
rJar := android.PathForModuleOut(ctx, "busybox/R.jar") rJar := android.PathForModuleOut(ctx, "busybox/R.jar")
resourceProcessorBusyBoxGenerateBinaryR(ctx, rTxt, a.mergedManifestFile, rJar, staticDeps, a.isLibrary, a.aaptProperties.Aaptflags) resourceProcessorBusyBoxGenerateBinaryR(ctx, rTxt, a.mergedManifestFile, rJar, staticDeps, a.isLibrary, a.aaptProperties.Aaptflags)
aapt2ExtractExtraPackages(ctx, extraPackages, rJar) aapt2ExtractExtraPackages(ctx, extraPackages, rJar)
@@ -577,7 +577,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio
rJar: a.rJar, rJar: a.rJar,
assets: a.assetPackage, assets: a.assetPackage,
usedResourceProcessor: a.useResourceProcessorBusyBox(), usedResourceProcessor: a.useResourceProcessorBusyBox(ctx),
}). }).
Transitive(staticResourcesNodesDepSet).Build() Transitive(staticResourcesNodesDepSet).Build()
a.rroDirsDepSet = android.NewDepSetBuilder[rroDir](android.TOPOLOGICAL). 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.proguardOptionsFile)
ctx.CheckbuildFile(a.aapt.exportPackage) ctx.CheckbuildFile(a.aapt.exportPackage)
if a.useResourceProcessorBusyBox() { if a.useResourceProcessorBusyBox(ctx) {
ctx.CheckbuildFile(a.aapt.rJar) ctx.CheckbuildFile(a.aapt.rJar)
} else { } else {
ctx.CheckbuildFile(a.aapt.aaptSrcJar) ctx.CheckbuildFile(a.aapt.aaptSrcJar)
@@ -849,7 +849,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
var extraSrcJars android.Paths var extraSrcJars android.Paths
var extraCombinedJars android.Paths var extraCombinedJars android.Paths
var extraClasspathJars android.Paths var extraClasspathJars android.Paths
if a.useResourceProcessorBusyBox() { if a.useResourceProcessorBusyBox(ctx) {
// When building a library with ResourceProcessorBusyBox enabled ResourceProcessorBusyBox for this // When building a library with ResourceProcessorBusyBox enabled ResourceProcessorBusyBox for this
// library and each of the transitive static android_library dependencies has already created an // 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. // 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) { func (a *aapt) IDEInfo(dpInfo *android.IdeInfo) {
if a.useResourceProcessorBusyBox() { if a.rJar != nil {
dpInfo.Jars = append(dpInfo.Jars, a.rJar.String()) dpInfo.Jars = append(dpInfo.Jars, a.rJar.String())
} }
} }

View File

@@ -588,7 +588,7 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) (android.Path, a
var extraSrcJars android.Paths var extraSrcJars android.Paths
var extraClasspathJars android.Paths var extraClasspathJars android.Paths
var extraCombinedJars android.Paths var extraCombinedJars android.Paths
if a.useResourceProcessorBusyBox() { if a.useResourceProcessorBusyBox(ctx) {
// When building an app with ResourceProcessorBusyBox enabled ResourceProcessorBusyBox has already // 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 // 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. // classpath when compiling everything else, and add it to the final classes jar.