Merge "copy JNI from AAR files to android_app APK" am: fb845984df

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2149174

Change-Id: I8697a193bf054623dcdf67f6beded56a75c52875
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Sam Delmerico
2022-08-03 13:31:01 +00:00
committed by Automerger Merge Worker
8 changed files with 271 additions and 19 deletions

View File

@@ -1218,7 +1218,7 @@ func TestJNIABI(t *testing.T) {
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.Output("jnilibs.zip")
jniLibZip := app.Output(jniJarOutputPathString)
var abis []string
args := strings.Fields(jniLibZip.Args["jarArgs"])
for i := 0; i < len(args); i++ {
@@ -1351,7 +1351,7 @@ func TestJNIPackaging(t *testing.T) {
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.MaybeOutput("jnilibs.zip")
jniLibZip := app.MaybeOutput(jniJarOutputPathString)
if g, w := (jniLibZip.Rule != nil), test.packaged; g != w {
t.Errorf("expected jni packaged %v, got %v", w, g)
}
@@ -1442,7 +1442,7 @@ func TestJNISDK(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.MaybeOutput("jnilibs.zip")
jniLibZip := app.MaybeOutput(jniJarOutputPathString)
if len(jniLibZip.Implicits) != 1 {
t.Fatalf("expected exactly one jni library, got %q", jniLibZip.Implicits.Strings())
}
@@ -2428,7 +2428,7 @@ func TestStl(t *testing.T) {
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.Output("jnilibs.zip")
jniLibZip := app.Output(jniJarOutputPathString)
var jnis []string
args := strings.Fields(jniLibZip.Args["jarArgs"])
for i := 0; i < len(args); i++ {
@@ -3077,3 +3077,89 @@ func TestAppMissingCertificateAllowMissingDependencies(t *testing.T) {
}
android.AssertStringDoesContain(t, "expected error rule message", fooApk.Args["error"], "missing dependencies: missing_certificate\n")
}
func TestAppIncludesJniPackages(t *testing.T) {
ctx := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
android_library_import {
name: "aary-nodeps",
aars: ["aary.aar"],
extract_jni: true,
}
android_library {
name: "aary-lib",
sdk_version: "current",
min_sdk_version: "21",
static_libs: ["aary-nodeps"],
}
android_app {
name: "aary-lib-dep",
sdk_version: "current",
min_sdk_version: "21",
manifest: "AndroidManifest.xml",
static_libs: ["aary-lib"],
use_embedded_native_libs: true,
}
android_app {
name: "aary-import-dep",
sdk_version: "current",
min_sdk_version: "21",
manifest: "AndroidManifest.xml",
static_libs: ["aary-nodeps"],
use_embedded_native_libs: true,
}
android_app {
name: "aary-no-use-embedded",
sdk_version: "current",
min_sdk_version: "21",
manifest: "AndroidManifest.xml",
static_libs: ["aary-nodeps"],
}`)
testCases := []struct {
name string
hasPackage bool
}{
{
name: "aary-import-dep",
hasPackage: true,
},
{
name: "aary-lib-dep",
hasPackage: true,
},
{
name: "aary-no-use-embedded",
hasPackage: false,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
app := ctx.ModuleForTests(tc.name, "android_common")
outputFile := "jnilibs.zip"
jniOutputLibZip := app.MaybeOutput(outputFile)
if jniOutputLibZip.Rule == nil && !tc.hasPackage {
return
}
jniPackage := "arm64-v8a_jni.zip"
inputs := jniOutputLibZip.Inputs
foundPackage := false
for i := 0; i < len(inputs); i++ {
if strings.Contains(inputs[i].String(), jniPackage) {
foundPackage = true
}
}
if foundPackage != tc.hasPackage {
t.Errorf("expected to find %v in %v inputs; inputs = %v", jniPackage, outputFile, inputs)
}
})
}
}