Revert^2 "Install jni symlinks in Soong"

b7646e4d4f

This is a relanding of I0930cb1ebb8ca8a6efd64b1ce2cdfd1c47fe19ef plus
some forward fix described below:

Export non-embedded JNI lib names via LOCAL_REQUIRED_MODULES

The non-embedded JNI libs are installed as the dependencies of the APK.
However, that dependency is not revealed to the Make world and as a
result, the JNI libs are dropped from the file_list.txt file which Make
uses to filter files to include in the image file.

Adding the lib names to LOCAL_REQUIRED_MODULES fixes it.

Bug: 341335305
Bug: 330276359
Test: m out/target/product/vsoc_x86_64_only/obj/PACKAGING/system_intermediates/file_list.txt
and check if libcarservicejni.so is there
Test: go test ./... under soong/java

Change-Id: If915a05909129c92fab7a6cbbd0c4c55f5ced598
This commit is contained in:
Jiyong Park
2024-05-17 22:58:54 +00:00
parent bd6b1fcab4
commit 25b9222a43
4 changed files with 63 additions and 153 deletions

View File

@@ -911,6 +911,26 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
installed := ctx.InstallFile(a.installDir, extra.Base(), extra)
extraInstalledPaths = append(extraInstalledPaths, installed)
}
// If we don't embed jni libs, make sure that those are installed along with the
// app, and also place symlinks to the installed paths under the lib/<arch>
// directory of the app installation directory. ex:
// /system/app/MyApp/lib/arm64/libfoo.so -> /system/lib64/libfoo.so
if !a.embeddedJniLibs {
for _, jniLib := range jniLibs {
archStr := jniLib.target.Arch.ArchType.String()
symlinkDir := a.installDir.Join(ctx, "lib", archStr)
for _, installedLib := range jniLib.installPaths {
// install the symlink target along with the app
extraInstalledPaths = append(extraInstalledPaths, installedLib)
ctx.PackageFile(installedLib, "", jniLib.path)
// install the symlink itself
symlinkName := installedLib.Base()
symlinkTarget := android.InstallPathToOnDevicePath(ctx, installedLib)
ctx.InstallAbsoluteSymlink(symlinkDir, symlinkName, symlinkTarget)
}
}
}
ctx.InstallFile(a.installDir, a.outputFile.Base(), a.outputFile, extraInstalledPaths...)
}
@@ -998,6 +1018,7 @@ func collectJniDeps(ctx android.ModuleContext,
coverageFile: dep.CoverageOutputFile(),
unstrippedFile: dep.UnstrippedOutputFile(),
partition: dep.Partition(),
installPaths: dep.FilesToInstall(),
})
} else if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{otherName})