Allow appending artifact in dist with product name

Some modules need to have their artifacts copied to dist with the
product name appended. This CL enables that functionality in a
boolean Soong property called append_artifact_with_product.

Fixes: 224561567
Test: Unit tests and build relevant target/modules
Change-Id: I4b824d4001679cebf0a9059be2d090d33a310933
This commit is contained in:
Trevor Radcliffe
2022-03-21 19:34:02 +00:00
parent b6a55c53e7
commit 90727f4576
5 changed files with 61 additions and 3 deletions

View File

@@ -148,6 +148,14 @@ type AndroidMkEntries struct {
// without worrying about the variables being mixed up in the actual mk file.
// 3. Makes troubleshooting and spotting errors easier.
entryOrder []string
// Provides data typically stored by Context objects that are commonly needed by
//AndroidMkEntries objects.
entryContext AndroidMkEntriesContext
}
type AndroidMkEntriesContext interface {
Config() Config
}
type AndroidMkExtraEntriesContext interface {
@@ -408,10 +416,19 @@ func (a *AndroidMkEntries) getDistContributions(mod blueprint.Module) *distContr
}
}
ext := filepath.Ext(dest)
suffix := ""
if dist.Suffix != nil {
ext := filepath.Ext(dest)
suffix := *dist.Suffix
dest = strings.TrimSuffix(dest, ext) + suffix + ext
suffix = *dist.Suffix
}
productString := ""
if dist.Append_artifact_with_product != nil && *dist.Append_artifact_with_product {
productString = fmt.Sprintf("_%s", a.entryContext.Config().DeviceProduct())
}
if suffix != "" || productString != "" {
dest = strings.TrimSuffix(dest, ext) + suffix + productString + ext
}
if dist.Dir != nil {
@@ -478,6 +495,7 @@ type fillInEntriesContext interface {
}
func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint.Module) {
a.entryContext = ctx
a.EntryMap = make(map[string][]string)
amod := mod.(Module)
base := amod.base()