Merge "Avoid extra copy of JNI libs zip" into main

This commit is contained in:
Colin Cross 2023-07-27 20:11:20 +00:00 committed by Gerrit Code Review
commit a706cc8c15
2 changed files with 16 additions and 13 deletions

View file

@ -225,8 +225,6 @@ func BuildBundleModule(ctx android.ModuleContext, outputFile android.WritablePat
})
}
const jniJarOutputPathString = "jniJarOutput.zip"
func TransformJniLibsToJar(
ctx android.ModuleContext,
outputFile android.WritablePath,
@ -258,7 +256,10 @@ func TransformJniLibsToJar(
rule = zipRE
args["implicits"] = strings.Join(deps.Strings(), ",")
}
jniJarPath := android.PathForModuleOut(ctx, jniJarOutputPathString)
var jniJarPath android.WritablePath = android.PathForModuleOut(ctx, "jniJarOutput.zip")
if len(prebuiltJniPackages) == 0 {
jniJarPath = outputFile
}
ctx.Build(pctx, android.BuildParams{
Rule: rule,
Description: "zip jni libs",
@ -266,12 +267,14 @@ func TransformJniLibsToJar(
Implicits: deps,
Args: args,
})
ctx.Build(pctx, android.BuildParams{
Rule: mergeAssetsRule,
Description: "merge prebuilt JNI packages",
Inputs: append(prebuiltJniPackages, jniJarPath),
Output: outputFile,
})
if len(prebuiltJniPackages) > 0 {
ctx.Build(pctx, android.BuildParams{
Rule: mergeAssetsRule,
Description: "merge prebuilt JNI packages",
Inputs: append(prebuiltJniPackages, jniJarPath),
Output: outputFile,
})
}
}
func (a *AndroidApp) generateJavaUsedByApex(ctx android.ModuleContext) {

View file

@ -1742,7 +1742,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(jniJarOutputPathString)
jniLibZip := app.Output("jnilibs.zip")
var abis []string
args := strings.Fields(jniLibZip.Args["jarArgs"])
for i := 0; i < len(args); i++ {
@ -1875,7 +1875,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(jniJarOutputPathString)
jniLibZip := app.MaybeOutput("jnilibs.zip")
if g, w := (jniLibZip.Rule != nil), test.packaged; g != w {
t.Errorf("expected jni packaged %v, got %v", w, g)
}
@ -1966,7 +1966,7 @@ func TestJNISDK(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.MaybeOutput(jniJarOutputPathString)
jniLibZip := app.MaybeOutput("jnilibs.zip")
if len(jniLibZip.Implicits) != 1 {
t.Fatalf("expected exactly one jni library, got %q", jniLibZip.Implicits.Strings())
}
@ -2986,7 +2986,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(jniJarOutputPathString)
jniLibZip := app.Output("jnilibs.zip")
var jnis []string
args := strings.Fields(jniLibZip.Args["jarArgs"])
for i := 0; i < len(args); i++ {