From 35143d0466461f5d83dfc7aeda53b36a274f8cc8 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 16 Nov 2017 00:11:20 -0800 Subject: [PATCH] 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 --- android/module.go | 5 +++++ genrule/genrule.go | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/android/module.go b/android/module.go index 2a8837b32..66859fa56 100644 --- a/android/module.go +++ b/android/module.go @@ -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 { diff --git a/genrule/genrule.go b/genrule/genrule.go index c5b7e1d34..c142c53e0 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -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 {