Add aconfig flag support for android_app

This change adds an overrideable property flags_packages to android_app,
which is used to list the aconfig_declarations module names that the app
depends on. The build action of android_app is modified to pass all
flags text file provided by the aconfig_declarations to aapt2 link as
--feature-flags arguments.

Test: m nothing --no-skip-soong-tests
Bug: 306024510
Change-Id: I4924f88b9954950cc1936a472cd7ac70f41add5d
This commit is contained in:
Jihoon Kang
2023-12-01 22:01:06 +00:00
parent cca3e0c4b5
commit 84b2589e6d
6 changed files with 88 additions and 8 deletions

View File

@@ -202,7 +202,8 @@ var mergeAssetsRule = pctx.AndroidStaticRule("mergeAssets",
func aapt2Link(ctx android.ModuleContext,
packageRes, genJar, proguardOptions, rTxt android.WritablePath,
flags []string, deps android.Paths,
compiledRes, compiledOverlay, assetPackages android.Paths, splitPackages android.WritablePaths) {
compiledRes, compiledOverlay, assetPackages android.Paths, splitPackages android.WritablePaths,
featureFlagsPaths android.Paths) {
var inFlags []string
@@ -255,6 +256,11 @@ func aapt2Link(ctx android.ModuleContext,
})
}
for _, featureFlagsPath := range featureFlagsPaths {
deps = append(deps, featureFlagsPath)
inFlags = append(inFlags, "--feature-flags", "@"+featureFlagsPath.String())
}
// Note the absence of splitPackages. The caller is supposed to compose and provide --split flag
// values via the flags parameter when it wants to split outputs.
// TODO(b/174509108): Perhaps we can process it in this func while keeping the code reasonably