aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android/defaults.go2
-rw-r--r--android/module.go90
-rw-r--r--android/mutator.go70
-rw-r--r--android/prebuilt.go2
-rw-r--r--cc/cc.go21
-rw-r--r--cc/coverage.go6
-rw-r--r--cc/lto.go4
-rw-r--r--cc/sabi.go4
-rw-r--r--cc/sanitize.go4
-rw-r--r--genrule/genrule.go2
-rw-r--r--java/app.go3
-rw-r--r--java/java.go17
-rw-r--r--java/system_modules.go2
-rw-r--r--python/binary.go4
-rw-r--r--python/python.go2
15 files changed, 166 insertions, 67 deletions
diff --git a/android/defaults.go b/android/defaults.go
index 4bf872ea..c7045292 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -131,7 +131,7 @@ func defaultsDepsMutator(ctx BottomUpMutatorContext) {
func defaultsMutator(ctx TopDownMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok && len(defaultable.defaults().Defaults) > 0 {
var defaultsList []Defaults
- ctx.WalkDeps(func(module, parent blueprint.Module) bool {
+ ctx.WalkDeps(func(module, parent Module) bool {
if ctx.OtherModuleDependencyTag(module) == DefaultsDepTag {
if defaults, ok := module.(Defaults); ok {
defaultsList = append(defaultsList, defaults)
diff --git a/android/module.go b/android/module.go
index 0fada781..4d4462b3 100644
--- a/android/module.go
+++ b/android/module.go
@@ -108,11 +108,11 @@ type ModuleContext interface {
ModuleSubDir() string
- VisitDirectDeps(visit func(blueprint.Module))
- VisitDirectDepsIf(pred func(blueprint.Module) bool, visit func(blueprint.Module))
- VisitDepsDepthFirst(visit func(blueprint.Module))
- VisitDepsDepthFirstIf(pred func(blueprint.Module) bool, visit func(blueprint.Module))
- WalkDeps(visit func(blueprint.Module, blueprint.Module) bool)
+ VisitDirectDeps(visit func(Module))
+ VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
+ VisitDepsDepthFirst(visit func(Module))
+ VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
+ WalkDeps(visit func(Module, Module) bool)
Variable(pctx blueprint.PackageContext, name, value string)
Rule(pctx blueprint.PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
@@ -663,9 +663,89 @@ func (a *androidModuleContext) GetMissingDependencies() []string {
func (a *androidModuleContext) AddMissingDependencies(deps []string) {
if deps != nil {
a.missingDeps = append(a.missingDeps, deps...)
+ a.missingDeps = FirstUniqueStrings(a.missingDeps)
}
}
+func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Module {
+ aModule, _ := module.(Module)
+ if aModule == nil {
+ a.ModuleErrorf("module %q not an android module", a.OtherModuleName(aModule))
+ return nil
+ }
+
+ if !aModule.Enabled() {
+ if a.AConfig().AllowMissingDependencies() {
+ a.AddMissingDependencies([]string{a.OtherModuleName(aModule)})
+ } else {
+ a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule))
+ }
+ return nil
+ }
+
+ return aModule
+}
+
+func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
+ a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
+ if aModule := a.validateAndroidModule(module); aModule != nil {
+ visit(aModule)
+ }
+ })
+}
+
+func (a *androidModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
+ a.ModuleContext.VisitDirectDepsIf(
+ // pred
+ func(module blueprint.Module) bool {
+ if aModule := a.validateAndroidModule(module); aModule != nil {
+ return pred(aModule)
+ } else {
+ return false
+ }
+ },
+ // visit
+ func(module blueprint.Module) {
+ visit(module.(Module))
+ })
+}
+
+func (a *androidModuleContext) VisitDepsDepthFirst(visit func(Module)) {
+ a.ModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
+ if aModule := a.validateAndroidModule(module); aModule != nil {
+ visit(aModule)
+ }
+ })
+}
+
+func (a *androidModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
+ a.ModuleContext.VisitDepsDepthFirstIf(
+ // pred
+ func(module blueprint.Module) bool {
+ if aModule := a.validateAndroidModule(module); aModule != nil {
+ return pred(aModule)
+ } else {
+ return false
+ }
+ },
+ // visit
+ func(module blueprint.Module) {
+ visit(module.(Module))
+ })
+}
+
+func (a *androidModuleContext) WalkDeps(visit func(Module, Module) bool) {
+ a.ModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
+ childAndroidModule := a.validateAndroidModule(child)
+ parentAndroidModule := a.validateAndroidModule(parent)
+ if childAndroidModule != nil && parentAndroidModule != nil {
+ return visit(childAndroidModule, parentAndroidModule)
+ } else {
+ return false
+ }
+ })
+}
+
func (a *androidBaseContextImpl) Target() Target {
return a.target
}
diff --git a/android/mutator.go b/android/mutator.go
index b485940e..afff7001 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -123,11 +123,11 @@ type TopDownMutatorContext interface {
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
- VisitDirectDeps(visit func(blueprint.Module))
- VisitDirectDepsIf(pred func(blueprint.Module) bool, visit func(blueprint.Module))
- VisitDepsDepthFirst(visit func(blueprint.Module))
- VisitDepsDepthFirstIf(pred func(blueprint.Module) bool, visit func(blueprint.Module))
- WalkDeps(visit func(blueprint.Module, blueprint.Module) bool)
+ VisitDirectDeps(visit func(Module))
+ VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
+ VisitDepsDepthFirst(visit func(Module))
+ VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
+ WalkDeps(visit func(Module, Module) bool)
}
type androidTopDownMutatorContext struct {
@@ -191,3 +191,63 @@ func depsMutator(ctx BottomUpMutatorContext) {
m.DepsMutator(ctx)
}
}
+
+func (a *androidTopDownMutatorContext) VisitDirectDeps(visit func(Module)) {
+ a.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) {
+ if aModule, _ := module.(Module); aModule != nil {
+ visit(aModule)
+ }
+ })
+}
+
+func (a *androidTopDownMutatorContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
+ a.TopDownMutatorContext.VisitDirectDepsIf(
+ // pred
+ func(module blueprint.Module) bool {
+ if aModule, _ := module.(Module); aModule != nil {
+ return pred(aModule)
+ } else {
+ return false
+ }
+ },
+ // visit
+ func(module blueprint.Module) {
+ visit(module.(Module))
+ })
+}
+
+func (a *androidTopDownMutatorContext) VisitDepsDepthFirst(visit func(Module)) {
+ a.TopDownMutatorContext.VisitDepsDepthFirst(func(module blueprint.Module) {
+ if aModule, _ := module.(Module); aModule != nil {
+ visit(aModule)
+ }
+ })
+}
+
+func (a *androidTopDownMutatorContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
+ a.TopDownMutatorContext.VisitDepsDepthFirstIf(
+ // pred
+ func(module blueprint.Module) bool {
+ if aModule, _ := module.(Module); aModule != nil {
+ return pred(aModule)
+ } else {
+ return false
+ }
+ },
+ // visit
+ func(module blueprint.Module) {
+ visit(module.(Module))
+ })
+}
+
+func (a *androidTopDownMutatorContext) WalkDeps(visit func(Module, Module) bool) {
+ a.TopDownMutatorContext.WalkDeps(func(child, parent blueprint.Module) bool {
+ childAndroidModule, _ := child.(Module)
+ parentAndroidModule, _ := parent.(Module)
+ if childAndroidModule != nil && parentAndroidModule != nil {
+ return visit(childAndroidModule, parentAndroidModule)
+ } else {
+ return false
+ }
+ })
+}
diff --git a/android/prebuilt.go b/android/prebuilt.go
index f61a0dd8..f29f8658 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -109,7 +109,7 @@ func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) {
p.properties.UsePrebuilt = p.usePrebuilt(ctx, nil)
}
} else if s, ok := ctx.Module().(Module); ok {
- ctx.VisitDirectDeps(func(m blueprint.Module) {
+ ctx.VisitDirectDeps(func(m Module) {
if ctx.OtherModuleDependencyTag(m) == prebuiltDepTag {
p := m.(PrebuiltInterface).Prebuilt()
if p.usePrebuilt(ctx, s) {
diff --git a/cc/cc.go b/cc/cc.go
index 36b97e11..b423ca6e 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1037,16 +1037,10 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
directStaticDeps := []*Module{}
- ctx.VisitDirectDeps(func(dep blueprint.Module) {
+ ctx.VisitDirectDeps(func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
depTag := ctx.OtherModuleDependencyTag(dep)
- aDep, _ := dep.(android.Module)
- if aDep == nil {
- ctx.ModuleErrorf("module %q not an android module", depName)
- return
- }
-
ccDep, _ := dep.(*Module)
if ccDep == nil {
// handling for a few module types that aren't cc Module but that are also supported
@@ -1096,20 +1090,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return
}
- // some validation
- if !aDep.Enabled() {
- if ctx.AConfig().AllowMissingDependencies() {
- ctx.AddMissingDependencies([]string{depName})
- } else {
- ctx.ModuleErrorf("depends on disabled module %q", depName)
- }
- return
- }
- if aDep.Target().Os != ctx.Os() {
+ if dep.Target().Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
return
}
- if aDep.Target().Arch.ArchType != ctx.Arch().ArchType {
+ if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
return
}
diff --git a/cc/coverage.go b/cc/coverage.go
index 0b4188f7..d2eede28 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -16,8 +16,6 @@ package cc
import (
"android/soong/android"
-
- "github.com/google/blueprint"
)
type CoverageProperties struct {
@@ -61,7 +59,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags {
// For static libraries, the only thing that changes our object files
// are included whole static libraries, so check to see if any of
// those have coverage enabled.
- ctx.VisitDirectDeps(func(m blueprint.Module) {
+ ctx.VisitDirectDeps(func(m android.Module) {
if ctx.OtherModuleDependencyTag(m) != wholeStaticDepTag {
return
}
@@ -75,7 +73,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags {
} else {
// For executables and shared libraries, we need to check all of
// our static dependencies.
- ctx.VisitDirectDeps(func(m blueprint.Module) {
+ ctx.VisitDirectDeps(func(m android.Module) {
cc, ok := m.(*Module)
if !ok || cc.coverage == nil {
return
diff --git a/cc/lto.go b/cc/lto.go
index 6a5ecdee..fdb76883 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -15,8 +15,6 @@
package cc
import (
- "github.com/google/blueprint"
-
"android/soong/android"
)
@@ -104,7 +102,7 @@ func ltoDepsMutator(mctx android.TopDownMutatorContext) {
mctx.PropertyErrorf("LTO", "FullLTO and ThinLTO are mutually exclusive")
}
- mctx.VisitDepsDepthFirst(func(m blueprint.Module) {
+ mctx.VisitDepsDepthFirst(func(m android.Module) {
tag := mctx.OtherModuleDependencyTag(m)
switch tag {
case staticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag, objDepTag, reuseObjTag:
diff --git a/cc/sabi.go b/cc/sabi.go
index 8086f5b6..ec1d2468 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -17,8 +17,6 @@ package cc
import (
"strings"
- "github.com/google/blueprint"
-
"android/soong/android"
"android/soong/cc/config"
)
@@ -81,7 +79,7 @@ func sabiDepsMutator(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok &&
((c.isVndk() && c.useVndk()) || inList(c.Name(), llndkLibraries) ||
(c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) {
- mctx.VisitDirectDeps(func(m blueprint.Module) {
+ mctx.VisitDirectDeps(func(m android.Module) {
tag := mctx.OtherModuleDependencyTag(m)
switch tag {
case staticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag:
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 74f4bdbb..d5535cb6 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -19,8 +19,6 @@ import (
"io"
"strings"
- "github.com/google/blueprint"
-
"android/soong/android"
"android/soong/cc/config"
)
@@ -493,7 +491,7 @@ func (sanitize *sanitize) SetSanitizer(t sanitizerType, b bool) {
func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) {
return func(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize.Sanitizer(t) {
- mctx.VisitDepsDepthFirst(func(module blueprint.Module) {
+ mctx.VisitDepsDepthFirst(func(module android.Module) {
if d, ok := mctx.Module().(*Module); ok && c.sanitize != nil &&
!c.sanitize.Properties.Sanitize.Never {
d.sanitize.Properties.SanitizeDep = true
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 9fcc4039..03e10ba4 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -157,7 +157,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
tools := map[string]android.Path{}
if len(g.properties.Tools) > 0 {
- ctx.VisitDirectDeps(func(module blueprint.Module) {
+ ctx.VisitDirectDeps(func(module android.Module) {
switch ctx.OtherModuleDependencyTag(module) {
case android.SourceDepTag:
// Nothing to do
diff --git a/java/app.go b/java/app.go
index 42ae2366..e8028a0d 100644
--- a/java/app.go
+++ b/java/app.go
@@ -20,7 +20,6 @@ import (
"path/filepath"
"strings"
- "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -231,7 +230,7 @@ func (a *AndroidApp) aaptFlags(ctx android.ModuleContext) ([]string, android.Pat
aaptFlags = append(aaptFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A "))
aaptFlags = append(aaptFlags, android.JoinWithPrefix(resourceDirs.Strings(), "-S "))
- ctx.VisitDirectDeps(func(module blueprint.Module) {
+ ctx.VisitDirectDeps(func(module android.Module) {
var depFiles android.Paths
if javaDep, ok := module.(Dependency); ok {
if ctx.OtherModuleName(module) == "framework-res" {
diff --git a/java/java.go b/java/java.go
index c12ada27..26514f33 100644
--- a/java/java.go
+++ b/java/java.go
@@ -406,25 +406,10 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
}
- ctx.VisitDirectDeps(func(module blueprint.Module) {
+ ctx.VisitDirectDeps(func(module android.Module) {
otherName := ctx.OtherModuleName(module)
tag := ctx.OtherModuleDependencyTag(module)
- aDep, _ := module.(android.Module)
- if aDep == nil {
- ctx.ModuleErrorf("module %q not an android module", ctx.OtherModuleName(aDep))
- return
- }
-
- if !aDep.Enabled() {
- if ctx.AConfig().AllowMissingDependencies() {
- ctx.AddMissingDependencies([]string{ctx.OtherModuleName(aDep)})
- } else {
- ctx.ModuleErrorf("depends on disabled module %q", ctx.OtherModuleName(aDep))
- }
- return
- }
-
dep, _ := module.(Dependency)
if dep == nil {
switch tag {
diff --git a/java/system_modules.go b/java/system_modules.go
index f6f572b6..a459b7a0 100644
--- a/java/system_modules.go
+++ b/java/system_modules.go
@@ -112,7 +112,7 @@ type SystemModulesProperties struct {
func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) {
var jars android.Paths
- ctx.VisitDirectDeps(func(module blueprint.Module) {
+ ctx.VisitDirectDeps(func(module android.Module) {
if ctx.OtherModuleDependencyTag(module) == libTag {
dep, _ := module.(Dependency)
jars = append(jars, dep.HeaderJars()...)
diff --git a/python/binary.go b/python/binary.go
index b7b50561..c2e38bf3 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -21,8 +21,6 @@ import (
"path/filepath"
"strings"
- "github.com/google/blueprint"
-
"android/soong/android"
)
@@ -135,7 +133,7 @@ func (binary *binaryDecorator) bootstrap(ctx android.ModuleContext, actual_versi
var launcher_path android.Path
if embedded_launcher {
- ctx.VisitDirectDeps(func(m blueprint.Module) {
+ ctx.VisitDirectDeps(func(m android.Module) {
if ctx.OtherModuleDependencyTag(m) != launcherTag {
return
}
diff --git a/python/python.go b/python/python.go
index e63c26c4..1b146a8e 100644
--- a/python/python.go
+++ b/python/python.go
@@ -508,7 +508,7 @@ func (p *Module) uniqWholeRunfilesTree(ctx android.ModuleContext) {
}
// visit all its dependencies in depth first.
- ctx.VisitDepsDepthFirst(func(module blueprint.Module) {
+ ctx.VisitDepsDepthFirst(func(module android.Module) {
if ctx.OtherModuleDependencyTag(module) != pythonLibTag {
return
}