Fix genrules depending on Go tools

genrules lost the ability to depend on Go tools after
I05e945f38915d49cd3c0ab72a86576949bc7eff2 which converted
VisitDirectDeps from blueprint Modules to android Modules.
Add VisitDirectDepsBlueprint to visit all modules including
blueprint Modules, and use it in genrule.  Also add a check
for disabled modules that was being handled by
VisitDirectDeps.

Test: m checkbuild
Change-Id: I65724283166c63596d071e598c08fed87ef32896
This commit is contained in:
Colin Cross 2017-11-16 00:11:20 -08:00
parent b1bd1aabca
commit 35143d0466
2 changed files with 14 additions and 1 deletions

View file

@ -108,6 +108,7 @@ type ModuleContext interface {
ModuleSubDir() string
VisitDirectDepsBlueprint(visit func(blueprint.Module))
VisitDirectDeps(visit func(Module))
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
VisitDepsDepthFirst(visit func(Module))
@ -686,6 +687,10 @@ func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Mo
return aModule
}
func (a *androidModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
a.ModuleContext.VisitDirectDeps(visit)
}
func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
if aModule := a.validateAndroidModule(module); aModule != nil {

View file

@ -158,7 +158,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
tools := map[string]android.Path{}
if len(g.properties.Tools) > 0 {
ctx.VisitDirectDeps(func(module android.Module) {
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
switch ctx.OtherModuleDependencyTag(module) {
case android.SourceDepTag:
// Nothing to do
@ -167,6 +167,14 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
var path android.OptionalPath
if t, ok := module.(HostToolProvider); ok {
if !t.(android.Module).Enabled() {
if ctx.AConfig().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{tool})
} else {
ctx.ModuleErrorf("depends on disabled module %q", tool)
}
break
}
path = t.HostToolPath()
} else if t, ok := module.(bootstrap.GoBinaryTool); ok {
if s, err := filepath.Rel(android.PathForOutput(ctx).String(), t.InstallPath()); err == nil {