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:
@@ -148,6 +148,14 @@ type AndroidMkEntries struct {
|
|||||||
// without worrying about the variables being mixed up in the actual mk file.
|
// without worrying about the variables being mixed up in the actual mk file.
|
||||||
// 3. Makes troubleshooting and spotting errors easier.
|
// 3. Makes troubleshooting and spotting errors easier.
|
||||||
entryOrder []string
|
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 {
|
type AndroidMkExtraEntriesContext interface {
|
||||||
@@ -408,10 +416,19 @@ func (a *AndroidMkEntries) getDistContributions(mod blueprint.Module) *distContr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if dist.Suffix != nil {
|
|
||||||
ext := filepath.Ext(dest)
|
ext := filepath.Ext(dest)
|
||||||
suffix := *dist.Suffix
|
suffix := ""
|
||||||
dest = strings.TrimSuffix(dest, ext) + suffix + ext
|
if dist.Suffix != nil {
|
||||||
|
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 {
|
if dist.Dir != nil {
|
||||||
@@ -478,6 +495,7 @@ type fillInEntriesContext interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint.Module) {
|
func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint.Module) {
|
||||||
|
a.entryContext = ctx
|
||||||
a.EntryMap = make(map[string][]string)
|
a.EntryMap = make(map[string][]string)
|
||||||
amod := mod.(Module)
|
amod := mod.(Module)
|
||||||
base := amod.base()
|
base := amod.base()
|
||||||
|
@@ -148,6 +148,9 @@ func buildContextAndCustomModuleFoo(t *testing.T, bp string) (*TestContext, *cus
|
|||||||
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
ctx.RegisterModuleType("custom", customModuleFactory)
|
ctx.RegisterModuleType("custom", customModuleFactory)
|
||||||
}),
|
}),
|
||||||
|
FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
||||||
|
variables.DeviceProduct = proptools.StringPtr("bar")
|
||||||
|
}),
|
||||||
FixtureWithRootAndroidBp(bp),
|
FixtureWithRootAndroidBp(bp),
|
||||||
).RunTest(t)
|
).RunTest(t)
|
||||||
|
|
||||||
@@ -400,6 +403,25 @@ func TestGetDistContributions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
testHelper(t, "append-artifact-with-product", `
|
||||||
|
custom {
|
||||||
|
name: "foo",
|
||||||
|
dist: {
|
||||||
|
targets: ["my_goal"],
|
||||||
|
append_artifact_with_product: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, &distContributions{
|
||||||
|
copiesForGoals: []*copiesForGoals{
|
||||||
|
{
|
||||||
|
goals: "my_goal",
|
||||||
|
copies: []distCopy{
|
||||||
|
distCopyForTest("one.out", "one_bar.out"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
testHelper(t, "dists-with-tag", `
|
testHelper(t, "dists-with-tag", `
|
||||||
custom {
|
custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@@ -351,6 +351,7 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
|||||||
config := &config{
|
config := &config{
|
||||||
productVariables: productVariables{
|
productVariables: productVariables{
|
||||||
DeviceName: stringPtr("test_device"),
|
DeviceName: stringPtr("test_device"),
|
||||||
|
DeviceProduct: stringPtr("test_product"),
|
||||||
Platform_sdk_version: intPtr(30),
|
Platform_sdk_version: intPtr(30),
|
||||||
Platform_sdk_codename: stringPtr("S"),
|
Platform_sdk_codename: stringPtr("S"),
|
||||||
Platform_base_sdk_extension_version: intPtr(1),
|
Platform_base_sdk_extension_version: intPtr(1),
|
||||||
@@ -723,6 +724,15 @@ func (c *config) DeviceName() string {
|
|||||||
return *c.productVariables.DeviceName
|
return *c.productVariables.DeviceName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeviceProduct returns the current product target. There could be multiple of
|
||||||
|
// these per device type.
|
||||||
|
//
|
||||||
|
// NOTE: Do not base conditional logic on this value. It may break product
|
||||||
|
// inheritance.
|
||||||
|
func (c *config) DeviceProduct() string {
|
||||||
|
return *c.productVariables.DeviceProduct
|
||||||
|
}
|
||||||
|
|
||||||
func (c *config) DeviceResourceOverlays() []string {
|
func (c *config) DeviceResourceOverlays() []string {
|
||||||
return c.productVariables.DeviceResourceOverlays
|
return c.productVariables.DeviceResourceOverlays
|
||||||
}
|
}
|
||||||
|
@@ -609,6 +609,12 @@ type Dist struct {
|
|||||||
// A suffix to add to the artifact file name (before any extension).
|
// A suffix to add to the artifact file name (before any extension).
|
||||||
Suffix *string `android:"arch_variant"`
|
Suffix *string `android:"arch_variant"`
|
||||||
|
|
||||||
|
// If true, then the artifact file will be appended with _<product name>. For
|
||||||
|
// example, if the product is coral and the module is an android_app module
|
||||||
|
// of name foo, then the artifact would be foo_coral.apk. If false, there is
|
||||||
|
// no change to the artifact file name.
|
||||||
|
Append_artifact_with_product *bool `android:"arch_variant"`
|
||||||
|
|
||||||
// A string tag to select the OutputFiles associated with the tag.
|
// A string tag to select the OutputFiles associated with the tag.
|
||||||
//
|
//
|
||||||
// If no tag is specified then it will select the default dist paths provided
|
// If no tag is specified then it will select the default dist paths provided
|
||||||
|
@@ -201,6 +201,7 @@ type productVariables struct {
|
|||||||
Platform_base_os *string `json:",omitempty"`
|
Platform_base_os *string `json:",omitempty"`
|
||||||
|
|
||||||
DeviceName *string `json:",omitempty"`
|
DeviceName *string `json:",omitempty"`
|
||||||
|
DeviceProduct *string `json:",omitempty"`
|
||||||
DeviceArch *string `json:",omitempty"`
|
DeviceArch *string `json:",omitempty"`
|
||||||
DeviceArchVariant *string `json:",omitempty"`
|
DeviceArchVariant *string `json:",omitempty"`
|
||||||
DeviceCpuVariant *string `json:",omitempty"`
|
DeviceCpuVariant *string `json:",omitempty"`
|
||||||
@@ -467,6 +468,7 @@ func (v *productVariables) SetDefaultConfig() {
|
|||||||
HostArch: stringPtr("x86_64"),
|
HostArch: stringPtr("x86_64"),
|
||||||
HostSecondaryArch: stringPtr("x86"),
|
HostSecondaryArch: stringPtr("x86"),
|
||||||
DeviceName: stringPtr("generic_arm64"),
|
DeviceName: stringPtr("generic_arm64"),
|
||||||
|
DeviceProduct: stringPtr("aosp_arm-eng"),
|
||||||
DeviceArch: stringPtr("arm64"),
|
DeviceArch: stringPtr("arm64"),
|
||||||
DeviceArchVariant: stringPtr("armv8-a"),
|
DeviceArchVariant: stringPtr("armv8-a"),
|
||||||
DeviceCpuVariant: stringPtr("generic"),
|
DeviceCpuVariant: stringPtr("generic"),
|
||||||
|
Reference in New Issue
Block a user