diff options
author | 2018-10-02 22:03:40 -0700 | |
---|---|---|
committer | 2018-10-08 15:20:56 -0700 | |
commit | a4f08813a34418a07aa0ebd8b3e704f3a82081ef (patch) | |
tree | f1956fe9c05bf91f87f8efd3aafe8daff09e1c67 /java/app_builder.go | |
parent | b1a5e9cadfdd0765f763883fd7410add24486ef6 (diff) |
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
Diffstat (limited to 'java/app_builder.go')
-rw-r--r-- | java/app_builder.go | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/java/app_builder.go b/java/app_builder.go index e27b1b70e..b9b5f43a7 100644 --- a/java/app_builder.go +++ b/java/app_builder.go @@ -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]) +} |