aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorJaewoong Jung <jungjw@google.com>2019-07-17 10:21:49 -0700
committerMichael Bestas <mkbestas@lineageos.org>2019-12-11 19:03:32 +0200
commitba18ee4726de96c98183968173f1c83918a72a52 (patch)
treea1d1be9eb9aecb8913a229826e58c8dfffec4956 /java
parentcdfe4845abb5c1609127207a6b98199dd561cbd3 (diff)
downloadbuild_soong-ba18ee4726de96c98183968173f1c83918a72a52.tar.gz
build_soong-ba18ee4726de96c98183968173f1c83918a72a52.tar.bz2
build_soong-ba18ee4726de96c98183968173f1c83918a72a52.zip
Add filename property to android_app_import
Test: app_test.go Bug: 137218697 Change-Id: If2b20a355bb6e9e8dbcd57347c0e2c6fa041a932
Diffstat (limited to 'java')
-rw-r--r--java/androidmk.go35
-rw-r--r--java/app.go8
-rw-r--r--java/app_test.go48
3 files changed, 70 insertions, 21 deletions
diff --git a/java/androidmk.go b/java/androidmk.go
index 78815838..8d9cbdd5 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -581,28 +581,23 @@ func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
}
}
-func (app *AndroidAppImport) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
+func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
+ return android.AndroidMkEntries{
Class: "APPS",
- OutputFile: android.OptionalPathForPath(app.outputFile),
+ OutputFile: android.OptionalPathForPath(a.outputFile),
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
- if Bool(app.properties.Privileged) {
- fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
- }
- if app.certificate != nil {
- fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
- } else {
- fmt.Fprintln(w, "LOCAL_CERTIFICATE := PRESIGNED")
- }
- if len(app.properties.Overrides) > 0 {
- fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES :=", strings.Join(app.properties.Overrides, " "))
- }
- if len(app.dexpreopter.builtInstalled) > 0 {
- fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", app.dexpreopter.builtInstalled)
- }
- },
+ AddCustomEntries: func(name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(a.properties.Privileged))
+ if a.certificate != nil {
+ entries.SetString("LOCAL_CERTIFICATE", a.certificate.Pem.String())
+ } else {
+ entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED")
+ }
+ entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
+ if len(a.dexpreopter.builtInstalled) > 0 {
+ entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
+ }
+ entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
},
}
}
diff --git a/java/app.go b/java/app.go
index 4b0eec13..bcbf6f31 100644
--- a/java/app.go
+++ b/java/app.go
@@ -692,6 +692,8 @@ type AndroidAppImport struct {
certificate *Certificate
dexpreopter
+
+ installPath android.OutputPath
}
type AndroidAppImportProperties struct {
@@ -717,6 +719,9 @@ type AndroidAppImportProperties struct {
// binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
// from PRODUCT_PACKAGES.
Overrides []string
+
+ // Optional name for the installed app. If unspecified, it is derived from the module name.
+ Filename *string
}
// Chooses a source APK path to use based on the module and product specs.
@@ -857,7 +862,8 @@ func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext
// TODO: Optionally compress the output apk.
- ctx.InstallFile(installDir, a.BaseModuleName()+".apk", a.outputFile)
+ a.installPath = ctx.InstallFile(installDir,
+ proptools.StringDefault(a.properties.Filename, a.BaseModuleName()+".apk"), a.outputFile)
// TODO: androidmk converter jni libs
}
diff --git a/java/app_test.go b/java/app_test.go
index d4de7533..8b254ad0 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -1314,3 +1314,51 @@ func TestAndroidAppImport_DpiVariants(t *testing.T) {
}
}
}
+
+func TestAndroidAppImport_Filename(t *testing.T) {
+ config := testConfig(nil)
+ ctx := testJava(t, `
+ android_app_import {
+ name: "foo",
+ apk: "prebuilts/apk/app.apk",
+ presigned: true,
+ }
+
+ android_app_import {
+ name: "bar",
+ apk: "prebuilts/apk/app.apk",
+ presigned: true,
+ filename: "bar_sample.apk"
+ }
+ `)
+
+ testCases := []struct {
+ name string
+ expected string
+ }{
+ {
+ name: "foo",
+ expected: "foo.apk",
+ },
+ {
+ name: "bar",
+ expected: "bar_sample.apk",
+ },
+ }
+
+ for _, test := range testCases {
+ variant := ctx.ModuleForTests(test.name, "android_common")
+ if variant.MaybeOutput(test.expected).Rule == nil {
+ t.Errorf("can't find output named %q - all outputs: %v", test.expected, variant.AllOutputs())
+ }
+
+ a := variant.Module().(*AndroidAppImport)
+ expectedValues := []string{test.expected}
+ actualValues := android.AndroidMkEntriesForTest(
+ t, config, "", a).EntryMap["LOCAL_INSTALLED_MODULE_STEM"]
+ if !reflect.DeepEqual(actualValues, expectedValues) {
+ t.Errorf("Incorrect LOCAL_INSTALLED_MODULE_STEM value '%s', expected '%s'",
+ actualValues, expectedValues)
+ }
+ }
+}