Add "jni_libs" property to apex module
Which is the list of JNI libraries that are embeded inside the apex. jni_libs is handled just like native_shared_libs except that it is stored in apex_manifest. When linkerconfig finds an apex with JNI libs, it exposes the namespace for the apex as visible so that libnativeloader can link the namespace to the corresponding classloader-namespace. Bug: 149363889 Test: m nothing(runs soong test) Change-Id: I52ebe38b44545e6e8853e34a3404a235c858112a
This commit is contained in:
31
apex/apex.go
31
apex/apex.go
@@ -52,6 +52,7 @@ type dependencyTag struct {
|
||||
|
||||
var (
|
||||
sharedLibTag = dependencyTag{name: "sharedLib", payload: true}
|
||||
jniLibTag = dependencyTag{name: "jniLib", payload: true}
|
||||
executableTag = dependencyTag{name: "executable", payload: true}
|
||||
javaLibTag = dependencyTag{name: "javaLib", payload: true}
|
||||
prebuiltTag = dependencyTag{name: "prebuilt", payload: true}
|
||||
@@ -1159,6 +1160,9 @@ type ApexNativeDependencies struct {
|
||||
// List of native libraries
|
||||
Native_shared_libs []string
|
||||
|
||||
// List of JNI libraries
|
||||
Jni_libs []string
|
||||
|
||||
// List of native executables
|
||||
Binaries []string
|
||||
|
||||
@@ -1406,6 +1410,8 @@ type apexFile struct {
|
||||
|
||||
jacocoReportClassesFile android.Path // only for javalibs and apps
|
||||
certificate java.Certificate // only for apps
|
||||
|
||||
isJniLib bool
|
||||
}
|
||||
|
||||
func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
|
||||
@@ -1536,6 +1542,12 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
|
||||
{Mutator: "version", Variation: ""}, // "" is the non-stub variant
|
||||
}...), sharedLibTag, nativeModules.Native_shared_libs...)
|
||||
|
||||
ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
|
||||
{Mutator: "image", Variation: imageVariation},
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
{Mutator: "version", Variation: ""}, // "" is the non-stub variant
|
||||
}...), jniLibTag, nativeModules.Jni_libs...)
|
||||
|
||||
ctx.AddFarVariationDependencies(append(target.Variations(),
|
||||
blueprint.Variation{Mutator: "image", Variation: imageVariation}),
|
||||
executableTag, nativeModules.Binaries...)
|
||||
@@ -1576,12 +1588,13 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
}
|
||||
for i, target := range targets {
|
||||
// When multilib.* is omitted for native_shared_libs/tests, it implies
|
||||
// When multilib.* is omitted for native_shared_libs/jni_libs/tests, it implies
|
||||
// multilib.both
|
||||
addDependenciesForNativeModules(ctx,
|
||||
ApexNativeDependencies{
|
||||
Native_shared_libs: a.properties.Native_shared_libs,
|
||||
Tests: a.properties.Tests,
|
||||
Jni_libs: a.properties.Jni_libs,
|
||||
Binaries: nil,
|
||||
},
|
||||
target, a.getImageVariation(config))
|
||||
@@ -1600,6 +1613,7 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
ApexNativeDependencies{
|
||||
Native_shared_libs: nil,
|
||||
Tests: nil,
|
||||
Jni_libs: nil,
|
||||
Binaries: a.properties.Binaries,
|
||||
},
|
||||
target, a.getImageVariation(config))
|
||||
@@ -1641,7 +1655,7 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
for _, sanitizer := range ctx.Config().SanitizeDevice() {
|
||||
if sanitizer == "hwaddress" {
|
||||
addDependenciesForNativeModules(ctx,
|
||||
ApexNativeDependencies{[]string{"libclang_rt.hwasan-aarch64-android"}, nil, nil},
|
||||
ApexNativeDependencies{[]string{"libclang_rt.hwasan-aarch64-android"}, nil, nil, nil},
|
||||
target, a.getImageVariation(config))
|
||||
break
|
||||
}
|
||||
@@ -2063,16 +2077,23 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
depName := ctx.OtherModuleName(child)
|
||||
if _, isDirectDep := parent.(*apexBundle); isDirectDep {
|
||||
switch depTag {
|
||||
case sharedLibTag:
|
||||
case sharedLibTag, jniLibTag:
|
||||
isJniLib := depTag == jniLibTag
|
||||
if c, ok := child.(*cc.Module); ok {
|
||||
// bootstrap bionic libs are treated as provided by system
|
||||
if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
|
||||
provideNativeLibs = append(provideNativeLibs, c.OutputFile().Path().Base())
|
||||
}
|
||||
filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, c, handleSpecialLibs))
|
||||
fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs)
|
||||
fi.isJniLib = isJniLib
|
||||
filesInfo = append(filesInfo, fi)
|
||||
return true // track transitive dependencies
|
||||
} else {
|
||||
ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
|
||||
propertyName := "native_shared_libs"
|
||||
if isJniLib {
|
||||
propertyName = "jni_libs"
|
||||
}
|
||||
ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
|
||||
}
|
||||
case executableTag:
|
||||
if cc, ok := child.(*cc.Module); ok {
|
||||
|
Reference in New Issue
Block a user