From 9049c2725a232bab8ee4f181c25cfe5fbdcf7e90 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Tue, 19 Mar 2024 21:57:36 +0000 Subject: Add aconfig flag support for android_library This change adds the support that was added to android_app in https://r.android.com/2854663 for android_library modules. Implementation details: - Move `Flags_packages` to aaptProperties, so that it can be utilized for both android_app and android_library. - Wrap `VisitDirectDeps` of aconfig_declarations to a function that takes a ModuleContext as an input, so that it can be utilized in the `GenerateAndroidBuildActions` of both android_app and android_library. Test: m nothing --no-skip-soong-tests Bug: 330222981 Change-Id: I8a755f5ca615c8a1651afcd2ec441fc9fbd82c61 --- java/aar.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'java/aar.go') diff --git a/java/aar.go b/java/aar.go index 27dd38b3f..d29c2fbf4 100644 --- a/java/aar.go +++ b/java/aar.go @@ -104,6 +104,9 @@ type aaptProperties struct { // Filter only specified product and ignore other products Filter_product *string `blueprint:"mutated"` + + // Names of aconfig_declarations modules that specify aconfig flags that the module depends on. + Flags_packages []string } type aapt struct { @@ -804,6 +807,10 @@ func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { a.aapt.deps(ctx, sdkDep) } a.usesLibrary.deps(ctx, false) + + for _, aconfig_declaration := range a.aaptProperties.Flags_packages { + ctx.AddDependency(ctx.Module(), aconfigDeclarationTag, aconfig_declaration) + } } func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -817,6 +824,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) sdkContext: android.SdkContext(a), classLoaderContexts: a.classLoaderContexts, enforceDefaultTargetSdkVersion: false, + aconfigTextFiles: getAconfigFilePaths(ctx), }, ) -- cgit v1.2.3-59-g8ed1b