Extract dist properties from commonProperties
Common properties are automatically inherited from a parent module
(i.e. one that calls CreateModule()) to the child module that it
creates. This makes no sense for dist/dists properties so this change
extracts them into their own structure separate to the
commonProperties.
Test: m checkbuild and TreeHugger
Bug: 160448975
Change-Id: Icceb20455e13394dd3b3bce464fb9bb34882d6c3
diff --git a/android/module.go b/android/module.go
index 17bc205..3374e1d 100644
--- a/android/module.go
+++ b/android/module.go
@@ -490,14 +490,6 @@
// 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
@@ -566,6 +558,16 @@
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
@@ -661,7 +663,8 @@
m.AddProperties(
&base.nameProperties,
- &base.commonProperties)
+ &base.commonProperties,
+ &base.distProperties)
initProductVariableModule(m)
@@ -752,6 +755,7 @@
nameProperties nameProperties
commonProperties commonProperties
+ distProperties distProperties
variableProperties interface{}
hostAndDeviceProperties hostAndDeviceProperties
generalProperties []interface{}
@@ -861,13 +865,13 @@
}
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
}
}
@@ -1344,20 +1348,20 @@
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.")
}
}