From 405f2d449957364873dd9abaa3e5461b2524dc83 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 22 Oct 2024 18:31:25 +0000 Subject: Use shared variant of dep for packaging For native modules that have both static and shared variants (e.g. cc_library), the deps mutator of android_filesystem would always create a dep to the static variant. This is likely due to the fact that `AddFarVariationDependencies` creates a dependency on the first variant of the dep which matches the requested variations. `static` appears before `shared` in linkMutator, and therefore android_filesystem would always create a dep to the static variant. This CL uses `OtherModuleFarDependencyVariantExists` to create a dep to the shared variant. If a cc_library is listed in `PRODUCT_PACKAGES`, it always means the shared variant. Test: go test./filesystem Test: diff in kati install files of vendor/ before and after this CL https://diff.googleplex.com/#key=qrY73chVkwff Change-Id: Iea9d6fde199ef95d43da2c041e2f84e5a7951285 --- filesystem/filesystem_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'filesystem/filesystem_test.go') diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go index 15c4898ea..ab63550ca 100644 --- a/filesystem/filesystem_test.go +++ b/filesystem/filesystem_test.go @@ -610,3 +610,22 @@ func TestDoNotPackageCrossPartitionDependencies(t *testing.T) { fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) android.AssertDeepEquals(t, "filesystem with dependencies on different partition", "bin/binfoo\n", fileList) } + +// If a cc_library is listed in `deps`, and it has a shared and static variant, then the shared variant +// should be installed. +func TestUseSharedVariationOfNativeLib(t *testing.T) { + result := fixture.RunTestWithBp(t, ` + android_filesystem { + name: "myfilesystem", + deps: ["libfoo"], + } + // cc_library will create a static and shared variant. + cc_library { + name: "libfoo", + } + `) + + partition := result.ModuleForTests("myfilesystem", "android_common") + fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) + android.AssertDeepEquals(t, "cc_library listed in deps", "lib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo.so\nlib64/libm.so\n", fileList) +} -- cgit v1.2.3-59-g8ed1b