Merge SingletonProviderContext with OtherModuleProviderContext

Bug: 358425833
Test: CI
Change-Id: I8e3f40dc3cfc5337008b419801f8e6bf2d48e8b2
This commit is contained in:
Yu Liu
2024-08-12 18:23:59 +00:00
parent 703c2e3d64
commit 663e4508dc
38 changed files with 74 additions and 89 deletions

View File

@@ -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")
}

View File

@@ -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)

View File

@@ -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",
) {

View File

@@ -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())

View File

@@ -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())
}

View File

@@ -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())
}

View File

@@ -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)

View File

@@ -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.

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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",
) {

View File

@@ -632,7 +632,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())
@@ -652,7 +652,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 {