Merge "apex: do not follow jni_libs from android_app"

This commit is contained in:
Jooyung Han 2020-02-26 02:35:10 +00:00 committed by Gerrit Code Review
commit 077f9a44f9
2 changed files with 22 additions and 9 deletions

View file

@ -2233,7 +2233,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return true // track transitive dependencies
}
} else if java.IsJniDepTag(depTag) {
return true
// Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
return false
} else if java.IsXmlPermissionsFileDepTag(depTag) {
if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))

View file

@ -2891,6 +2891,15 @@ func TestApexWithApps(t *testing.T) {
cc_library_shared {
name: "libjni",
srcs: ["mylib.cpp"],
shared_libs: ["libfoo"],
stl: "none",
system_shared_libs: [],
apex_available: [ "myapex" ],
sdk_version: "current",
}
cc_library_shared {
name: "libfoo",
stl: "none",
system_shared_libs: [],
apex_available: [ "myapex" ],
@ -2905,16 +2914,19 @@ func TestApexWithApps(t *testing.T) {
ensureContains(t, copyCmds, "image.apex/app/AppFoo/AppFoo.apk")
ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv/AppFooPriv.apk")
// JNI libraries are embedded inside APK
appZipRule := ctx.ModuleForTests("AppFoo", "android_common_myapex").Description("zip jni lib")
libjniOutput := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_shared_myapex").Module().(*cc.Module).OutputFile()
ensureListContains(t, appZipRule.Implicits.Strings(), libjniOutput.String())
// ... uncompressed
appZipRule := ctx.ModuleForTests("AppFoo", "android_common_myapex").Description("zip jni libs")
// JNI libraries are uncompressed
if args := appZipRule.Args["jarArgs"]; !strings.Contains(args, "-L 0") {
t.Errorf("jni lib is not uncompressed for AppFoo")
t.Errorf("jni libs are not uncompressed for AppFoo")
}
// JNI libraries including transitive deps are
for _, jni := range []string{"libjni", "libfoo"} {
jniOutput := ctx.ModuleForTests(jni, "android_arm64_armv8-a_shared_myapex").Module().(*cc.Module).OutputFile()
// ... embedded inside APK (jnilibs.zip)
ensureListContains(t, appZipRule.Implicits.Strings(), jniOutput.String())
// ... and not directly inside the APEX
ensureNotContains(t, copyCmds, "image.apex/lib64/"+jni+".so")
}
// ... and not directly inside the APEX
ensureNotContains(t, copyCmds, "image.apex/lib64/libjni.so")
}
func TestApexWithAppImports(t *testing.T) {