diff options
author | 2024-03-19 21:57:36 +0000 | |
---|---|---|
committer | 2024-03-20 00:06:05 +0000 | |
commit | 9049c2725a232bab8ee4f181c25cfe5fbdcf7e90 (patch) | |
tree | 0a3f953f034851b7935431fb9faf67b65a281811 /java/aar_test.go | |
parent | f11f786571282209093b9988065fa259fd3b056b (diff) |
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
Diffstat (limited to 'java/aar_test.go')
-rw-r--r-- | java/aar_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/java/aar_test.go b/java/aar_test.go index 4d4e5d025..6bd53f228 100644 --- a/java/aar_test.go +++ b/java/aar_test.go @@ -81,3 +81,50 @@ func TestAarImportProducesJniPackages(t *testing.T) { }) } } + +func TestLibraryFlagsPackages(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForJavaTest, + ).RunTestWithBp(t, ` + android_library { + name: "foo", + srcs: ["a.java"], + sdk_version: "current", + flags_packages: [ + "bar", + "baz", + ], + } + aconfig_declarations { + name: "bar", + package: "com.example.package.bar", + srcs: [ + "bar.aconfig", + ], + } + aconfig_declarations { + name: "baz", + package: "com.example.package.baz", + srcs: [ + "baz.aconfig", + ], + } + `) + + foo := result.ModuleForTests("foo", "android_common") + + // android_library module depends on aconfig_declarations listed in flags_packages + android.AssertBoolEquals(t, "foo expected to depend on bar", true, + CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "bar")) + + android.AssertBoolEquals(t, "foo expected to depend on baz", true, + CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "baz")) + + aapt2LinkRule := foo.Rule("android/soong/java.aapt2Link") + linkInFlags := aapt2LinkRule.Args["inFlags"] + android.AssertStringDoesContain(t, + "aapt2 link command expected to pass feature flags arguments", + linkInFlags, + "--feature-flags @out/soong/.intermediates/bar/intermediate.txt --feature-flags @out/soong/.intermediates/baz/intermediate.txt", + ) +} |