From ed87513b0ba000a01badcebd643c2a7f888e3452 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 2 Sep 2020 13:08:57 +0100 Subject: [PATCH] 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 --- android/defaults.go | 3 ++- android/module.go | 42 +++++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/android/defaults.go b/android/defaults.go index 81e340e8e..23aa7b42d 100644 --- a/android/defaults.go +++ b/android/defaults.go @@ -195,7 +195,8 @@ func InitDefaultsModule(module DefaultsModule) { module.AddProperties( &hostAndDeviceProperties{}, commonProperties, - &ApexProperties{}) + &ApexProperties{}, + &distProperties{}) initAndroidModuleBase(module) initProductVariableModule(module) diff --git a/android/module.go b/android/module.go index 17bc205e0..3374e1dcb 100644 --- a/android/module.go +++ b/android/module.go @@ -490,14 +490,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 @@ -566,6 +558,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 @@ -661,7 +663,8 @@ func InitAndroidModule(m Module) { m.AddProperties( &base.nameProperties, - &base.commonProperties) + &base.commonProperties, + &base.distProperties) initProductVariableModule(m) @@ -752,6 +755,7 @@ type ModuleBase struct { nameProperties nameProperties commonProperties commonProperties + distProperties distProperties variableProperties interface{} hostAndDeviceProperties hostAndDeviceProperties generalProperties []interface{} @@ -861,13 +865,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 } } @@ -1344,20 +1348,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.") } }