Extract dist properties from commonProperties am: ed87513b0b

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1418389

Change-Id: I9a59d1a4154409a6a3d1efa590cccd2064b6c389
This commit is contained in:
Paul Duffin
2020-09-03 15:18:46 +00:00
committed by Automerger Merge Worker
2 changed files with 25 additions and 20 deletions

View File

@@ -195,7 +195,8 @@ func InitDefaultsModule(module DefaultsModule) {
module.AddProperties(
&hostAndDeviceProperties{},
commonProperties,
&ApexProperties{})
&ApexProperties{},
&distProperties{})
initAndroidModuleBase(module)
initProductVariableModule(module)

View File

@@ -491,14 +491,6 @@ type commonProperties struct {
// relative path to a file to include in the list of notices for the device
Notice *string `android:"path"`
// configuration to distribute output files from this module to the distribution
// directory (default: $OUT/dist, configurable with $DIST_DIR)
Dist Dist `android:"arch_variant"`
// a list of configurations to distribute output files from this module to the
// distribution directory (default: $OUT/dist, configurable with $DIST_DIR)
Dists []Dist `android:"arch_variant"`
// The OsType of artifacts that this module variant is responsible for creating.
//
// Set by osMutator
@@ -567,6 +559,16 @@ type commonProperties struct {
ImageVariation string `blueprint:"mutated"`
}
type distProperties struct {
// configuration to distribute output files from this module to the distribution
// directory (default: $OUT/dist, configurable with $DIST_DIR)
Dist Dist `android:"arch_variant"`
// a list of configurations to distribute output files from this module to the
// distribution directory (default: $OUT/dist, configurable with $DIST_DIR)
Dists []Dist `android:"arch_variant"`
}
// A map of OutputFile tag keys to Paths, for disting purposes.
type TaggedDistFiles map[string]Paths
@@ -662,7 +664,8 @@ func InitAndroidModule(m Module) {
m.AddProperties(
&base.nameProperties,
&base.commonProperties)
&base.commonProperties,
&base.distProperties)
initProductVariableModule(m)
@@ -753,6 +756,7 @@ type ModuleBase struct {
nameProperties nameProperties
commonProperties commonProperties
distProperties distProperties
variableProperties interface{}
hostAndDeviceProperties hostAndDeviceProperties
generalProperties []interface{}
@@ -862,13 +866,13 @@ func (m *ModuleBase) visibilityProperties() []visibilityProperty {
}
func (m *ModuleBase) Dists() []Dist {
if len(m.commonProperties.Dist.Targets) > 0 {
if len(m.distProperties.Dist.Targets) > 0 {
// Make a copy of the underlying Dists slice to protect against
// backing array modifications with repeated calls to this method.
distsCopy := append([]Dist(nil), m.commonProperties.Dists...)
return append(distsCopy, m.commonProperties.Dist)
distsCopy := append([]Dist(nil), m.distProperties.Dists...)
return append(distsCopy, m.distProperties.Dist)
} else {
return m.commonProperties.Dists
return m.distProperties.Dists
}
}
@@ -1345,20 +1349,20 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
ctx.Variable(pctx, "moduleDescSuffix", s)
// Some common property checks for properties that will be used later in androidmk.go
if m.commonProperties.Dist.Dest != nil {
_, err := validateSafePath(*m.commonProperties.Dist.Dest)
if m.distProperties.Dist.Dest != nil {
_, err := validateSafePath(*m.distProperties.Dist.Dest)
if err != nil {
ctx.PropertyErrorf("dist.dest", "%s", err.Error())
}
}
if m.commonProperties.Dist.Dir != nil {
_, err := validateSafePath(*m.commonProperties.Dist.Dir)
if m.distProperties.Dist.Dir != nil {
_, err := validateSafePath(*m.distProperties.Dist.Dir)
if err != nil {
ctx.PropertyErrorf("dist.dir", "%s", err.Error())
}
}
if m.commonProperties.Dist.Suffix != nil {
if strings.Contains(*m.commonProperties.Dist.Suffix, "/") {
if m.distProperties.Dist.Suffix != nil {
if strings.Contains(*m.distProperties.Dist.Suffix, "/") {
ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
}
}