Convert ModuleProvder to generic providers API
Convert all of the callers of ModuleProvider/ModuleHasProvider to use the type-safe android.SingletonModuleProvider API. Bug: 316410648 Test: builds Change-Id: I6f11638546b64749e451cebbf33140248dc1d193
This commit is contained in:
@@ -52,7 +52,7 @@ func TestAarImportProducesJniPackages(t *testing.T) {
|
||||
appMod := ctx.Module(tc.name, "android_common")
|
||||
appTestMod := ctx.ModuleForTests(tc.name, "android_common")
|
||||
|
||||
info, ok := ctx.ModuleProvider(appMod, JniPackageProvider).(JniPackageInfo)
|
||||
info, ok := android.SingletonModuleProvider(ctx, appMod, JniPackageProvider)
|
||||
if !ok {
|
||||
t.Errorf("expected android_library_import to have JniPackageProvider")
|
||||
}
|
||||
|
@@ -272,7 +272,7 @@ func TestBootclasspathFragment_StubLibs(t *testing.T) {
|
||||
`)
|
||||
|
||||
fragment := result.Module("myfragment", "android_common")
|
||||
info := result.ModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
|
||||
info, _ := android.SingletonModuleProvider(result, fragment, HiddenAPIInfoProvider)
|
||||
|
||||
stubsJar := "out/soong/.intermediates/mystublib/android_common/dex/mystublib.jar"
|
||||
|
||||
@@ -456,7 +456,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 := result.ModuleProvider(library, hiddenAPIPropertyInfoProvider).(HiddenAPIPropertyInfo)
|
||||
info, _ := android.SingletonModuleProvider(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)
|
||||
|
@@ -30,9 +30,7 @@ func TestCodeMetadata(t *testing.T) {
|
||||
).Module().(*soongTesting.CodeMetadataModule)
|
||||
|
||||
// Check that the provider has the right contents
|
||||
data := result.ModuleProvider(
|
||||
module, soongTesting.CodeMetadataProviderKey,
|
||||
).(soongTesting.CodeMetadataProviderData)
|
||||
data, _ := android.SingletonModuleProvider(result, module, soongTesting.CodeMetadataProviderKey)
|
||||
if !strings.HasSuffix(
|
||||
data.IntermediatePath.String(), "/intermediateCodeMetadata.pb",
|
||||
) {
|
||||
|
@@ -2226,7 +2226,8 @@ func TestTransitiveSrcFiles(t *testing.T) {
|
||||
}
|
||||
`)
|
||||
c := ctx.ModuleForTests("c", "android_common").Module()
|
||||
transitiveSrcFiles := android.Paths(ctx.ModuleProvider(c, JavaInfoProvider).(JavaInfo).TransitiveSrcFiles.ToList())
|
||||
javaInfo, _ := android.SingletonModuleProvider(ctx, c, JavaInfoProvider)
|
||||
transitiveSrcFiles := android.Paths(javaInfo.TransitiveSrcFiles.ToList())
|
||||
android.AssertArrayString(t, "unexpected jar deps", []string{"b.java", "c.java"}, transitiveSrcFiles.Strings())
|
||||
}
|
||||
|
||||
|
@@ -89,8 +89,7 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont
|
||||
dpInfo.Classes = append(dpInfo.Classes, data.Class)
|
||||
}
|
||||
|
||||
if ctx.ModuleHasProvider(module, JavaInfoProvider) {
|
||||
dep := ctx.ModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||
if dep, ok := android.SingletonModuleProvider(ctx, module, JavaInfoProvider); ok {
|
||||
dpInfo.Installed_paths = append(dpInfo.Installed_paths, dep.ImplementationJars.Strings()...)
|
||||
}
|
||||
dpInfo.Classes = android.FirstUniqueStrings(dpInfo.Classes)
|
||||
|
@@ -660,7 +660,7 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) {
|
||||
}
|
||||
|
||||
if apex, ok := m.(android.ApexModule); ok && apex.NotAvailableForPlatform() {
|
||||
apexInfo := ctx.ModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo)
|
||||
apexInfo, _ := android.SingletonModuleProvider(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.
|
||||
|
@@ -262,8 +262,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 ctx.ModuleHasProvider(module, JavaInfoProvider) {
|
||||
j := ctx.ModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||
if j, ok := android.SingletonModuleProvider(ctx, module, JavaInfoProvider); ok {
|
||||
name := ctx.ModuleName(module)
|
||||
if i := android.IndexList(name, stubsModules); i != -1 {
|
||||
stubsJars[i] = j.HeaderJars
|
||||
|
@@ -132,7 +132,7 @@ func TestJavaSdkLibrary(t *testing.T) {
|
||||
result.ModuleForTests("foo.api.system.28", "")
|
||||
result.ModuleForTests("foo.api.test.28", "")
|
||||
|
||||
exportedComponentsInfo := result.ModuleProvider(foo.Module(), android.ExportedComponentsInfoProvider).(android.ExportedComponentsInfo)
|
||||
exportedComponentsInfo, _ := android.SingletonModuleProvider(result, foo.Module(), android.ExportedComponentsInfoProvider)
|
||||
expectedFooExportedComponents := []string{
|
||||
"foo-removed.api.public.latest",
|
||||
"foo-removed.api.system.latest",
|
||||
|
@@ -24,7 +24,7 @@ func getModuleHeaderJarsAsRelativeToTopPaths(result *android.TestResult, moduleN
|
||||
paths := []string{}
|
||||
for _, moduleName := range moduleNames {
|
||||
module := result.Module(moduleName, "android_common")
|
||||
info := result.ModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||
info, _ := android.SingletonModuleProvider(result, module, JavaInfoProvider)
|
||||
paths = append(paths, info.HeaderJars.RelativeToTop().Strings()...)
|
||||
}
|
||||
return paths
|
||||
|
@@ -34,9 +34,7 @@ func TestTestSpec(t *testing.T) {
|
||||
).Module().(*soongTesting.TestSpecModule)
|
||||
|
||||
// Check that the provider has the right contents
|
||||
data := result.ModuleProvider(
|
||||
module, soongTesting.TestSpecProviderKey,
|
||||
).(soongTesting.TestSpecProviderData)
|
||||
data, _ := android.SingletonModuleProvider(result, module, soongTesting.TestSpecProviderKey)
|
||||
if !strings.HasSuffix(
|
||||
data.IntermediatePath.String(), "/intermediateTestSpecMetadata.pb",
|
||||
) {
|
||||
|
@@ -617,7 +617,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 := result.ModuleProvider(p, ClasspathFragmentProtoContentInfoProvider).(ClasspathFragmentProtoContentInfo)
|
||||
info, _ := android.SingletonModuleProvider(result, p, ClasspathFragmentProtoContentInfoProvider)
|
||||
|
||||
android.AssertBoolEquals(t, "classpath proto generated", generated, info.ClasspathFragmentProtoGenerated)
|
||||
android.AssertStringEquals(t, "classpath proto contents", contents, info.ClasspathFragmentProtoContents.String())
|
||||
@@ -637,7 +637,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 := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
||||
apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)
|
||||
if apexInfo.IsForPlatform() {
|
||||
apex = "platform"
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user