summaryrefslogtreecommitdiff
path: root/android/provider.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/provider.go')
-rw-r--r--android/provider.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/android/provider.go b/android/provider.go
index b48fd9148..aae93ef88 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -16,6 +16,12 @@ var _ OtherModuleProviderContext = BottomUpMutatorContext(nil)
var _ OtherModuleProviderContext = SingletonContext(nil)
var _ OtherModuleProviderContext = (*TestContext)(nil)
+// ConfigAndOtherModuleProviderContext is OtherModuleProviderContext + ConfigContext
+type ConfigAndOtherModuleProviderContext interface {
+ OtherModuleProviderContext
+ 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.
@@ -35,6 +41,14 @@ func OtherModuleProviderOrDefault[K any](ctx OtherModuleProviderContext, module
return value
}
+func OtherModulePointerProviderOrDefault[K *T, T any](ctx OtherModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) K {
+ if value, ok := OtherModuleProvider(ctx, module, provider); ok {
+ return value
+ }
+ var val T
+ return &val
+}
+
// ModuleProviderContext is a helper interface that is a subset of ModuleContext or BottomUpMutatorContext
// for use in ModuleProvider.
type ModuleProviderContext interface {