diff --git a/android/module.go b/android/module.go index cb068abba..0fb947963 100644 --- a/android/module.go +++ b/android/module.go @@ -139,6 +139,7 @@ type ModuleContext interface { VisitDirectDepsBlueprint(visit func(blueprint.Module)) VisitDirectDeps(visit func(Module)) + VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) VisitDepsDepthFirst(visit func(Module)) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) @@ -831,6 +832,16 @@ func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) { }) } +func (a *androidModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) { + a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) { + if aModule := a.validateAndroidModule(module); aModule != nil { + if a.ModuleContext.OtherModuleDependencyTag(aModule) == tag { + visit(aModule) + } + } + }) +} + func (a *androidModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) { a.ModuleContext.VisitDirectDepsIf( // pred diff --git a/android/mutator.go b/android/mutator.go index 8de57e1b6..2f13f6caf 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -127,6 +127,7 @@ type TopDownMutatorContext interface { GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) VisitDirectDeps(visit func(Module)) + VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) VisitDepsDepthFirst(visit func(Module)) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) @@ -230,6 +231,16 @@ func (a *androidTopDownMutatorContext) VisitDirectDeps(visit func(Module)) { }) } +func (a *androidTopDownMutatorContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) { + a.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) { + if aModule, _ := module.(Module); aModule != nil { + if a.TopDownMutatorContext.OtherModuleDependencyTag(aModule) == tag { + visit(aModule) + } + } + }) +} + func (a *androidTopDownMutatorContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) { a.TopDownMutatorContext.VisitDirectDepsIf( // pred diff --git a/android/prebuilt.go b/android/prebuilt.go index d3f970416..9356aabb9 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -109,13 +109,11 @@ func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) { p.properties.UsePrebuilt = p.usePrebuilt(ctx, nil) } } else if s, ok := ctx.Module().(Module); ok { - ctx.VisitDirectDeps(func(m Module) { - if ctx.OtherModuleDependencyTag(m) == prebuiltDepTag { - p := m.(PrebuiltInterface).Prebuilt() - if p.usePrebuilt(ctx, s) { - p.properties.UsePrebuilt = true - s.SkipInstall() - } + ctx.VisitDirectDepsWithTag(prebuiltDepTag, func(m Module) { + p := m.(PrebuiltInterface).Prebuilt() + if p.usePrebuilt(ctx, s) { + p.properties.UsePrebuilt = true + s.SkipInstall() } }) } diff --git a/cc/coverage.go b/cc/coverage.go index d2eede286..391b11812 100644 --- a/cc/coverage.go +++ b/cc/coverage.go @@ -59,11 +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 android.Module) { - if ctx.OtherModuleDependencyTag(m) != wholeStaticDepTag { - return - } - + ctx.VisitDirectDepsWithTag(wholeStaticDepTag, func(m android.Module) { if cc, ok := m.(*Module); ok && cc.coverage != nil { if cc.coverage.linkCoverage { cov.linkCoverage = true diff --git a/java/system_modules.go b/java/system_modules.go index 5234d174f..196d041c8 100644 --- a/java/system_modules.go +++ b/java/system_modules.go @@ -112,11 +112,9 @@ type SystemModulesProperties struct { func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) { var jars android.Paths - ctx.VisitDirectDeps(func(module android.Module) { - if ctx.OtherModuleDependencyTag(module) == libTag { - dep, _ := module.(Dependency) - jars = append(jars, dep.HeaderJars()...) - } + ctx.VisitDirectDepsWithTag(libTag, func(module android.Module) { + dep, _ := module.(Dependency) + jars = append(jars, dep.HeaderJars()...) }) jars = append(jars, android.PathsForModuleSrc(ctx, system.properties.Jars)...) diff --git a/python/binary.go b/python/binary.go index 457c7fa0a..0314edb8c 100644 --- a/python/binary.go +++ b/python/binary.go @@ -133,10 +133,7 @@ func (binary *binaryDecorator) bootstrap(ctx android.ModuleContext, actual_versi var launcher_path android.Path if embedded_launcher { - ctx.VisitDirectDeps(func(m android.Module) { - if ctx.OtherModuleDependencyTag(m) != launcherTag { - return - } + ctx.VisitDirectDepsWithTag(launcherTag, func(m android.Module) { if provider, ok := m.(IntermPathProvider); ok { if launcher_path != nil { panic(fmt.Errorf("launcher path was found before: %q",