aboutsummaryrefslogtreecommitdiffstats
path: root/apex
diff options
context:
space:
mode:
authorNikita Ioffe <ioffe@google.com>2019-04-04 18:09:48 +0100
committerNikita Ioffe <ioffe@google.com>2019-04-08 06:30:39 +0100
commited75f6139899bd0301eaa0321ccfbc8cab620003 (patch)
tree5f6a6307b795267fa3f294a0c1750843edc72bff /apex
parent03a31cc2ccfcd65a7e1fc953aa306609355bed97 (diff)
downloadbuild_soong-ed75f6139899bd0301eaa0321ccfbc8cab620003.tar.gz
build_soong-ed75f6139899bd0301eaa0321ccfbc8cab620003.tar.bz2
build_soong-ed75f6139899bd0301eaa0321ccfbc8cab620003.zip
Add filename property to prebuilt_apex
* Makes it more inline with prebuilt_etc; * For shim apexes, prebuilt_apex modules have pattern of com.android.apex.cts.shim.v1_prebuilt, but I would prefer pre-installed shim to be: /system/apex/com.android.apex.cts.shim.apex Bug: 128677967 Bug: 127789981 Test: m Change-Id: I34e3e078733420b5cf777fd6e3ce4d8c5796b19b Merged-In: I34e3e078733420b5cf777fd6e3ce4d8c5796b19b (cherry picked from commit 7a41ebdf5fafcd2ca101ddd56e560c3f59660778)
Diffstat (limited to 'apex')
-rw-r--r--apex/apex.go16
-rw-r--r--apex/apex_test.go17
2 files changed, 29 insertions, 4 deletions
diff --git a/apex/apex.go b/apex/apex.go
index c68d1cff..389290c1 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1294,8 +1294,9 @@ type Prebuilt struct {
properties PrebuiltProperties
- inputApex android.Path
- installDir android.OutputPath
+ inputApex android.Path
+ installDir android.OutputPath
+ installFilename string
}
type PrebuiltProperties struct {
@@ -1319,6 +1320,9 @@ type PrebuiltProperties struct {
}
Installable *bool
+ // Optional name for the installed apex. If unspecified, name of the
+ // module is used as the file name
+ Filename *string
}
func (p *Prebuilt) installable() bool {
@@ -1357,8 +1361,12 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// TODO(jungjw): Check the key validity.
p.inputApex = p.Prebuilt().SingleSourcePath(ctx)
p.installDir = android.PathForModuleInstall(ctx, "apex")
+ p.installFilename = proptools.StringDefault(p.properties.Filename, ctx.ModuleName()+imageApexSuffix)
+ if !strings.HasSuffix(p.installFilename, imageApexSuffix) {
+ ctx.ModuleErrorf("filename should end in %s for prebuilt_apex", imageApexSuffix)
+ }
if p.installable() {
- ctx.InstallFile(p.installDir, ctx.ModuleName()+imageApexSuffix, p.inputApex)
+ ctx.InstallFile(p.installDir, p.installFilename, p.inputApex)
}
}
@@ -1378,7 +1386,7 @@ func (p *Prebuilt) AndroidMk() android.AndroidMkData {
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString()))
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", p.BaseModuleName()+imageApexSuffix)
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", p.installFilename)
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !p.installable())
},
},
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 6d101d8a..3c80376d 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -1256,3 +1256,20 @@ func TestPrebuilt(t *testing.T) {
t.Errorf("inputApex invalid. expected: %q, actual: %q", expectedInput, prebuilt.inputApex.String())
}
}
+
+func TestPrebuiltFilenameOverride(t *testing.T) {
+ ctx := testApex(t, `
+ prebuilt_apex {
+ name: "myapex",
+ src: "myapex-arm.apex",
+ filename: "notmyapex.apex",
+ }
+ `)
+
+ p := ctx.ModuleForTests("myapex", "android_common").Module().(*Prebuilt)
+
+ expected := "notmyapex.apex"
+ if p.installFilename != expected {
+ t.Errorf("installFilename invalid. expected: %q, actual: %q", expected, p.installFilename)
+ }
+}