Convert Visit*Deps from blueprint.Module to android.Module
Also adds checks that the dependencies are android.Modules and are not disabled. Test: m checkbuild Change-Id: I05e945f38915d49cd3c0ab72a86576949bc7eff2
This commit is contained in:
parent
b671544973
commit
d11fcda940
15 changed files with 166 additions and 67 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
21
cc/cc.go
21
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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" {
|
||||
|
|
17
java/java.go
17
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 {
|
||||
|
|
|
@ -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()...)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue