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