Merge "Add build flag to enable ResourceProcessorBusyBox by default" into main am: 99ed03f4fe am: 4ccd312ed5

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2929990

Change-Id: Ic45b89c81b5f70eba08fc45f078932458de94a5d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2024-01-26 20:21:33 +00:00
committed by Automerger Merge Worker
3 changed files with 15 additions and 11 deletions

View File

@@ -1973,6 +1973,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",

View File

@@ -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 {
@@ -416,7 +416,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.
@@ -455,7 +455,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
@@ -517,7 +517,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")
}
@@ -544,7 +544,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)
@@ -579,7 +579,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).
@@ -825,7 +825,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)
@@ -851,7 +851,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.
@@ -891,7 +891,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())
}
}

View File

@@ -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.