diff --git a/apex/apex.go b/apex/apex.go index 96a6dca50..76fa60b6d 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1155,7 +1155,7 @@ func setUseVendorWhitelistForTest(config android.Config, whitelist []string) { }) } -type apexNativeDependencies struct { +type ApexNativeDependencies struct { // List of native libraries Native_shared_libs []string @@ -1168,19 +1168,19 @@ type apexNativeDependencies struct { type apexMultilibProperties struct { // Native dependencies whose compile_multilib is "first" - First apexNativeDependencies + First ApexNativeDependencies // Native dependencies whose compile_multilib is "both" - Both apexNativeDependencies + Both ApexNativeDependencies // Native dependencies whose compile_multilib is "prefer32" - Prefer32 apexNativeDependencies + Prefer32 ApexNativeDependencies // Native dependencies whose compile_multilib is "32" - Lib32 apexNativeDependencies + Lib32 ApexNativeDependencies // Native dependencies whose compile_multilib is "64" - Lib64 apexNativeDependencies + Lib64 ApexNativeDependencies } type apexBundleProperties struct { @@ -1202,11 +1202,7 @@ type apexBundleProperties struct { // Default: /system/sepolicy/apex/_file_contexts. File_contexts *string `android:"path"` - // List of native shared libs that are embedded inside this APEX bundle - Native_shared_libs []string - - // List of executables that are embedded inside this APEX bundle - Binaries []string + ApexNativeDependencies // List of java libraries that are embedded inside this APEX bundle Java_libs []string @@ -1214,9 +1210,6 @@ type apexBundleProperties struct { // List of prebuilt files that are embedded inside this APEX bundle Prebuilts []string - // List of tests that are embedded inside this APEX bundle - Tests []string - // Name of the apex_key module that provides the private key to sign APEX Key *string @@ -1531,7 +1524,7 @@ type apexBundle struct { } func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, - native_shared_libs []string, binaries []string, tests []string, + nativeModules ApexNativeDependencies, target android.Target, imageVariation string) { // Use *FarVariation* to be able to depend on modules having // conflicting variations with this module. This is required since @@ -1541,16 +1534,16 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, {Mutator: "image", Variation: imageVariation}, {Mutator: "link", Variation: "shared"}, {Mutator: "version", Variation: ""}, // "" is the non-stub variant - }...), sharedLibTag, native_shared_libs...) + }...), sharedLibTag, nativeModules.Native_shared_libs...) ctx.AddFarVariationDependencies(append(target.Variations(), blueprint.Variation{Mutator: "image", Variation: imageVariation}), - executableTag, binaries...) + executableTag, nativeModules.Binaries...) ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ {Mutator: "image", Variation: imageVariation}, {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant - }...), testTag, tests...) + }...), testTag, nativeModules.Tests...) } func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { @@ -1583,41 +1576,37 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { } } for i, target := range targets { - // When multilib.* is omitted for native_shared_libs, it implies - // multilib.both. - ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ - {Mutator: "image", Variation: a.getImageVariation(config)}, - {Mutator: "link", Variation: "shared"}, - }...), sharedLibTag, a.properties.Native_shared_libs...) - - // When multilib.* is omitted for tests, it implies - // multilib.both. - ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ - {Mutator: "image", Variation: a.getImageVariation(config)}, - {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant - }...), testTag, a.properties.Tests...) + // When multilib.* is omitted for native_shared_libs/tests, it implies + // multilib.both + addDependenciesForNativeModules(ctx, + ApexNativeDependencies{ + Native_shared_libs: a.properties.Native_shared_libs, + Tests: a.properties.Tests, + Binaries: nil, + }, + target, a.getImageVariation(config)) // Add native modules targetting both ABIs addDependenciesForNativeModules(ctx, - a.properties.Multilib.Both.Native_shared_libs, - a.properties.Multilib.Both.Binaries, - a.properties.Multilib.Both.Tests, + a.properties.Multilib.Both, target, a.getImageVariation(config)) isPrimaryAbi := i == 0 if isPrimaryAbi { // When multilib.* is omitted for binaries, it implies - // multilib.first. - ctx.AddFarVariationDependencies(append(target.Variations(), - blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}), - executableTag, a.properties.Binaries...) + // multilib.first + addDependenciesForNativeModules(ctx, + ApexNativeDependencies{ + Native_shared_libs: nil, + Tests: nil, + Binaries: a.properties.Binaries, + }, + target, a.getImageVariation(config)) // Add native modules targetting the first ABI addDependenciesForNativeModules(ctx, - a.properties.Multilib.First.Native_shared_libs, - a.properties.Multilib.First.Binaries, - a.properties.Multilib.First.Tests, + a.properties.Multilib.First, target, a.getImageVariation(config)) } @@ -1626,32 +1615,24 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { case "lib32": // Add native modules targetting 32-bit ABI addDependenciesForNativeModules(ctx, - a.properties.Multilib.Lib32.Native_shared_libs, - a.properties.Multilib.Lib32.Binaries, - a.properties.Multilib.Lib32.Tests, + a.properties.Multilib.Lib32, target, a.getImageVariation(config)) addDependenciesForNativeModules(ctx, - a.properties.Multilib.Prefer32.Native_shared_libs, - a.properties.Multilib.Prefer32.Binaries, - a.properties.Multilib.Prefer32.Tests, + a.properties.Multilib.Prefer32, target, a.getImageVariation(config)) case "lib64": // Add native modules targetting 64-bit ABI addDependenciesForNativeModules(ctx, - a.properties.Multilib.Lib64.Native_shared_libs, - a.properties.Multilib.Lib64.Binaries, - a.properties.Multilib.Lib64.Tests, + a.properties.Multilib.Lib64, target, a.getImageVariation(config)) if !has32BitTarget { addDependenciesForNativeModules(ctx, - a.properties.Multilib.Prefer32.Native_shared_libs, - a.properties.Multilib.Prefer32.Binaries, - a.properties.Multilib.Prefer32.Tests, + a.properties.Multilib.Prefer32, target, a.getImageVariation(config)) } @@ -1660,8 +1641,8 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { for _, sanitizer := range ctx.Config().SanitizeDevice() { if sanitizer == "hwaddress" { addDependenciesForNativeModules(ctx, - []string{"libclang_rt.hwasan-aarch64-android"}, - nil, nil, target, a.getImageVariation(config)) + ApexNativeDependencies{[]string{"libclang_rt.hwasan-aarch64-android"}, nil, nil}, + target, a.getImageVariation(config)) break } } diff --git a/apex/apex_test.go b/apex/apex_test.go index 10fc8d6aa..d1d8d6491 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -1532,13 +1532,17 @@ func ensureExactContents(t *testing.T, ctx *android.TestContext, moduleName, var var surplus []string filesMatched := make(map[string]bool) for _, file := range getFiles(t, ctx, moduleName, variant) { + mactchFound := false for _, expected := range files { if matched, _ := path.Match(expected, file.path); matched { filesMatched[expected] = true - return + mactchFound = true + break } } - surplus = append(surplus, file.path) + if !mactchFound { + surplus = append(surplus, file.path) + } } if len(surplus) > 0 { @@ -1605,8 +1609,10 @@ func TestVndkApexCurrent(t *testing.T) { ensureExactContents(t, ctx, "myapex", "android_common_image", []string{ "lib/libvndk.so", "lib/libvndksp.so", + "lib/libc++.so", "lib64/libvndk.so", "lib64/libvndksp.so", + "lib64/libc++.so", "etc/llndk.libraries.VER.txt", "etc/vndkcore.libraries.VER.txt", "etc/vndksp.libraries.VER.txt", @@ -1666,6 +1672,8 @@ func TestVndkApexWithPrebuilt(t *testing.T) { "lib/libvndk.so", "lib/libvndk.arm.so", "lib64/libvndk.so", + "lib/libc++.so", + "lib64/libc++.so", "etc/*", }) } @@ -1877,6 +1885,8 @@ func TestVndkApexSkipsNativeBridgeSupportedModules(t *testing.T) { ensureExactContents(t, ctx, "myapex", "android_common_image", []string{ "lib/libvndk.so", "lib64/libvndk.so", + "lib/libc++.so", + "lib64/libc++.so", "etc/*", }) }