Merge SingletonProviderContext with OtherModuleProviderContext
Bug: 358425833
Test: CI
Change-Id: I8e3f40dc3cfc5337008b419801f8e6bf2d48e8b2
diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go
index a47e80f..f0675dd 100644
--- a/android/aconfig_providers.go
+++ b/android/aconfig_providers.go
@@ -141,7 +141,7 @@
}
func aconfigUpdateAndroidMkData(ctx fillInEntriesContext, mod Module, data *AndroidMkData) {
- info, ok := SingletonModuleProvider(ctx, mod, AconfigPropagatingProviderKey)
+ info, ok := OtherModuleProvider(ctx, mod, AconfigPropagatingProviderKey)
// If there is no aconfigPropagatingProvider, or there are no AconfigFiles, then we are done.
if !ok || len(info.AconfigFiles) == 0 {
return
@@ -172,7 +172,7 @@
if len(*entries) == 0 {
return
}
- info, ok := SingletonModuleProvider(ctx, mod, AconfigPropagatingProviderKey)
+ info, ok := OtherModuleProvider(ctx, mod, AconfigPropagatingProviderKey)
if !ok || len(info.AconfigFiles) == 0 {
return
}
diff --git a/android/all_teams.go b/android/all_teams.go
index d4bf7d0..e3c2e70 100644
--- a/android/all_teams.go
+++ b/android/all_teams.go
@@ -1,9 +1,10 @@
package android
import (
- "android/soong/android/team_proto"
"path/filepath"
+ "android/soong/android/team_proto"
+
"google.golang.org/protobuf/proto"
)
@@ -93,7 +94,7 @@
}
testModInfo := TestModuleInformation{}
- if tmi, ok := SingletonModuleProvider(ctx, module, TestOnlyProviderKey); ok {
+ if tmi, ok := OtherModuleProvider(ctx, module, TestOnlyProviderKey); ok {
testModInfo = tmi
}
diff --git a/android/androidmk.go b/android/androidmk.go
index 9699ce5..e9df752 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -170,7 +170,7 @@
}
func (a *androidMkExtraEntriesContext) Provider(provider blueprint.AnyProviderKey) (any, bool) {
- return a.ctx.moduleProvider(a.mod, provider)
+ return a.ctx.otherModuleProvider(a.mod, provider)
}
type AndroidMkExtraEntriesFunc func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries)
@@ -497,7 +497,7 @@
ModuleDir(module blueprint.Module) string
ModuleSubDir(module blueprint.Module) string
Config() Config
- moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
+ otherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
ModuleType(module blueprint.Module) string
OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{})
}
@@ -633,11 +633,11 @@
}
}
- if licenseMetadata, ok := SingletonModuleProvider(ctx, mod, LicenseMetadataProvider); ok {
+ if licenseMetadata, ok := OtherModuleProvider(ctx, mod, LicenseMetadataProvider); ok {
a.SetPath("LOCAL_SOONG_LICENSE_METADATA", licenseMetadata.LicenseMetadataPath)
}
- if _, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ if _, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
a.SetBool("LOCAL_SOONG_MODULE_INFO_JSON", true)
}
@@ -918,7 +918,7 @@
}
if !data.Entries.disabled() {
- if moduleInfoJSON, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ if moduleInfoJSON, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
*moduleInfoJSONs = append(*moduleInfoJSONs, moduleInfoJSON)
}
}
@@ -960,7 +960,7 @@
}
if len(entriesList) > 0 && !entriesList[0].disabled() {
- if moduleInfoJSON, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ if moduleInfoJSON, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
*moduleInfoJSONs = append(*moduleInfoJSONs, moduleInfoJSON)
}
}
diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go
index 6ea6654..0080b9a 100644
--- a/android/compliance_metadata.go
+++ b/android/compliance_metadata.go
@@ -267,7 +267,7 @@
writerToCsv(csvWriter, metadata)
return
}
- if provider, ok := ctx.moduleProvider(module, ComplianceMetadataProvider); ok {
+ if provider, ok := ctx.otherModuleProvider(module, ComplianceMetadataProvider); ok {
metadataInfo := provider.(*ComplianceMetadataInfo)
rowId = rowId + 1
metadata := []string{strconv.Itoa(rowId)}
diff --git a/android/logtags.go b/android/logtags.go
index d11cccf..7929057 100644
--- a/android/logtags.go
+++ b/android/logtags.go
@@ -42,7 +42,7 @@
if !module.ExportedToMake() {
return
}
- if logtagsInfo, ok := SingletonModuleProvider(ctx, module, LogtagsProviderKey); ok {
+ if logtagsInfo, ok := OtherModuleProvider(ctx, module, LogtagsProviderKey); ok {
allLogtags = append(allLogtags, logtagsInfo.Logtags...)
}
})
diff --git a/android/makevars.go b/android/makevars.go
index f92f458..ff43cc5 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -94,7 +94,7 @@
ModuleDir(module blueprint.Module) string
ModuleSubDir(module blueprint.Module) string
ModuleType(module blueprint.Module) string
- moduleProvider(module blueprint.Module, key blueprint.AnyProviderKey) (any, bool)
+ otherModuleProvider(module blueprint.Module, key blueprint.AnyProviderKey) (any, bool)
BlueprintFile(module blueprint.Module) string
ModuleErrorf(module blueprint.Module, format string, args ...interface{})
diff --git a/android/module.go b/android/module.go
index f9fab96..15976ad 100644
--- a/android/module.go
+++ b/android/module.go
@@ -2519,7 +2519,7 @@
fromProperty = true
}
} else if cta, isCta := ctx.(*singletonContextAdaptor); isCta {
- providerData, _ := cta.moduleProvider(module, OutputFilesProvider)
+ providerData, _ := cta.otherModuleProvider(module, OutputFilesProvider)
outputFiles, _ = providerData.(OutputFilesInfo)
} else {
return nil, fmt.Errorf("unsupported context %q in method outputFilesForModuleFromProvider", reflect.TypeOf(ctx))
diff --git a/android/provider.go b/android/provider.go
index 3b9c5d2..327f224 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -14,6 +14,8 @@
var _ OtherModuleProviderContext = ModuleContext(nil)
var _ OtherModuleProviderContext = BottomUpMutatorContext(nil)
var _ OtherModuleProviderContext = TopDownMutatorContext(nil)
+var _ OtherModuleProviderContext = SingletonContext(nil)
+var _ OtherModuleProviderContext = (*TestContext)(nil)
// 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
@@ -56,26 +58,6 @@
return value.(K), ok
}
-type SingletonModuleProviderContext interface {
- moduleProvider(blueprint.Module, blueprint.AnyProviderKey) (any, bool)
-}
-
-var _ SingletonModuleProviderContext = SingletonContext(nil)
-var _ SingletonModuleProviderContext = (*TestContext)(nil)
-
-// SingletonModuleProvider wraps blueprint.SingletonModuleProvider to provide a type-safe method to retrieve the value
-// of the given provider from a module using a SingletonContext. If the provider has not been set the first return
-// value will be the zero value of the provider's type, and the second return value will be false. If the provider has
-// been set the second return value will be true.
-func SingletonModuleProvider[K any](ctx SingletonModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) (K, bool) {
- value, ok := ctx.moduleProvider(module, provider)
- if !ok {
- var k K
- return k, false
- }
- return value.(K), ok
-}
-
// SetProviderContext is a helper interface that is a subset of ModuleContext, BottomUpMutatorContext, or
// TopDownMutatorContext for use in SetProvider.
type SetProviderContext interface {
diff --git a/android/singleton.go b/android/singleton.go
index d364384..92264d2 100644
--- a/android/singleton.go
+++ b/android/singleton.go
@@ -35,7 +35,7 @@
// Allows generating build actions for `referer` based on the metadata for `name` deferred until the singleton context.
ModuleVariantsFromName(referer Module, name string) []Module
- moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
+ otherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
ModuleErrorf(module blueprint.Module, format string, args ...interface{})
Errorf(format string, args ...interface{})
@@ -279,7 +279,7 @@
return result
}
-func (s *singletonContextAdaptor) moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
+func (s *singletonContextAdaptor) otherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
return s.SingletonContext.ModuleProvider(module, provider)
}
diff --git a/android/testing.go b/android/testing.go
index e3853b8..a3e35cb 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -212,7 +212,7 @@
ctx.PreArchMutators(f)
}
-func (ctx *TestContext) moduleProvider(m blueprint.Module, p blueprint.AnyProviderKey) (any, bool) {
+func (ctx *TestContext) otherModuleProvider(m blueprint.Module, p blueprint.AnyProviderKey) (any, bool) {
return ctx.Context.ModuleProvider(m, p)
}
@@ -230,7 +230,7 @@
func (ctx *TestContext) OtherModuleProviderAdaptor() OtherModuleProviderContext {
return NewOtherModuleProviderAdaptor(func(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
- return ctx.moduleProvider(module, provider)
+ return ctx.otherModuleProvider(module, provider)
})
}