diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go index 548329523..e89cd316f 100644 --- a/aconfig/aconfig_declarations_test.go +++ b/aconfig/aconfig_declarations_test.go @@ -40,7 +40,7 @@ func TestAconfigDeclarations(t *testing.T) { module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule) // Check that the provider has the right contents - depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey) + depData, _ := android.OtherModuleProvider(result, module, android.AconfigDeclarationsProviderKey) android.AssertStringEquals(t, "package", depData.Package, "com.example.package") android.AssertStringEquals(t, "container", depData.Container, "com.android.foo") android.AssertBoolEquals(t, "exportable", depData.Exportable, true) @@ -67,7 +67,7 @@ func TestAconfigDeclarationsWithExportableUnset(t *testing.T) { result := runTest(t, android.FixtureExpectsNoErrors, bp) module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule) - depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey) + depData, _ := android.OtherModuleProvider(result, module, android.AconfigDeclarationsProviderKey) android.AssertBoolEquals(t, "exportable", depData.Exportable, false) } @@ -205,7 +205,7 @@ func TestGenerateAndroidBuildActions(t *testing.T) { } result := fixture.RunTestWithBp(t, test.bp) module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule) - depData, _ := android.SingletonModuleProvider(result, module, android.AconfigReleaseDeclarationsProviderKey) + depData, _ := android.OtherModuleProvider(result, module, android.AconfigReleaseDeclarationsProviderKey) expectedKeys := []string{""} for _, rc := range strings.Split(test.buildFlags["RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS"], " ") { expectedKeys = append(expectedKeys, rc) diff --git a/aconfig/aconfig_value_set_test.go b/aconfig/aconfig_value_set_test.go index 7d1899926..32c31cb32 100644 --- a/aconfig/aconfig_value_set_test.go +++ b/aconfig/aconfig_value_set_test.go @@ -38,6 +38,6 @@ func TestAconfigValueSet(t *testing.T) { module := result.ModuleForTests("module_name", "").Module().(*ValueSetModule) // Check that the provider has the right contents - depData, _ := android.SingletonModuleProvider(result, module, valueSetProviderKey) + depData, _ := android.OtherModuleProvider(result, module, valueSetProviderKey) android.AssertStringEquals(t, "AvailablePackages", "blah.aconfig_values", depData.AvailablePackages["foo.package"][0].String()) } diff --git a/aconfig/aconfig_values_test.go b/aconfig/aconfig_values_test.go index 526579c40..ddbea57a8 100644 --- a/aconfig/aconfig_values_test.go +++ b/aconfig/aconfig_values_test.go @@ -33,7 +33,7 @@ func TestAconfigValues(t *testing.T) { module := result.ModuleForTests("module_name", "").Module().(*ValuesModule) // Check that the provider has the right contents - depData, _ := android.SingletonModuleProvider(result, module, valuesProviderKey) + depData, _ := android.OtherModuleProvider(result, module, valuesProviderKey) android.AssertStringEquals(t, "package", "foo.package", depData.Package) android.AssertPathsEndWith(t, "srcs", []string{"blah.aconfig_values"}, depData.Values) } diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go index 0437c266f..6ad54da4a 100644 --- a/aconfig/all_aconfig_declarations.go +++ b/aconfig/all_aconfig_declarations.go @@ -15,9 +15,10 @@ package aconfig import ( - "android/soong/android" "fmt" "slices" + + "android/soong/android" ) // A singleton module that collects all of the aconfig flags declared in the @@ -55,7 +56,7 @@ func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.Si var packages = make(map[string]int) var cacheFiles android.Paths ctx.VisitAllModules(func(module android.Module) { - decl, ok := android.SingletonModuleProvider(ctx, module, android.AconfigReleaseDeclarationsProviderKey) + decl, ok := android.OtherModuleProvider(ctx, module, android.AconfigReleaseDeclarationsProviderKey) if !ok { return } diff --git a/aconfig/build_flags/all_build_flag_declarations.go b/aconfig/build_flags/all_build_flag_declarations.go index 282c9dcf8..5f0291262 100644 --- a/aconfig/build_flags/all_build_flag_declarations.go +++ b/aconfig/build_flags/all_build_flag_declarations.go @@ -38,7 +38,7 @@ func (this *allBuildFlagDeclarationsSingleton) GenerateBuildActions(ctx android. // Find all of the build_flag_declarations modules var intermediateFiles android.Paths ctx.VisitAllModules(func(module android.Module) { - decl, ok := android.SingletonModuleProvider(ctx, module, BuildFlagDeclarationsProviderKey) + decl, ok := android.OtherModuleProvider(ctx, module, BuildFlagDeclarationsProviderKey) if !ok { return } diff --git a/aconfig/exported_java_aconfig_library.go b/aconfig/exported_java_aconfig_library.go index 291938fa8..a64cac882 100644 --- a/aconfig/exported_java_aconfig_library.go +++ b/aconfig/exported_java_aconfig_library.go @@ -30,7 +30,7 @@ func (this *exportedJavaDeclarationsLibrarySingleton) GenerateBuildActions(ctx a // Find all of the aconfig_declarations modules var cacheFiles android.Paths ctx.VisitAllModules(func(module android.Module) { - decl, ok := android.SingletonModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey) + decl, ok := android.OtherModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey) if !ok { return } diff --git a/aidl_library/aidl_library_test.go b/aidl_library/aidl_library_test.go index 01eab0eaf..166045635 100644 --- a/aidl_library/aidl_library_test.go +++ b/aidl_library/aidl_library_test.go @@ -15,8 +15,9 @@ package aidl_library import ( - "android/soong/android" "testing" + + "android/soong/android" ) func TestAidlLibrary(t *testing.T) { @@ -46,7 +47,7 @@ func TestAidlLibrary(t *testing.T) { ).RunTest(t).TestContext foo := ctx.ModuleForTests("foo", "").Module().(*AidlLibrary) - actualInfo, _ := android.SingletonModuleProvider(ctx, foo, AidlLibraryProvider) + actualInfo, _ := android.OtherModuleProvider(ctx, foo, AidlLibraryProvider) android.AssertArrayString( t, @@ -95,7 +96,7 @@ func TestAidlLibraryWithoutStripImportPrefix(t *testing.T) { ).RunTest(t).TestContext foo := ctx.ModuleForTests("foo", "").Module().(*AidlLibrary) - actualInfo, _ := android.SingletonModuleProvider(ctx, foo, AidlLibraryProvider) + actualInfo, _ := android.OtherModuleProvider(ctx, foo, AidlLibraryProvider) android.AssertArrayString( t, diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go index a47e80f03..f0675dd5b 100644 --- a/android/aconfig_providers.go +++ b/android/aconfig_providers.go @@ -141,7 +141,7 @@ func aconfigUpdateAndroidBuildActions(ctx ModuleContext) { } 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 @@ func aconfigUpdateAndroidMkEntries(ctx fillInEntriesContext, mod Module, entries 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 d4bf7d0c4..e3c2e70bd 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 @@ func (t *allTeamsSingleton) GenerateBuildActions(ctx SingletonContext) { } 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 9699ce5b8..e9df75283 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -170,7 +170,7 @@ type androidMkExtraEntriesContext struct { } 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 @@ type fillInEntriesContext interface { 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 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint } } - 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 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs * } 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 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleIn } 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 6ea66541a..0080b9afc 100644 --- a/android/compliance_metadata.go +++ b/android/compliance_metadata.go @@ -267,7 +267,7 @@ func (c *complianceMetadataSingleton) GenerateBuildActions(ctx SingletonContext) 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 d11cccf4f..7929057ff 100644 --- a/android/logtags.go +++ b/android/logtags.go @@ -42,7 +42,7 @@ func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) { 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 f92f4581e..ff43cc5ab 100644 --- a/android/makevars.go +++ b/android/makevars.go @@ -94,7 +94,7 @@ type MakeVarsContext interface { 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 f9fab96a9..15976ad9a 100644 --- a/android/module.go +++ b/android/module.go @@ -2519,7 +2519,7 @@ func outputFilesForModuleFromProvider(ctx PathContext, module blueprint.Module, 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 3b9c5d2ba..327f224f7 100644 --- a/android/provider.go +++ b/android/provider.go @@ -14,6 +14,8 @@ var _ OtherModuleProviderContext = BaseModuleContext(nil) 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 @@ func ModuleProvider[K any](ctx ModuleProviderContext, provider blueprint.Provide 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 d364384e2..92264d2e3 100644 --- a/android/singleton.go +++ b/android/singleton.go @@ -35,7 +35,7 @@ type SingletonContext interface { // 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 @@ func (s *singletonContextAdaptor) ModuleVariantsFromName(referer Module, name st 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 e3853b844..a3e35cb99 100644 --- a/android/testing.go +++ b/android/testing.go @@ -212,7 +212,7 @@ func (ctx *TestContext) HardCodedPreArchMutators(f RegisterMutatorFunc) { 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) FinalDepsMutators(f RegisterMutatorFunc) { 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) }) } diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go index a8d89b11e..f405cb2fe 100644 --- a/apex/apex_singleton.go +++ b/apex/apex_singleton.go @@ -88,7 +88,7 @@ func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContex updatableFlatLists := android.Paths{} ctx.VisitAllModules(func(module android.Module) { if binaryInfo, ok := module.(android.ApexBundleDepsInfoIntf); ok { - apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider) + apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider) if path := binaryInfo.FlatListPath(); path != nil { if binaryInfo.Updatable() || apexInfo.Updatable { updatableFlatLists = append(updatableFlatLists, path) @@ -155,7 +155,7 @@ func (a *apexPrebuiltInfo) GenerateBuildActions(ctx android.SingletonContext) { prebuiltInfos := []android.PrebuiltInfo{} ctx.VisitAllModules(func(m android.Module) { - prebuiltInfo, exists := android.SingletonModuleProvider(ctx, m, android.PrebuiltInfoProvider) + prebuiltInfo, exists := android.OtherModuleProvider(ctx, m, android.PrebuiltInfoProvider) // Use prebuiltInfoProvider to filter out non apex soong modules. // Use HideFromMake to filter out the unselected variants of a specific apex. if exists && !m.IsHideFromMake() { diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go index f8c823e94..25131eec6 100644 --- a/apex/bootclasspath_fragment_test.go +++ b/apex/bootclasspath_fragment_test.go @@ -152,7 +152,7 @@ func TestBootclasspathFragments_FragmentDependency(t *testing.T) { // Check stub dex paths exported by art. artFragment := result.Module("art-bootclasspath-fragment", "android_common") - artInfo, _ := android.SingletonModuleProvider(result, artFragment, java.HiddenAPIInfoProvider) + artInfo, _ := android.OtherModuleProvider(result, artFragment, java.HiddenAPIInfoProvider) bazPublicStubs := "out/soong/.intermediates/baz.stubs.exportable/android_common/dex/baz.stubs.exportable.jar" bazSystemStubs := "out/soong/.intermediates/baz.stubs.exportable.system/android_common/dex/baz.stubs.exportable.system.jar" @@ -165,7 +165,7 @@ func TestBootclasspathFragments_FragmentDependency(t *testing.T) { // Check stub dex paths exported by other. otherFragment := result.Module("other-bootclasspath-fragment", "android_common") - otherInfo, _ := android.SingletonModuleProvider(result, otherFragment, java.HiddenAPIInfoProvider) + otherInfo, _ := android.OtherModuleProvider(result, otherFragment, java.HiddenAPIInfoProvider) fooPublicStubs := "out/soong/.intermediates/foo.stubs.exportable/android_common/dex/foo.stubs.exportable.jar" fooSystemStubs := "out/soong/.intermediates/foo.stubs.exportable.system/android_common/dex/foo.stubs.exportable.system.jar" @@ -688,7 +688,7 @@ func TestBootclasspathFragmentContentsNoName(t *testing.T) { // Make sure that the fragment provides the hidden API encoded dex jars to the APEX. fragment := result.Module("mybootclasspathfragment", "android_common_apex10000") - info, _ := android.SingletonModuleProvider(result, fragment, java.BootclasspathFragmentApexContentInfoProvider) + info, _ := android.OtherModuleProvider(result, fragment, java.BootclasspathFragmentApexContentInfoProvider) checkFragmentExportedDexJar := func(name string, expectedDexJar string) { module := result.Module(name, "android_common_apex10000") diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go index 645eebb13..920fc0c0b 100644 --- a/apex/platform_bootclasspath_test.go +++ b/apex/platform_bootclasspath_test.go @@ -154,7 +154,7 @@ func TestPlatformBootclasspath_Fragments(t *testing.T) { ).RunTest(t) pbcp := result.Module("platform-bootclasspath", "android_common") - info, _ := android.SingletonModuleProvider(result, pbcp, java.MonolithicHiddenAPIInfoProvider) + info, _ := android.OtherModuleProvider(result, pbcp, java.MonolithicHiddenAPIInfoProvider) for _, category := range java.HiddenAPIFlagFileCategories { name := category.PropertyName() @@ -236,7 +236,7 @@ func TestPlatformBootclasspath_LegacyPrebuiltFragment(t *testing.T) { ) pbcp := result.Module("myplatform-bootclasspath", "android_common") - info, _ := android.SingletonModuleProvider(result, pbcp, java.MonolithicHiddenAPIInfoProvider) + info, _ := android.OtherModuleProvider(result, pbcp, java.MonolithicHiddenAPIInfoProvider) android.AssertArrayString(t, "stub flags", []string{"prebuilt-stub-flags.csv:out/soong/.intermediates/mybootclasspath-fragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop()) android.AssertArrayString(t, "all flags", []string{"prebuilt-all-flags.csv:out/soong/.intermediates/mybootclasspath-fragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop()) diff --git a/bloaty/bloaty.go b/bloaty/bloaty.go index b72b6d387..8ecea98b4 100644 --- a/bloaty/bloaty.go +++ b/bloaty/bloaty.go @@ -88,7 +88,7 @@ func (singleton *sizesSingleton) GenerateBuildActions(ctx android.SingletonConte if !m.ExportedToMake() { return } - filePaths, ok := android.SingletonModuleProvider(ctx, m, fileSizeMeasurerKey) + filePaths, ok := android.OtherModuleProvider(ctx, m, fileSizeMeasurerKey) if !ok { return } diff --git a/cc/cc_test.go b/cc/cc_test.go index 7372fff66..779e53d40 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -851,7 +851,7 @@ func TestStaticLibDepReordering(t *testing.T) { variant := "android_arm64_armv8-a_static" moduleA := ctx.ModuleForTests("a", variant).Module().(*Module) - staticLibInfo, _ := android.SingletonModuleProvider(ctx, moduleA, StaticLibraryInfoProvider) + staticLibInfo, _ := android.OtherModuleProvider(ctx, moduleA, StaticLibraryInfoProvider) actual := android.Paths(staticLibInfo.TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop() expected := GetOutputPaths(ctx, variant, []string{"a", "c", "b", "d"}) @@ -887,7 +887,7 @@ func TestStaticLibDepReorderingWithShared(t *testing.T) { variant := "android_arm64_armv8-a_static" moduleA := ctx.ModuleForTests("a", variant).Module().(*Module) - staticLibInfo, _ := android.SingletonModuleProvider(ctx, moduleA, StaticLibraryInfoProvider) + staticLibInfo, _ := android.OtherModuleProvider(ctx, moduleA, StaticLibraryInfoProvider) actual := android.Paths(staticLibInfo.TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop() expected := GetOutputPaths(ctx, variant, []string{"a", "c", "b"}) @@ -999,7 +999,7 @@ func TestLlndkLibrary(t *testing.T) { checkExportedIncludeDirs := func(module, variant string, expectedSystemDirs []string, expectedDirs ...string) { t.Helper() m := result.ModuleForTests(module, variant).Module() - f, _ := android.SingletonModuleProvider(result, m, FlagExporterInfoProvider) + f, _ := android.OtherModuleProvider(result, m, FlagExporterInfoProvider) android.AssertPathsRelativeToTopEquals(t, "exported include dirs for "+module+"["+variant+"]", expectedDirs, f.IncludeDirs) android.AssertPathsRelativeToTopEquals(t, "exported include dirs for "+module+"["+variant+"]", @@ -1027,7 +1027,7 @@ func TestLlndkLibrary(t *testing.T) { } } vendorModule := result.ModuleForTests(module, vendorVariant).Module() - vendorInfo, _ := android.SingletonModuleProvider(result, vendorModule, FlagExporterInfoProvider) + vendorInfo, _ := android.OtherModuleProvider(result, vendorModule, FlagExporterInfoProvider) vendorDirs := android.Concat(vendorInfo.IncludeDirs, vendorInfo.SystemIncludeDirs) android.AssertStringEquals(t, module+" has different exported include dirs for vendor variant and ABI check", android.JoinPathsWithPrefix(vendorDirs, "-I"), abiCheckFlags) @@ -2452,7 +2452,7 @@ func TestIncludeDirsExporting(t *testing.T) { checkIncludeDirs := func(t *testing.T, ctx *android.TestContext, module android.Module, checkers ...exportedChecker) { t.Helper() - exported, _ := android.SingletonModuleProvider(ctx, module, FlagExporterInfoProvider) + exported, _ := android.OtherModuleProvider(ctx, module, FlagExporterInfoProvider) name := module.Name() for _, checker := range checkers { diff --git a/cc/sanitize_test.go b/cc/sanitize_test.go index 44f38e10a..80facd8f0 100644 --- a/cc/sanitize_test.go +++ b/cc/sanitize_test.go @@ -47,7 +47,7 @@ var prepareForTsanTest = android.FixtureAddFile("tsan/Android.bp", []byte(` `)) type providerInterface interface { - android.SingletonModuleProviderContext + android.OtherModuleProviderContext } // expectSharedLinkDep verifies that the from module links against the to module as a @@ -55,7 +55,7 @@ type providerInterface interface { func expectSharedLinkDep(t *testing.T, ctx providerInterface, from, to android.TestingModule) { t.Helper() fromLink := from.Description("link") - toInfo, _ := android.SingletonModuleProvider(ctx, to.Module(), SharedLibraryInfoProvider) + toInfo, _ := android.OtherModuleProvider(ctx, to.Module(), SharedLibraryInfoProvider) if g, w := fromLink.OrderOnly.Strings(), toInfo.SharedLibrary.RelativeToTop().String(); !android.InList(w, g) { t.Errorf("%s should link against %s, expected %q, got %q", @@ -68,7 +68,7 @@ func expectSharedLinkDep(t *testing.T, ctx providerInterface, from, to android.T func expectNoSharedLinkDep(t *testing.T, ctx providerInterface, from, to android.TestingModule) { t.Helper() fromLink := from.Description("link") - toInfo, _ := android.SingletonModuleProvider(ctx, to.Module(), SharedLibraryInfoProvider) + toInfo, _ := android.OtherModuleProvider(ctx, to.Module(), SharedLibraryInfoProvider) if g, w := fromLink.OrderOnly.Strings(), toInfo.SharedLibrary.RelativeToTop().String(); android.InList(w, g) { t.Errorf("%s should not link against %s, expected %q, got %q", @@ -81,7 +81,7 @@ func expectNoSharedLinkDep(t *testing.T, ctx providerInterface, from, to android func expectStaticLinkDep(t *testing.T, ctx providerInterface, from, to android.TestingModule) { t.Helper() fromLink := from.Description("link") - toInfo, _ := android.SingletonModuleProvider(ctx, to.Module(), StaticLibraryInfoProvider) + toInfo, _ := android.OtherModuleProvider(ctx, to.Module(), StaticLibraryInfoProvider) if g, w := fromLink.Implicits.Strings(), toInfo.StaticLibrary.RelativeToTop().String(); !android.InList(w, g) { t.Errorf("%s should link against %s, expected %q, got %q", @@ -95,7 +95,7 @@ func expectStaticLinkDep(t *testing.T, ctx providerInterface, from, to android.T func expectNoStaticLinkDep(t *testing.T, ctx providerInterface, from, to android.TestingModule) { t.Helper() fromLink := from.Description("link") - toInfo, _ := android.SingletonModuleProvider(ctx, to.Module(), StaticLibraryInfoProvider) + toInfo, _ := android.OtherModuleProvider(ctx, to.Module(), StaticLibraryInfoProvider) if g, w := fromLink.Implicits.Strings(), toInfo.StaticLibrary.RelativeToTop().String(); android.InList(w, g) { t.Errorf("%s should not link against %s, expected %q, got %q", diff --git a/java/aar_test.go b/java/aar_test.go index ebad310ab..877e2c7d6 100644 --- a/java/aar_test.go +++ b/java/aar_test.go @@ -53,7 +53,7 @@ func TestAarImportProducesJniPackages(t *testing.T) { appMod := ctx.Module(tc.name, "android_common") appTestMod := ctx.ModuleForTests(tc.name, "android_common") - info, ok := android.SingletonModuleProvider(ctx, appMod, JniPackageProvider) + info, ok := android.OtherModuleProvider(ctx, appMod, JniPackageProvider) if !ok { t.Errorf("expected android_library_import to have JniPackageProvider") } diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go index d72417afa..60f1a50e1 100644 --- a/java/bootclasspath_fragment_test.go +++ b/java/bootclasspath_fragment_test.go @@ -273,7 +273,7 @@ func TestBootclasspathFragment_StubLibs(t *testing.T) { `) fragment := result.Module("myfragment", "android_common") - info, _ := android.SingletonModuleProvider(result, fragment, HiddenAPIInfoProvider) + info, _ := android.OtherModuleProvider(result, fragment, HiddenAPIInfoProvider) stubsJar := "out/soong/.intermediates/mystublib/android_common/dex/mystublib.jar" @@ -457,7 +457,7 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { // Make sure that the library exports hidden API properties for use by the bootclasspath_fragment. library := result.Module("mynewlibrary", "android_common") - info, _ := android.SingletonModuleProvider(result, library, hiddenAPIPropertyInfoProvider) + info, _ := android.OtherModuleProvider(result, library, hiddenAPIPropertyInfoProvider) android.AssertArrayString(t, "split packages", []string{"sdklibrary", "newlibrary"}, info.SplitPackages) android.AssertArrayString(t, "package prefixes", []string{"newlibrary.all.mine"}, info.PackagePrefixes) android.AssertArrayString(t, "single packages", []string{"newlibrary.mine"}, info.SinglePackages) diff --git a/java/code_metadata_test.go b/java/code_metadata_test.go index 99b1f5226..9dc9a2262 100644 --- a/java/code_metadata_test.go +++ b/java/code_metadata_test.go @@ -29,7 +29,7 @@ func TestCodeMetadata(t *testing.T) { module := result.ModuleForTests("module-name", "") // Check that the provider has the right contents - data, _ := android.SingletonModuleProvider(result, module.Module(), soongTesting.CodeMetadataProviderKey) + data, _ := android.OtherModuleProvider(result, module.Module(), soongTesting.CodeMetadataProviderKey) if !strings.HasSuffix( data.IntermediatePath.String(), "/intermediateCodeMetadata.pb", ) { diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 56e007bbf..a81ab8316 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -1341,7 +1341,7 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) { image := d.defaultBootImage if image != nil { - if profileInstallInfo, ok := android.SingletonModuleProvider(ctx, d, profileInstallInfoProvider); ok { + if profileInstallInfo, ok := android.OtherModuleProvider(ctx, d, profileInstallInfoProvider); ok { ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", profileInstallInfo.profileInstalls.String()) if profileInstallInfo.profileLicenseMetadataFile.Valid() { ctx.Strict("DEXPREOPT_IMAGE_PROFILE_LICENSE_METADATA", profileInstallInfo.profileLicenseMetadataFile.String()) diff --git a/java/dexpreopt_config_testing.go b/java/dexpreopt_config_testing.go index 104829f5f..37c54b915 100644 --- a/java/dexpreopt_config_testing.go +++ b/java/dexpreopt_config_testing.go @@ -1237,7 +1237,7 @@ func nestedCheckBootImageConfig(t *testing.T, result *android.TestResult, imageC if !mutated { dexBootJarModule := result.ModuleForTests("dex_bootjars", "android_common") - profileInstallInfo, _ := android.SingletonModuleProvider(result, dexBootJarModule.Module(), profileInstallInfoProvider) + profileInstallInfo, _ := android.OtherModuleProvider(result, dexBootJarModule.Module(), profileInstallInfoProvider) assertInstallsEqual(t, "profileInstalls", expected.profileInstalls, profileInstallInfo.profileInstalls) android.AssertStringEquals(t, "profileLicenseMetadataFile", expected.profileLicenseMetadataFile, profileInstallInfo.profileLicenseMetadataFile.RelativeToTop().String()) } diff --git a/java/java_test.go b/java/java_test.go index 86bfe9fe4..477a0b385 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1100,7 +1100,7 @@ func TestJavaImport(t *testing.T) { source := ctx.ModuleForTests("source_library", "android_common") sourceJar := source.Output("javac/source_library.jar") sourceHeaderJar := source.Output("turbine-combined/source_library.jar") - sourceJavaInfo, _ := android.SingletonModuleProvider(ctx, source.Module(), JavaInfoProvider) + sourceJavaInfo, _ := android.OtherModuleProvider(ctx, source.Module(), JavaInfoProvider) // The source library produces separate implementation and header jars android.AssertPathsRelativeToTopEquals(t, "source library implementation jar", @@ -1110,7 +1110,7 @@ func TestJavaImport(t *testing.T) { importWithNoDeps := ctx.ModuleForTests("import_with_no_deps", "android_common") importWithNoDepsJar := importWithNoDeps.Output("combined/import_with_no_deps.jar") - importWithNoDepsJavaInfo, _ := android.SingletonModuleProvider(ctx, importWithNoDeps.Module(), JavaInfoProvider) + importWithNoDepsJavaInfo, _ := android.OtherModuleProvider(ctx, importWithNoDeps.Module(), JavaInfoProvider) // An import with no deps produces a single jar used as both the header and implementation jar. android.AssertPathsRelativeToTopEquals(t, "import with no deps implementation jar", @@ -1123,7 +1123,7 @@ func TestJavaImport(t *testing.T) { importWithSourceDeps := ctx.ModuleForTests("import_with_source_deps", "android_common") importWithSourceDepsJar := importWithSourceDeps.Output("combined/import_with_source_deps.jar") importWithSourceDepsHeaderJar := importWithSourceDeps.Output("turbine-combined/import_with_source_deps.jar") - importWithSourceDepsJavaInfo, _ := android.SingletonModuleProvider(ctx, importWithSourceDeps.Module(), JavaInfoProvider) + importWithSourceDepsJavaInfo, _ := android.OtherModuleProvider(ctx, importWithSourceDeps.Module(), JavaInfoProvider) // An import with source deps produces separate header and implementation jars. android.AssertPathsRelativeToTopEquals(t, "import with source deps implementation jar", @@ -1137,7 +1137,7 @@ func TestJavaImport(t *testing.T) { importWithImportDeps := ctx.ModuleForTests("import_with_import_deps", "android_common") importWithImportDepsJar := importWithImportDeps.Output("combined/import_with_import_deps.jar") - importWithImportDepsJavaInfo, _ := android.SingletonModuleProvider(ctx, importWithImportDeps.Module(), JavaInfoProvider) + importWithImportDepsJavaInfo, _ := android.OtherModuleProvider(ctx, importWithImportDeps.Module(), JavaInfoProvider) // An import with only import deps produces a single jar used as both the header and implementation jar. android.AssertPathsRelativeToTopEquals(t, "import with import deps implementation jar", @@ -2274,7 +2274,7 @@ func TestTransitiveSrcFiles(t *testing.T) { } `) c := ctx.ModuleForTests("c", "android_common").Module() - javaInfo, _ := android.SingletonModuleProvider(ctx, c, JavaInfoProvider) + javaInfo, _ := android.OtherModuleProvider(ctx, c, JavaInfoProvider) transitiveSrcFiles := android.Paths(javaInfo.TransitiveSrcFiles.ToList()) android.AssertArrayString(t, "unexpected jar deps", []string{"b.java", "c.java"}, transitiveSrcFiles.Strings()) } diff --git a/java/jdeps.go b/java/jdeps.go index 340026318..e856b37ee 100644 --- a/java/jdeps.go +++ b/java/jdeps.go @@ -89,7 +89,7 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont dpInfo.Classes = append(dpInfo.Classes, data.Class) } - if dep, ok := android.SingletonModuleProvider(ctx, module, JavaInfoProvider); ok { + if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { dpInfo.Installed_paths = append(dpInfo.Installed_paths, dep.ImplementationJars.Strings()...) } dpInfo.Classes = android.FirstUniqueStrings(dpInfo.Classes) diff --git a/java/lint.go b/java/lint.go index 2eea07d31..6782adc5f 100644 --- a/java/lint.go +++ b/java/lint.go @@ -650,7 +650,7 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) { } if apex, ok := m.(android.ApexModule); ok && apex.NotAvailableForPlatform() { - apexInfo, _ := android.SingletonModuleProvider(ctx, m, android.ApexInfoProvider) + apexInfo, _ := android.OtherModuleProvider(ctx, m, android.ApexInfoProvider) if apexInfo.IsForPlatform() { // There are stray platform variants of modules in apexes that are not available for // the platform, and they sometimes can't be built. Don't depend on them. diff --git a/java/sdk.go b/java/sdk.go index 4ef4ee251..dd198ac57 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -278,7 +278,7 @@ func createFrameworkAidl(stubsModules []string, path android.WritablePath, ctx a ctx.VisitAllModules(func(module android.Module) { // Collect dex jar paths for the modules listed above. - if j, ok := android.SingletonModuleProvider(ctx, module, JavaInfoProvider); ok { + if j, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { name := ctx.ModuleName(module) if i := android.IndexList(name, stubsModules); i != -1 { stubsJars[i] = j.HeaderJars diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 368eca7f2..52d4af0fd 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -130,7 +130,7 @@ func TestJavaSdkLibrary(t *testing.T) { result.ModuleForTests("foo.api.system.28", "") result.ModuleForTests("foo.api.test.28", "") - exportedComponentsInfo, _ := android.SingletonModuleProvider(result, foo.Module(), android.ExportedComponentsInfoProvider) + exportedComponentsInfo, _ := android.OtherModuleProvider(result, foo.Module(), android.ExportedComponentsInfoProvider) expectedFooExportedComponents := []string{ "foo-removed.api.combined.public.latest", "foo-removed.api.combined.system.latest", diff --git a/java/system_modules_test.go b/java/system_modules_test.go index 1a8d0b5d5..b05b0e497 100644 --- a/java/system_modules_test.go +++ b/java/system_modules_test.go @@ -25,7 +25,7 @@ func getModuleHeaderJarsAsRelativeToTopPaths(result *android.TestResult, moduleN paths := []string{} for _, moduleName := range moduleNames { module := result.Module(moduleName, "android_common") - info, _ := android.SingletonModuleProvider(result, module, JavaInfoProvider) + info, _ := android.OtherModuleProvider(result, module, JavaInfoProvider) paths = append(paths, info.HeaderJars.RelativeToTop().Strings()...) } return paths diff --git a/java/test_spec_test.go b/java/test_spec_test.go index 4144dad69..f0a5fdb4b 100644 --- a/java/test_spec_test.go +++ b/java/test_spec_test.go @@ -32,7 +32,7 @@ func TestTestSpec(t *testing.T) { module := result.ModuleForTests("module-name", "") // Check that the provider has the right contents - data, _ := android.SingletonModuleProvider(result, module.Module(), soongTesting.TestSpecProviderKey) + data, _ := android.OtherModuleProvider(result, module.Module(), soongTesting.TestSpecProviderKey) if !strings.HasSuffix( data.IntermediatePath.String(), "/intermediateTestSpecMetadata.pb", ) { diff --git a/java/testing.go b/java/testing.go index 8158bb0a1..7a852771f 100644 --- a/java/testing.go +++ b/java/testing.go @@ -633,7 +633,7 @@ func CheckPlatformBootclasspathModules(t *testing.T, result *android.TestResult, func CheckClasspathFragmentProtoContentInfoProvider(t *testing.T, result *android.TestResult, generated bool, contents, outputFilename, installDir string) { t.Helper() p := result.Module("platform-bootclasspath", "android_common").(*platformBootclasspathModule) - info, _ := android.SingletonModuleProvider(result, p, ClasspathFragmentProtoContentInfoProvider) + info, _ := android.OtherModuleProvider(result, p, ClasspathFragmentProtoContentInfoProvider) android.AssertBoolEquals(t, "classpath proto generated", generated, info.ClasspathFragmentProtoGenerated) android.AssertStringEquals(t, "classpath proto contents", contents, info.ClasspathFragmentProtoContents.String()) @@ -653,7 +653,7 @@ func ApexNamePairsFromModules(ctx *android.TestContext, modules []android.Module func apexNamePairFromModule(ctx *android.TestContext, module android.Module) string { name := module.Name() var apex string - apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider) + apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider) if apexInfo.IsForPlatform() { apex = "platform" } else { diff --git a/testing/all_code_metadata.go b/testing/all_code_metadata.go index 12aa7b51f..e89b28155 100644 --- a/testing/all_code_metadata.go +++ b/testing/all_code_metadata.go @@ -21,7 +21,7 @@ func (this *allCodeMetadataSingleton) GenerateBuildActions(ctx android.Singleton ctx.VisitAllModules( func(module android.Module) { - if metadata, ok := android.SingletonModuleProvider(ctx, module, CodeMetadataProviderKey); ok { + if metadata, ok := android.OtherModuleProvider(ctx, module, CodeMetadataProviderKey); ok { intermediateMetadataPaths = append(intermediateMetadataPaths, metadata.IntermediatePath) } }, diff --git a/testing/all_test_specs.go b/testing/all_test_specs.go index b035435db..68f24d15c 100644 --- a/testing/all_test_specs.go +++ b/testing/all_test_specs.go @@ -21,7 +21,7 @@ func (this *allTestSpecsSingleton) GenerateBuildActions(ctx android.SingletonCon var intermediateMetadataPaths android.Paths ctx.VisitAllModules(func(module android.Module) { - if metadata, ok := android.SingletonModuleProvider(ctx, module, TestSpecProviderKey); ok { + if metadata, ok := android.OtherModuleProvider(ctx, module, TestSpecProviderKey); ok { intermediateMetadataPaths = append(intermediateMetadataPaths, metadata.IntermediatePath) } })