Merge "Make native_shared_libs configurable" into main
This commit is contained in:
70
apex/apex.go
70
apex/apex.go
@@ -213,7 +213,7 @@ type apexBundleProperties struct {
|
|||||||
|
|
||||||
type ApexNativeDependencies struct {
|
type ApexNativeDependencies struct {
|
||||||
// List of native libraries that are embedded inside this APEX.
|
// List of native libraries that are embedded inside this APEX.
|
||||||
Native_shared_libs []string
|
Native_shared_libs proptools.Configurable[[]string]
|
||||||
|
|
||||||
// List of JNI libraries that are embedded inside this APEX.
|
// List of JNI libraries that are embedded inside this APEX.
|
||||||
Jni_libs []string
|
Jni_libs []string
|
||||||
@@ -223,7 +223,6 @@ type ApexNativeDependencies struct {
|
|||||||
|
|
||||||
// List of native executables that are embedded inside this APEX.
|
// List of native executables that are embedded inside this APEX.
|
||||||
Binaries proptools.Configurable[[]string]
|
Binaries proptools.Configurable[[]string]
|
||||||
ResolvedBinaries []string `blueprint:"mutated"`
|
|
||||||
|
|
||||||
// List of native tests that are embedded inside this APEX.
|
// List of native tests that are embedded inside this APEX.
|
||||||
Tests []string
|
Tests []string
|
||||||
@@ -233,7 +232,50 @@ type ApexNativeDependencies struct {
|
|||||||
|
|
||||||
// List of prebuilt_etcs that are embedded inside this APEX bundle.
|
// List of prebuilt_etcs that are embedded inside this APEX bundle.
|
||||||
Prebuilts proptools.Configurable[[]string]
|
Prebuilts proptools.Configurable[[]string]
|
||||||
ResolvedPrebuilts []string `blueprint:"mutated"`
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// List of prebuilt_etcs to exclude from this APEX bundle.
|
||||||
|
Exclude_prebuilts []string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResolvedApexNativeDependencies struct {
|
||||||
|
// List of native libraries that are embedded inside this APEX.
|
||||||
|
Native_shared_libs []string
|
||||||
|
|
||||||
|
// List of JNI libraries that are embedded inside this APEX.
|
||||||
|
Jni_libs []string
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
Binaries []string
|
||||||
|
|
||||||
|
// List of native tests that are embedded inside this APEX.
|
||||||
|
Tests []string
|
||||||
|
|
||||||
|
// List of filesystem images that are embedded inside this APEX bundle.
|
||||||
|
Filesystems []string
|
||||||
|
|
||||||
|
// List of prebuilt_etcs that are embedded inside this APEX bundle.
|
||||||
|
Prebuilts []string
|
||||||
|
|
||||||
// List of native libraries to exclude from this APEX.
|
// List of native libraries to exclude from this APEX.
|
||||||
Exclude_native_shared_libs []string
|
Exclude_native_shared_libs []string
|
||||||
@@ -258,14 +300,14 @@ type ApexNativeDependencies struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Merge combines another ApexNativeDependencies into this one
|
// Merge combines another ApexNativeDependencies into this one
|
||||||
func (a *ApexNativeDependencies) Merge(ctx android.BaseMutatorContext, b ApexNativeDependencies) {
|
func (a *ResolvedApexNativeDependencies) Merge(ctx android.BaseMutatorContext, b ApexNativeDependencies) {
|
||||||
a.Native_shared_libs = append(a.Native_shared_libs, b.Native_shared_libs...)
|
a.Native_shared_libs = append(a.Native_shared_libs, b.Native_shared_libs.GetOrDefault(ctx, nil)...)
|
||||||
a.Jni_libs = append(a.Jni_libs, b.Jni_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.Rust_dyn_libs = append(a.Rust_dyn_libs, b.Rust_dyn_libs...)
|
||||||
a.ResolvedBinaries = append(a.ResolvedBinaries, b.Binaries.GetOrDefault(ctx, nil)...)
|
a.Binaries = append(a.Binaries, b.Binaries.GetOrDefault(ctx, nil)...)
|
||||||
a.Tests = append(a.Tests, b.Tests...)
|
a.Tests = append(a.Tests, b.Tests...)
|
||||||
a.Filesystems = append(a.Filesystems, b.Filesystems...)
|
a.Filesystems = append(a.Filesystems, b.Filesystems...)
|
||||||
a.ResolvedPrebuilts = append(a.ResolvedPrebuilts, b.Prebuilts.GetOrDefault(ctx, nil)...)
|
a.Prebuilts = append(a.Prebuilts, b.Prebuilts.GetOrDefault(ctx, nil)...)
|
||||||
|
|
||||||
a.Exclude_native_shared_libs = append(a.Exclude_native_shared_libs, b.Exclude_native_shared_libs...)
|
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_jni_libs = append(a.Exclude_jni_libs, b.Exclude_jni_libs...)
|
||||||
@@ -700,7 +742,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TODO(jiyong): shorten this function signature
|
// TODO(jiyong): shorten this function signature
|
||||||
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeModules ApexNativeDependencies, target android.Target, imageVariation string) {
|
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeModules ResolvedApexNativeDependencies, target android.Target, imageVariation string) {
|
||||||
binVariations := target.Variations()
|
binVariations := target.Variations()
|
||||||
libVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
|
libVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
|
||||||
rustLibVariations := append(
|
rustLibVariations := append(
|
||||||
@@ -718,7 +760,7 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeM
|
|||||||
// this module. This is required since arch variant of an APEX bundle is 'common' but it is
|
// this module. This is required since arch variant of an APEX bundle is 'common' but it is
|
||||||
// 'arm' or 'arm64' for native shared libs.
|
// 'arm' or 'arm64' for native shared libs.
|
||||||
ctx.AddFarVariationDependencies(binVariations, executableTag,
|
ctx.AddFarVariationDependencies(binVariations, executableTag,
|
||||||
android.RemoveListFromList(nativeModules.ResolvedBinaries, nativeModules.Exclude_binaries)...)
|
android.RemoveListFromList(nativeModules.Binaries, nativeModules.Exclude_binaries)...)
|
||||||
ctx.AddFarVariationDependencies(binVariations, testTag,
|
ctx.AddFarVariationDependencies(binVariations, testTag,
|
||||||
android.RemoveListFromList(nativeModules.Tests, nativeModules.Exclude_tests)...)
|
android.RemoveListFromList(nativeModules.Tests, nativeModules.Exclude_tests)...)
|
||||||
ctx.AddFarVariationDependencies(libVariations, jniLibTag,
|
ctx.AddFarVariationDependencies(libVariations, jniLibTag,
|
||||||
@@ -730,7 +772,7 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeM
|
|||||||
ctx.AddFarVariationDependencies(target.Variations(), fsTag,
|
ctx.AddFarVariationDependencies(target.Variations(), fsTag,
|
||||||
android.RemoveListFromList(nativeModules.Filesystems, nativeModules.Exclude_filesystems)...)
|
android.RemoveListFromList(nativeModules.Filesystems, nativeModules.Exclude_filesystems)...)
|
||||||
ctx.AddFarVariationDependencies(target.Variations(), prebuiltTag,
|
ctx.AddFarVariationDependencies(target.Variations(), prebuiltTag,
|
||||||
android.RemoveListFromList(nativeModules.ResolvedPrebuilts, nativeModules.Exclude_prebuilts)...)
|
android.RemoveListFromList(nativeModules.Prebuilts, nativeModules.Exclude_prebuilts)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
|
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
|
||||||
@@ -781,7 +823,7 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, target := range targets {
|
for i, target := range targets {
|
||||||
var deps ApexNativeDependencies
|
var deps ResolvedApexNativeDependencies
|
||||||
|
|
||||||
// Add native modules targeting both ABIs. When multilib.* is omitted for
|
// Add native modules targeting both ABIs. When multilib.* is omitted for
|
||||||
// native_shared_libs/jni_libs/tests, it implies multilib.both
|
// native_shared_libs/jni_libs/tests, it implies multilib.both
|
||||||
@@ -798,7 +840,7 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
if isPrimaryAbi {
|
if isPrimaryAbi {
|
||||||
deps.Merge(ctx, a.properties.Multilib.First)
|
deps.Merge(ctx, a.properties.Multilib.First)
|
||||||
deps.Merge(ctx, ApexNativeDependencies{
|
deps.Merge(ctx, ApexNativeDependencies{
|
||||||
Native_shared_libs: nil,
|
Native_shared_libs: proptools.NewConfigurable[[]string](nil, nil),
|
||||||
Tests: nil,
|
Tests: nil,
|
||||||
Jni_libs: nil,
|
Jni_libs: nil,
|
||||||
Binaries: a.properties.Binaries,
|
Binaries: a.properties.Binaries,
|
||||||
@@ -1035,7 +1077,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
|
|||||||
|
|
||||||
if a.dynamic_common_lib_apex() {
|
if a.dynamic_common_lib_apex() {
|
||||||
android.SetProvider(mctx, DCLAInfoProvider, DCLAInfo{
|
android.SetProvider(mctx, DCLAInfoProvider, DCLAInfo{
|
||||||
ProvidedLibs: a.properties.Native_shared_libs,
|
ProvidedLibs: a.properties.Native_shared_libs.GetOrDefault(mctx, nil),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1492,7 +1534,7 @@ func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext
|
|||||||
imageVariation := a.getImageVariation()
|
imageVariation := a.getImageVariation()
|
||||||
for _, target := range ctx.MultiTargets() {
|
for _, target := range ctx.MultiTargets() {
|
||||||
if target.Arch.ArchType.Multilib == "lib64" {
|
if target.Arch.ArchType.Multilib == "lib64" {
|
||||||
addDependenciesForNativeModules(ctx, ApexNativeDependencies{
|
addDependenciesForNativeModules(ctx, ResolvedApexNativeDependencies{
|
||||||
Native_shared_libs: []string{"libclang_rt.hwasan"},
|
Native_shared_libs: []string{"libclang_rt.hwasan"},
|
||||||
Tests: nil,
|
Tests: nil,
|
||||||
Jni_libs: nil,
|
Jni_libs: nil,
|
||||||
|
Reference in New Issue
Block a user