Propagate flags_packages to static reverse dependencies
flags_packages property was added to supports flagging the manifest
files. The listed names of `aconfig_declarations` modules are passed to
aapt2. However, this is currently scoped to the module level, and is not
propagated to the reverse dependencies. In other words, if the manifest
is flagged with `featureFlag` property, all of the reverse dependency of
the android_app/android_library should specify `flags_packages` property
in the bp module definition, leading to huge toil for the users.
In order to resolve such inconvenience, this change modifies the build
rules of android_app,android_library and runtime_resource_overlay such
that flags_packages of the static dependencies are collected.
Test: Patch ag/27816261 && m Settings --no-skip-soong-tests
Bug: 347289274
Change-Id: I4c3855541dd09cb72293515eb2626eaf4ae8c0df
diff --git a/java/aar.go b/java/aar.go
index 07392f6..3168d9b 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -831,12 +831,13 @@
if a.usesLibrary.shouldDisableDexpreopt {
a.dexpreopter.disableDexpreopt()
}
+ aconfigTextFilePaths := getAconfigFilePaths(ctx)
a.aapt.buildActions(ctx,
aaptBuildActionOptions{
sdkContext: android.SdkContext(a),
classLoaderContexts: a.classLoaderContexts,
enforceDefaultTargetSdkVersion: false,
- aconfigTextFiles: getAconfigFilePaths(ctx),
+ aconfigTextFiles: aconfigTextFilePaths,
usesLibrary: &a.usesLibrary,
},
)
@@ -906,6 +907,10 @@
JniPackages: prebuiltJniPackages,
})
}
+
+ android.SetProvider(ctx, FlagsPackagesProvider, FlagsPackages{
+ AconfigTextFiles: aconfigTextFilePaths,
+ })
}
func (a *AndroidLibrary) IDEInfo(dpInfo *android.IdeInfo) {