aboutsummaryrefslogtreecommitdiff
path: root/android/provider.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/provider.go')
-rw-r--r--android/provider.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/android/provider.go b/android/provider.go
index aae93ef88..85fc08c0c 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -7,7 +7,7 @@ import (
// OtherModuleProviderContext is a helper interface that is a subset of ModuleContext or BottomUpMutatorContext
// for use in OtherModuleProvider.
type OtherModuleProviderContext interface {
- otherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
+ otherModuleProvider(m ModuleOrProxy, provider blueprint.AnyProviderKey) (any, bool)
}
var _ OtherModuleProviderContext = BaseModuleContext(nil)
@@ -22,13 +22,14 @@ type ConfigAndOtherModuleProviderContext interface {
ConfigContext
}
-// OtherModuleProvider reads the provider for the given module. If the provider has been set the value is
-// returned and the boolean is true. If it has not been set the zero value of the provider's type is returned
-// and the boolean is false. The value returned may be a deep copy of the value originally passed to SetProvider.
+// OtherModuleProvider reads the provider for the given module. If the provider has been set the
+// value is returned and the boolean is true. If it has not been set or the module is nil, the zero
+// value of the provider's type is returned and the boolean is false. The value returned may be a
+// deep copy of the value originally passed to SetProvider.
//
// OtherModuleProviderContext is a helper interface that accepts ModuleContext or BottomUpMutatorContext.
-func OtherModuleProvider[K any](ctx OtherModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) (K, bool) {
- value, ok := ctx.otherModuleProvider(getWrappedModule(module), provider)
+func OtherModuleProvider[K any](ctx OtherModuleProviderContext, module ModuleOrProxy, provider blueprint.ProviderKey[K]) (K, bool) {
+ value, ok := ctx.otherModuleProvider(module, provider)
if !ok {
var k K
return k, false
@@ -36,12 +37,12 @@ func OtherModuleProvider[K any](ctx OtherModuleProviderContext, module blueprint
return value.(K), ok
}
-func OtherModuleProviderOrDefault[K any](ctx OtherModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) K {
+func OtherModuleProviderOrDefault[K any](ctx OtherModuleProviderContext, module ModuleOrProxy, provider blueprint.ProviderKey[K]) K {
value, _ := OtherModuleProvider(ctx, module, provider)
return value
}
-func OtherModulePointerProviderOrDefault[K *T, T any](ctx OtherModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) K {
+func OtherModulePointerProviderOrDefault[K *T, T any](ctx OtherModuleProviderContext, module ModuleOrProxy, provider blueprint.ProviderKey[K]) K {
if value, ok := OtherModuleProvider(ctx, module, provider); ok {
return value
}
@@ -97,13 +98,13 @@ var _ OtherModuleProviderContext = (*otherModuleProviderAdaptor)(nil)
// An OtherModuleProviderFunc can be passed to NewOtherModuleProviderAdaptor to create an OtherModuleProviderContext
// for use in tests.
-type OtherModuleProviderFunc func(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
+type OtherModuleProviderFunc func(module ModuleOrProxy, provider blueprint.AnyProviderKey) (any, bool)
type otherModuleProviderAdaptor struct {
otherModuleProviderFunc OtherModuleProviderFunc
}
-func (p *otherModuleProviderAdaptor) otherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
+func (p *otherModuleProviderAdaptor) otherModuleProvider(module ModuleOrProxy, provider blueprint.AnyProviderKey) (any, bool) {
return p.otherModuleProviderFunc(module, provider)
}