summaryrefslogtreecommitdiff
path: root/android/module.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2020-11-23 18:17:03 +0000
committer Paul Duffin <paulduffin@google.com> 2020-11-27 15:17:44 +0000
commit89968e3dec95baa4cf0352d7eb85a9033dece8ef (patch)
tree7b15909d373de496c00020b46739d9bb08edba1f /android/module.go
parentd83988dbada4c0bce1a5b145ddc575c0f6047534 (diff)
Expand dist property checks to cover dists
Previously, only the dist property's nested properties were checked for correctness. This change also checks the dists property's nested dist structures and adds some tests to verify that the checks are run and correctly report the location of the incorrect property even when it is within a slice of dist structs. Test: m nothing Bug: 174226317 Change-Id: If5a19360e1e4c98ee3b5afc813e35349d1fc6f6f
Diffstat (limited to 'android/module.go')
-rw-r--r--android/module.go45
1 files changed, 29 insertions, 16 deletions
diff --git a/android/module.go b/android/module.go
index bd60829f1..0716b5dac 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1579,22 +1579,9 @@ 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.distProperties.Dist.Dest != nil {
- _, err := validateSafePath(*m.distProperties.Dist.Dest)
- if err != nil {
- ctx.PropertyErrorf("dist.dest", "%s", err.Error())
- }
- }
- if m.distProperties.Dist.Dir != nil {
- _, err := validateSafePath(*m.distProperties.Dist.Dir)
- if err != nil {
- ctx.PropertyErrorf("dist.dir", "%s", err.Error())
- }
- }
- if m.distProperties.Dist.Suffix != nil {
- if strings.Contains(*m.distProperties.Dist.Suffix, "/") {
- ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
- }
+ checkDistProperties(ctx, "dist", &m.distProperties.Dist)
+ for i, _ := range m.distProperties.Dists {
+ checkDistProperties(ctx, fmt.Sprintf("dists[%d]", i), &m.distProperties.Dists[i])
}
if m.Enabled() {
@@ -1659,6 +1646,32 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
m.variables = ctx.variables
}
+// Check the supplied dist structure to make sure that it is valid.
+//
+// property - the base property, e.g. dist or dists[1], which is combined with the
+// name of the nested property to produce the full property, e.g. dist.dest or
+// dists[1].dir.
+func checkDistProperties(ctx *moduleContext, property string, dist *Dist) {
+ if dist.Dest != nil {
+ _, err := validateSafePath(*dist.Dest)
+ if err != nil {
+ ctx.PropertyErrorf(property+".dest", "%s", err.Error())
+ }
+ }
+ if dist.Dir != nil {
+ _, err := validateSafePath(*dist.Dir)
+ if err != nil {
+ ctx.PropertyErrorf(property+".dir", "%s", err.Error())
+ }
+ }
+ if dist.Suffix != nil {
+ if strings.Contains(*dist.Suffix, "/") {
+ ctx.PropertyErrorf(property+".suffix", "Suffix may not contain a '/' character.")
+ }
+ }
+
+}
+
type earlyModuleContext struct {
blueprint.EarlyModuleContext