Add VisitDirectDepsWithTag
Add a method on ModuleContext and TopDownMutatorContext to visit direct dependencies that have a given dependency tag. Test: m checkbuild Change-Id: Ib875563091dcae6b7282b3e3427d0eb07d8c8af5
This commit is contained in:
@@ -139,6 +139,7 @@ type ModuleContext interface {
|
|||||||
|
|
||||||
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
||||||
VisitDirectDeps(visit func(Module))
|
VisitDirectDeps(visit func(Module))
|
||||||
|
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
|
||||||
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
||||||
VisitDepsDepthFirst(visit func(Module))
|
VisitDepsDepthFirst(visit func(Module))
|
||||||
VisitDepsDepthFirstIf(pred func(Module) bool, 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)) {
|
func (a *androidModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
||||||
a.ModuleContext.VisitDirectDepsIf(
|
a.ModuleContext.VisitDirectDepsIf(
|
||||||
// pred
|
// pred
|
||||||
|
@@ -127,6 +127,7 @@ type TopDownMutatorContext interface {
|
|||||||
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
||||||
|
|
||||||
VisitDirectDeps(visit func(Module))
|
VisitDirectDeps(visit func(Module))
|
||||||
|
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
|
||||||
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
||||||
VisitDepsDepthFirst(visit func(Module))
|
VisitDepsDepthFirst(visit func(Module))
|
||||||
VisitDepsDepthFirstIf(pred func(Module) bool, 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)) {
|
func (a *androidTopDownMutatorContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
||||||
a.TopDownMutatorContext.VisitDirectDepsIf(
|
a.TopDownMutatorContext.VisitDirectDepsIf(
|
||||||
// pred
|
// pred
|
||||||
|
@@ -109,13 +109,11 @@ func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) {
|
|||||||
p.properties.UsePrebuilt = p.usePrebuilt(ctx, nil)
|
p.properties.UsePrebuilt = p.usePrebuilt(ctx, nil)
|
||||||
}
|
}
|
||||||
} else if s, ok := ctx.Module().(Module); ok {
|
} else if s, ok := ctx.Module().(Module); ok {
|
||||||
ctx.VisitDirectDeps(func(m Module) {
|
ctx.VisitDirectDepsWithTag(prebuiltDepTag, func(m Module) {
|
||||||
if ctx.OtherModuleDependencyTag(m) == prebuiltDepTag {
|
p := m.(PrebuiltInterface).Prebuilt()
|
||||||
p := m.(PrebuiltInterface).Prebuilt()
|
if p.usePrebuilt(ctx, s) {
|
||||||
if p.usePrebuilt(ctx, s) {
|
p.properties.UsePrebuilt = true
|
||||||
p.properties.UsePrebuilt = true
|
s.SkipInstall()
|
||||||
s.SkipInstall()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -59,11 +59,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags {
|
|||||||
// For static libraries, the only thing that changes our object files
|
// For static libraries, the only thing that changes our object files
|
||||||
// are included whole static libraries, so check to see if any of
|
// are included whole static libraries, so check to see if any of
|
||||||
// those have coverage enabled.
|
// those have coverage enabled.
|
||||||
ctx.VisitDirectDeps(func(m android.Module) {
|
ctx.VisitDirectDepsWithTag(wholeStaticDepTag, func(m android.Module) {
|
||||||
if ctx.OtherModuleDependencyTag(m) != wholeStaticDepTag {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if cc, ok := m.(*Module); ok && cc.coverage != nil {
|
if cc, ok := m.(*Module); ok && cc.coverage != nil {
|
||||||
if cc.coverage.linkCoverage {
|
if cc.coverage.linkCoverage {
|
||||||
cov.linkCoverage = true
|
cov.linkCoverage = true
|
||||||
|
@@ -112,11 +112,9 @@ type SystemModulesProperties struct {
|
|||||||
func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
var jars android.Paths
|
var jars android.Paths
|
||||||
|
|
||||||
ctx.VisitDirectDeps(func(module android.Module) {
|
ctx.VisitDirectDepsWithTag(libTag, func(module android.Module) {
|
||||||
if ctx.OtherModuleDependencyTag(module) == libTag {
|
dep, _ := module.(Dependency)
|
||||||
dep, _ := module.(Dependency)
|
jars = append(jars, dep.HeaderJars()...)
|
||||||
jars = append(jars, dep.HeaderJars()...)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
jars = append(jars, android.PathsForModuleSrc(ctx, system.properties.Jars)...)
|
jars = append(jars, android.PathsForModuleSrc(ctx, system.properties.Jars)...)
|
||||||
|
@@ -133,10 +133,7 @@ func (binary *binaryDecorator) bootstrap(ctx android.ModuleContext, actual_versi
|
|||||||
|
|
||||||
var launcher_path android.Path
|
var launcher_path android.Path
|
||||||
if embedded_launcher {
|
if embedded_launcher {
|
||||||
ctx.VisitDirectDeps(func(m android.Module) {
|
ctx.VisitDirectDepsWithTag(launcherTag, func(m android.Module) {
|
||||||
if ctx.OtherModuleDependencyTag(m) != launcherTag {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if provider, ok := m.(IntermPathProvider); ok {
|
if provider, ok := m.(IntermPathProvider); ok {
|
||||||
if launcher_path != nil {
|
if launcher_path != nil {
|
||||||
panic(fmt.Errorf("launcher path was found before: %q",
|
panic(fmt.Errorf("launcher path was found before: %q",
|
||||||
|
Reference in New Issue
Block a user