Merge "Add VisitDirectDepsIgnoreBlueprint" into main am: d19b214fa1
am: b242ed2eee
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2920271 Change-Id: Iffc947d8b3db558fa84c835ec269ee04caccaf90 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -49,13 +49,7 @@ func CollectDependencyAconfigFiles(ctx ModuleContext, mergedAconfigFiles *map[st
|
|||||||
if *mergedAconfigFiles == nil {
|
if *mergedAconfigFiles == nil {
|
||||||
*mergedAconfigFiles = make(map[string]Paths)
|
*mergedAconfigFiles = make(map[string]Paths)
|
||||||
}
|
}
|
||||||
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
ctx.VisitDirectDepsIgnoreBlueprint(func(module Module) {
|
||||||
// Walk our direct dependencies, ignoring blueprint Modules and disabled Android Modules.
|
|
||||||
aModule, _ := module.(Module)
|
|
||||||
if aModule == nil || !aModule.Enabled() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if dep, _ := OtherModuleProvider(ctx, module, AconfigDeclarationsProviderKey); dep.IntermediateCacheOutputPath != nil {
|
if dep, _ := OtherModuleProvider(ctx, module, AconfigDeclarationsProviderKey); dep.IntermediateCacheOutputPath != nil {
|
||||||
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath)
|
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath)
|
||||||
return
|
return
|
||||||
|
@@ -105,7 +105,7 @@ type BaseModuleContext interface {
|
|||||||
// dependencies that are not an android.Module.
|
// dependencies that are not an android.Module.
|
||||||
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
|
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
|
||||||
|
|
||||||
// GetDirectDep returns the Module and DependencyTag for the direct dependency with the specified
|
// GetDirectDep returns the Module and DependencyTag for the direct dependency with the specified
|
||||||
// name, or nil if none exists. If there are multiple dependencies on the same module it returns
|
// name, or nil if none exists. If there are multiple dependencies on the same module it returns
|
||||||
// the first DependencyTag.
|
// the first DependencyTag.
|
||||||
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
||||||
@@ -118,6 +118,15 @@ type BaseModuleContext interface {
|
|||||||
// function, it may be invalidated by future mutators.
|
// function, it may be invalidated by future mutators.
|
||||||
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
||||||
|
|
||||||
|
// VisitDirectDepsIgnoreBlueprint calls visit for each direct dependency. If there are multiple
|
||||||
|
// direct dependencies on the same module visit will be called multiple times on that module
|
||||||
|
// and OtherModuleDependencyTag will return a different tag for each. It silently ignores any
|
||||||
|
// dependencies that are not an android.Module.
|
||||||
|
//
|
||||||
|
// The Module passed to the visit function should not be retained outside of the visit
|
||||||
|
// function, it may be invalidated by future mutators.
|
||||||
|
VisitDirectDepsIgnoreBlueprint(visit func(Module))
|
||||||
|
|
||||||
// VisitDirectDeps calls visit for each direct dependency. If there are multiple
|
// VisitDirectDeps calls visit for each direct dependency. If there are multiple
|
||||||
// direct dependencies on the same module visit will be called multiple times on that module
|
// direct dependencies on the same module visit will be called multiple times on that module
|
||||||
// and OtherModuleDependencyTag will return a different tag for each. It raises an error if any of the
|
// and OtherModuleDependencyTag will return a different tag for each. It raises an error if any of the
|
||||||
@@ -306,7 +315,7 @@ type AllowDisabledModuleDependency interface {
|
|||||||
AllowDisabledModuleDependency(target Module) bool
|
AllowDisabledModuleDependency(target Module) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag blueprint.DependencyTag, strict bool) Module {
|
func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag blueprint.DependencyTag, strict bool, ignoreBlueprint bool) Module {
|
||||||
aModule, _ := module.(Module)
|
aModule, _ := module.(Module)
|
||||||
|
|
||||||
if !strict {
|
if !strict {
|
||||||
@@ -314,7 +323,9 @@ func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag b
|
|||||||
}
|
}
|
||||||
|
|
||||||
if aModule == nil {
|
if aModule == nil {
|
||||||
b.ModuleErrorf("module %q (%#v) not an android module", b.OtherModuleName(module), tag)
|
if !ignoreBlueprint {
|
||||||
|
b.ModuleErrorf("module %q (%#v) not an android module", b.OtherModuleName(module), tag)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,8 +422,16 @@ func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
||||||
|
b.visitDirectDeps(visit, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *baseModuleContext) VisitDirectDepsIgnoreBlueprint(visit func(Module)) {
|
||||||
|
b.visitDirectDeps(visit, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *baseModuleContext) visitDirectDeps(visit func(Module), ignoreBlueprint bool) {
|
||||||
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
||||||
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps, ignoreBlueprint); aModule != nil {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -421,7 +440,7 @@ func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
|||||||
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
||||||
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
||||||
if b.bp.OtherModuleDependencyTag(module) == tag {
|
if b.bp.OtherModuleDependencyTag(module) == tag {
|
||||||
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps, false); aModule != nil {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,7 +451,7 @@ func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func
|
|||||||
b.bp.VisitDirectDepsIf(
|
b.bp.VisitDirectDepsIf(
|
||||||
// pred
|
// pred
|
||||||
func(module blueprint.Module) bool {
|
func(module blueprint.Module) bool {
|
||||||
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps, false); aModule != nil {
|
||||||
return pred(aModule)
|
return pred(aModule)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@@ -446,7 +465,7 @@ func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func
|
|||||||
|
|
||||||
func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
||||||
b.bp.VisitDepsDepthFirst(func(module blueprint.Module) {
|
b.bp.VisitDepsDepthFirst(func(module blueprint.Module) {
|
||||||
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps, false); aModule != nil {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -456,7 +475,7 @@ func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit
|
|||||||
b.bp.VisitDepsDepthFirstIf(
|
b.bp.VisitDepsDepthFirstIf(
|
||||||
// pred
|
// pred
|
||||||
func(module blueprint.Module) bool {
|
func(module blueprint.Module) bool {
|
||||||
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps, false); aModule != nil {
|
||||||
return pred(aModule)
|
return pred(aModule)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
@@ -1692,7 +1692,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||||||
// ensure all direct android.Module deps are enabled
|
// ensure all direct android.Module deps are enabled
|
||||||
ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) {
|
ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) {
|
||||||
if m, ok := bm.(Module); ok {
|
if m, ok := bm.(Module); ok {
|
||||||
ctx.validateAndroidModule(bm, ctx.OtherModuleDependencyTag(m), ctx.baseModuleContext.strictVisitDeps)
|
ctx.validateAndroidModule(bm, ctx.OtherModuleDependencyTag(m), ctx.baseModuleContext.strictVisitDeps, false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user