Merge "Add exclude_* properties to apex arch-specific properties"
This commit is contained in:
87
apex/apex.go
87
apex/apex.go
@@ -225,7 +225,7 @@ type ApexNativeDependencies struct {
|
||||
// List of JNI libraries that are embedded inside this APEX.
|
||||
Jni_libs []string
|
||||
|
||||
// List of rust dyn libraries
|
||||
// List of rust dyn libraries that are embedded inside this APEX.
|
||||
Rust_dyn_libs []string
|
||||
|
||||
// List of native executables that are embedded inside this APEX.
|
||||
@@ -236,6 +236,41 @@ type ApexNativeDependencies struct {
|
||||
|
||||
// List of filesystem images that are embedded inside this APEX bundle.
|
||||
Filesystems []string
|
||||
|
||||
// List of native libraries to exclude from this APEX.
|
||||
Exclude_native_shared_libs []string
|
||||
|
||||
// List of JNI libraries to exclude from this APEX.
|
||||
Exclude_jni_libs []string
|
||||
|
||||
// List of rust dyn libraries to exclude from this APEX.
|
||||
Exclude_rust_dyn_libs []string
|
||||
|
||||
// List of native executables to exclude from this APEX.
|
||||
Exclude_binaries []string
|
||||
|
||||
// List of native tests to exclude from this APEX.
|
||||
Exclude_tests []string
|
||||
|
||||
// List of filesystem images to exclude from this APEX bundle.
|
||||
Exclude_filesystems []string
|
||||
}
|
||||
|
||||
// Merge combines another ApexNativeDependencies into this one
|
||||
func (a *ApexNativeDependencies) Merge(b ApexNativeDependencies) {
|
||||
a.Native_shared_libs = append(a.Native_shared_libs, b.Native_shared_libs...)
|
||||
a.Jni_libs = append(a.Jni_libs, b.Jni_libs...)
|
||||
a.Rust_dyn_libs = append(a.Rust_dyn_libs, b.Rust_dyn_libs...)
|
||||
a.Binaries = append(a.Binaries, b.Binaries...)
|
||||
a.Tests = append(a.Tests, b.Tests...)
|
||||
a.Filesystems = append(a.Filesystems, b.Filesystems...)
|
||||
|
||||
a.Exclude_native_shared_libs = append(a.Exclude_native_shared_libs, b.Exclude_native_shared_libs...)
|
||||
a.Exclude_jni_libs = append(a.Exclude_jni_libs, b.Exclude_jni_libs...)
|
||||
a.Exclude_rust_dyn_libs = append(a.Exclude_rust_dyn_libs, b.Exclude_rust_dyn_libs...)
|
||||
a.Exclude_binaries = append(a.Exclude_binaries, b.Exclude_binaries...)
|
||||
a.Exclude_tests = append(a.Exclude_tests, b.Exclude_tests...)
|
||||
a.Exclude_filesystems = append(a.Exclude_filesystems, b.Exclude_filesystems...)
|
||||
}
|
||||
|
||||
type apexMultilibProperties struct {
|
||||
@@ -675,12 +710,18 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeM
|
||||
// Use *FarVariation* to be able to depend on modules having conflicting variations with
|
||||
// this module. This is required since arch variant of an APEX bundle is 'common' but it is
|
||||
// 'arm' or 'arm64' for native shared libs.
|
||||
ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...)
|
||||
ctx.AddFarVariationDependencies(binVariations, testTag, nativeModules.Tests...)
|
||||
ctx.AddFarVariationDependencies(libVariations, jniLibTag, nativeModules.Jni_libs...)
|
||||
ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...)
|
||||
ctx.AddFarVariationDependencies(rustLibVariations, sharedLibTag, nativeModules.Rust_dyn_libs...)
|
||||
ctx.AddFarVariationDependencies(target.Variations(), fsTag, nativeModules.Filesystems...)
|
||||
ctx.AddFarVariationDependencies(binVariations, executableTag,
|
||||
android.RemoveListFromList(nativeModules.Binaries, nativeModules.Exclude_binaries)...)
|
||||
ctx.AddFarVariationDependencies(binVariations, testTag,
|
||||
android.RemoveListFromList(nativeModules.Tests, nativeModules.Exclude_tests)...)
|
||||
ctx.AddFarVariationDependencies(libVariations, jniLibTag,
|
||||
android.RemoveListFromList(nativeModules.Jni_libs, nativeModules.Exclude_jni_libs)...)
|
||||
ctx.AddFarVariationDependencies(libVariations, sharedLibTag,
|
||||
android.RemoveListFromList(nativeModules.Native_shared_libs, nativeModules.Exclude_native_shared_libs)...)
|
||||
ctx.AddFarVariationDependencies(rustLibVariations, sharedLibTag,
|
||||
android.RemoveListFromList(nativeModules.Rust_dyn_libs, nativeModules.Exclude_rust_dyn_libs)...)
|
||||
ctx.AddFarVariationDependencies(target.Variations(), fsTag,
|
||||
android.RemoveListFromList(nativeModules.Filesystems, nativeModules.Exclude_filesystems)...)
|
||||
}
|
||||
|
||||
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
|
||||
@@ -748,12 +789,12 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
continue
|
||||
}
|
||||
|
||||
var depsList []ApexNativeDependencies
|
||||
var deps ApexNativeDependencies
|
||||
|
||||
// Add native modules targeting both ABIs. When multilib.* is omitted for
|
||||
// native_shared_libs/jni_libs/tests, it implies multilib.both
|
||||
depsList = append(depsList, a.properties.Multilib.Both)
|
||||
depsList = append(depsList, ApexNativeDependencies{
|
||||
deps.Merge(a.properties.Multilib.Both)
|
||||
deps.Merge(ApexNativeDependencies{
|
||||
Native_shared_libs: a.properties.Native_shared_libs,
|
||||
Tests: a.properties.Tests,
|
||||
Jni_libs: a.properties.Jni_libs,
|
||||
@@ -764,8 +805,8 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
// binaries, it implies multilib.first
|
||||
isPrimaryAbi := i == 0
|
||||
if isPrimaryAbi {
|
||||
depsList = append(depsList, a.properties.Multilib.First)
|
||||
depsList = append(depsList, ApexNativeDependencies{
|
||||
deps.Merge(a.properties.Multilib.First)
|
||||
deps.Merge(ApexNativeDependencies{
|
||||
Native_shared_libs: nil,
|
||||
Tests: nil,
|
||||
Jni_libs: nil,
|
||||
@@ -776,34 +817,32 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
// Add native modules targeting either 32-bit or 64-bit ABI
|
||||
switch target.Arch.ArchType.Multilib {
|
||||
case "lib32":
|
||||
depsList = append(depsList, a.properties.Multilib.Lib32)
|
||||
depsList = append(depsList, a.properties.Multilib.Prefer32)
|
||||
deps.Merge(a.properties.Multilib.Lib32)
|
||||
deps.Merge(a.properties.Multilib.Prefer32)
|
||||
case "lib64":
|
||||
depsList = append(depsList, a.properties.Multilib.Lib64)
|
||||
deps.Merge(a.properties.Multilib.Lib64)
|
||||
if !has32BitTarget {
|
||||
depsList = append(depsList, a.properties.Multilib.Prefer32)
|
||||
deps.Merge(a.properties.Multilib.Prefer32)
|
||||
}
|
||||
}
|
||||
|
||||
// Add native modules targeting a specific arch variant
|
||||
switch target.Arch.ArchType {
|
||||
case android.Arm:
|
||||
depsList = append(depsList, a.archProperties.Arch.Arm.ApexNativeDependencies)
|
||||
deps.Merge(a.archProperties.Arch.Arm.ApexNativeDependencies)
|
||||
case android.Arm64:
|
||||
depsList = append(depsList, a.archProperties.Arch.Arm64.ApexNativeDependencies)
|
||||
deps.Merge(a.archProperties.Arch.Arm64.ApexNativeDependencies)
|
||||
case android.Riscv64:
|
||||
depsList = append(depsList, a.archProperties.Arch.Riscv64.ApexNativeDependencies)
|
||||
deps.Merge(a.archProperties.Arch.Riscv64.ApexNativeDependencies)
|
||||
case android.X86:
|
||||
depsList = append(depsList, a.archProperties.Arch.X86.ApexNativeDependencies)
|
||||
deps.Merge(a.archProperties.Arch.X86.ApexNativeDependencies)
|
||||
case android.X86_64:
|
||||
depsList = append(depsList, a.archProperties.Arch.X86_64.ApexNativeDependencies)
|
||||
deps.Merge(a.archProperties.Arch.X86_64.ApexNativeDependencies)
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported arch %v\n", ctx.Arch().ArchType))
|
||||
}
|
||||
|
||||
for _, d := range depsList {
|
||||
addDependenciesForNativeModules(ctx, d, target, imageVariation)
|
||||
}
|
||||
addDependenciesForNativeModules(ctx, deps, target, imageVariation)
|
||||
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "os", Variation: target.OsVariation()},
|
||||
{Mutator: "arch", Variation: target.ArchVariation()},
|
||||
|
@@ -4399,12 +4399,15 @@ func TestApexWithArch(t *testing.T) {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
updatable: false,
|
||||
native_shared_libs: ["mylib.generic"],
|
||||
arch: {
|
||||
arm64: {
|
||||
native_shared_libs: ["mylib.arm64"],
|
||||
exclude_native_shared_libs: ["mylib.generic"],
|
||||
},
|
||||
x86_64: {
|
||||
native_shared_libs: ["mylib.x64"],
|
||||
exclude_native_shared_libs: ["mylib.generic"],
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -4415,6 +4418,18 @@ func TestApexWithArch(t *testing.T) {
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "mylib.generic",
|
||||
srcs: ["mylib.cpp"],
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
// TODO: remove //apex_available:platform
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"myapex",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "mylib.arm64",
|
||||
srcs: ["mylib.cpp"],
|
||||
@@ -4445,6 +4460,7 @@ func TestApexWithArch(t *testing.T) {
|
||||
|
||||
// Ensure that apex variant is created for the direct dep
|
||||
ensureListContains(t, ctx.ModuleVariantsForTests("mylib.arm64"), "android_arm64_armv8-a_shared_apex10000")
|
||||
ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib.generic"), "android_arm64_armv8-a_shared_apex10000")
|
||||
ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib.x64"), "android_arm64_armv8-a_shared_apex10000")
|
||||
|
||||
// Ensure that both direct and indirect deps are copied into apex
|
||||
|
Reference in New Issue
Block a user