Add support for JNI libraries to android_app modules
Make android_app modules a MultiTargets module, which means the common variant will have a list of Targets that it needs to handle. Collect JNI libraries for each Target, and package them into or alongside the APK. Bug: 80095087 Test: app_test.go Change-Id: Iabd3921e1d4c4b4cfcc7e131a0b0d9ab83b0ebbb
This commit is contained in:
@@ -19,9 +19,11 @@ package java
|
||||
// functions.
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
@@ -61,16 +63,18 @@ var combineApk = pctx.AndroidStaticRule("combineApk",
|
||||
})
|
||||
|
||||
func CreateAppPackage(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
resJarFile, dexJarFile android.Path, certificates []certificate) {
|
||||
|
||||
// TODO(ccross): JNI libs
|
||||
resJarFile, jniJarFile, dexJarFile android.Path, certificates []certificate) {
|
||||
|
||||
unsignedApk := android.PathForModuleOut(ctx, "unsigned.apk")
|
||||
|
||||
inputs := android.Paths{resJarFile}
|
||||
var inputs android.Paths
|
||||
if dexJarFile != nil {
|
||||
inputs = append(inputs, dexJarFile)
|
||||
}
|
||||
inputs = append(inputs, resJarFile)
|
||||
if jniJarFile != nil {
|
||||
inputs = append(inputs, jniJarFile)
|
||||
}
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: combineApk,
|
||||
@@ -132,3 +136,37 @@ func BuildAAR(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TransformJniLibsToJar(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
jniLibs []jniLib) {
|
||||
|
||||
var deps android.Paths
|
||||
jarArgs := []string{
|
||||
"-j", // junk paths, they will be added back with -P arguments
|
||||
}
|
||||
|
||||
if !ctx.Config().UnbundledBuild() {
|
||||
jarArgs = append(jarArgs, "-L 0")
|
||||
}
|
||||
|
||||
for _, j := range jniLibs {
|
||||
deps = append(deps, j.path)
|
||||
jarArgs = append(jarArgs,
|
||||
"-P "+targetToJniDir(j.target),
|
||||
"-f "+j.path.String())
|
||||
}
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: zip,
|
||||
Description: "zip jni libs",
|
||||
Output: outputFile,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"jarArgs": strings.Join(proptools.NinjaAndShellEscape(jarArgs), " "),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func targetToJniDir(target android.Target) string {
|
||||
return filepath.Join("lib", target.Arch.Abi[0])
|
||||
}
|
||||
|
Reference in New Issue
Block a user