Add filename property to prebuilt_apex
am: 7a41ebdf5f
Change-Id: Ie3397cb98902c215d2967ea49c6f763835ad4184
This commit is contained in:
commit
8501172354
2 changed files with 29 additions and 4 deletions
16
apex/apex.go
16
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())
|
||||
},
|
||||
},
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue