Change GetModuleFromPathDep to use ModuleProxy.
Bug: 377723687
Test: Compare ninja and mk files generated.
Change-Id: I428b0965b217adb20a792ebde88374e0c6fae9d6
diff --git a/android/base_module_context.go b/android/base_module_context.go
index 060fae5..719d6d5 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -113,7 +113,7 @@
// GetDirectDepWithTag returns the Module the direct dependency with the specified name, or nil if
// none exists. It panics if the dependency does not have the specified tag. It skips any
// dependencies that are not an android.Module.
- GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
+ GetDirectDepWithTag(name string, tag blueprint.DependencyTag) Module
// 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
@@ -129,13 +129,14 @@
// function, it may be invalidated by future mutators.
VisitDirectDeps(visit func(Module))
- // VisitDirectDeps calls visit for each direct dependency. If there are multiple
+ // VisitDirectDepsProxy 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.
+ // and OtherModuleDependencyTag will return a different tag for each. It raises an error if any of the
+ // dependencies are disabled.
//
- // The Module passed to the visit function should not be retained outside of the visit
+ // The ModuleProxy passed to the visit function should not be retained outside of the visit
// function, it may be invalidated by future mutators.
- VisitDirectDepsAllowDisabled(visit func(Module))
+ VisitDirectDepsProxy(visit func(proxy ModuleProxy))
// VisitDirectDepsProxyAllowDisabled calls visit for each direct dependency. If there are
// multiple direct dependencies on the same module visit will be called multiple times on
@@ -261,7 +262,9 @@
func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string {
return b.bp.OtherModuleName(getWrappedModule(m))
}
-func (b *baseModuleContext) OtherModuleDir(m blueprint.Module) string { return b.bp.OtherModuleDir(m) }
+func (b *baseModuleContext) OtherModuleDir(m blueprint.Module) string {
+ return b.bp.OtherModuleDir(getWrappedModule(m))
+}
func (b *baseModuleContext) OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) {
b.bp.OtherModuleErrorf(m, fmt, args...)
}
@@ -298,8 +301,11 @@
b.bp.SetProvider(provider, value)
}
-func (b *baseModuleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
- return b.bp.GetDirectDepWithTag(name, tag)
+func (b *baseModuleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) Module {
+ if module := b.bp.GetDirectDepWithTag(name, tag); module != nil {
+ return module.(Module)
+ }
+ return nil
}
func (b *baseModuleContext) blueprintBaseModuleContext() blueprint.BaseModuleContext {
@@ -464,18 +470,16 @@
})
}
-func (b *baseModuleContext) VisitDirectDepsAllowDisabled(visit func(Module)) {
- b.bp.VisitDirectDeps(func(module blueprint.Module) {
- visit(module.(Module))
+func (b *baseModuleContext) VisitDirectDepsProxy(visit func(ModuleProxy)) {
+ b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) {
+ if aModule := b.validateAndroidModuleProxy(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
+ visit(*aModule)
+ }
})
}
func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy)) {
- b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) {
- visit(ModuleProxy{
- module: module,
- })
- })
+ b.bp.VisitDirectDepsProxy(visitProxyAdaptor(visit))
}
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {