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:
parent
313aa5475f
commit
5a37718c95
31 changed files with 51 additions and 88 deletions
|
@ -38,7 +38,7 @@ func TestAconfigDeclarations(t *testing.T) {
|
|||
module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)
|
||||
|
||||
// Check that the provider has the right contents
|
||||
depData := result.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData)
|
||||
depData, _ := android.SingletonModuleProvider(result, module, DeclarationsProviderKey)
|
||||
android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
|
||||
android.AssertStringEquals(t, "container", depData.Container, "com.android.foo")
|
||||
if !strings.HasSuffix(depData.IntermediateCacheOutputPath.String(), "/intermediate.pb") {
|
||||
|
|
|
@ -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 := result.ModuleProvider(module, valueSetProviderKey).(valueSetProviderData)
|
||||
depData, _ := android.SingletonModuleProvider(result, module, valueSetProviderKey)
|
||||
android.AssertStringEquals(t, "AvailablePackages", "blah.aconfig_values", depData.AvailablePackages["foo.package"][0].String())
|
||||
}
|
||||
|
|
|
@ -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 := result.ModuleProvider(module, valuesProviderKey).(valuesProviderData)
|
||||
depData, _ := android.SingletonModuleProvider(result, module, valuesProviderKey)
|
||||
android.AssertStringEquals(t, "package", "foo.package", depData.Package)
|
||||
android.AssertPathsEndWith(t, "srcs", []string{"blah.aconfig_values"}, depData.Values)
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.Si
|
|||
// Find all of the aconfig_declarations modules
|
||||
var cacheFiles android.Paths
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
if !ctx.ModuleHasProvider(module, DeclarationsProviderKey) {
|
||||
decl, ok := android.SingletonModuleProvider(ctx, module, DeclarationsProviderKey)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
decl := ctx.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData)
|
||||
cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath)
|
||||
})
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ func (this *exportedJavaDeclarationsLibrarySingleton) GenerateBuildActions(ctx a
|
|||
// Find all of the aconfig_declarations modules
|
||||
var cacheFiles android.Paths
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
if !ctx.ModuleHasProvider(module, DeclarationsProviderKey) {
|
||||
decl, ok := android.SingletonModuleProvider(ctx, module, DeclarationsProviderKey)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
decl := ctx.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData)
|
||||
cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath)
|
||||
})
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ func TestAidlLibrary(t *testing.T) {
|
|||
).RunTest(t).TestContext
|
||||
|
||||
foo := ctx.ModuleForTests("foo", "").Module().(*AidlLibrary)
|
||||
actualInfo := ctx.ModuleProvider(foo, AidlLibraryProvider).(AidlLibraryInfo)
|
||||
actualInfo, _ := android.SingletonModuleProvider(ctx, foo, AidlLibraryProvider)
|
||||
|
||||
android.AssertArrayString(
|
||||
t,
|
||||
|
@ -95,7 +95,7 @@ func TestAidlLibraryWithoutStripImportPrefix(t *testing.T) {
|
|||
).RunTest(t).TestContext
|
||||
|
||||
foo := ctx.ModuleForTests("foo", "").Module().(*AidlLibrary)
|
||||
actualInfo := ctx.ModuleProvider(foo, AidlLibraryProvider).(AidlLibraryInfo)
|
||||
actualInfo, _ := android.SingletonModuleProvider(ctx, foo, AidlLibraryProvider)
|
||||
|
||||
android.AssertArrayString(
|
||||
t,
|
||||
|
|
|
@ -492,8 +492,6 @@ type fillInEntriesContext interface {
|
|||
ModuleDir(module blueprint.Module) string
|
||||
ModuleSubDir(module blueprint.Module) string
|
||||
Config() Config
|
||||
ModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) any
|
||||
ModuleHasProvider(module blueprint.Module, provider blueprint.AnyProviderKey) bool
|
||||
moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
|
||||
ModuleType(module blueprint.Module) string
|
||||
}
|
||||
|
|
|
@ -92,7 +92,6 @@ 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
|
||||
moduleProvider(module blueprint.Module, key blueprint.AnyProviderKey) (any, bool)
|
||||
BlueprintFile(module blueprint.Module) string
|
||||
|
||||
|
|
|
@ -35,16 +35,6 @@ 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 returns the value, if any, for the provider for a module. If the value for the
|
||||
// provider was not set it returns the zero value of the type of the provider, which means the
|
||||
// return value can always be type-asserted to the type of the provider. The return value should
|
||||
// always be considered read-only. It panics if called before the appropriate mutator or
|
||||
// GenerateBuildActions pass for the provider on the module.
|
||||
ModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) any
|
||||
|
||||
// ModuleHasProvider returns true if the provider for the given module has been set.
|
||||
ModuleHasProvider(module blueprint.Module, provider blueprint.AnyProviderKey) bool
|
||||
|
||||
moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
|
||||
|
||||
ModuleErrorf(module blueprint.Module, format string, args ...interface{})
|
||||
|
@ -291,17 +281,6 @@ func (s *singletonContextAdaptor) ModuleVariantsFromName(referer Module, name st
|
|||
return result
|
||||
}
|
||||
|
||||
func (s *singletonContextAdaptor) ModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) any {
|
||||
value, _ := s.SingletonContext.ModuleProvider(module, provider)
|
||||
return value
|
||||
}
|
||||
|
||||
// ModuleHasProvider returns true if the provider for the given module has been set.
|
||||
func (s *singletonContextAdaptor) ModuleHasProvider(module blueprint.Module, provider blueprint.AnyProviderKey) bool {
|
||||
_, ok := s.SingletonContext.ModuleProvider(module, provider)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (s *singletonContextAdaptor) moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
|
||||
return s.SingletonContext.ModuleProvider(module, provider)
|
||||
}
|
||||
|
|
|
@ -83,7 +83,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 := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
||||
apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)
|
||||
if path := binaryInfo.FlatListPath(); path != nil {
|
||||
if binaryInfo.Updatable() || apexInfo.Updatable {
|
||||
updatableFlatLists = append(updatableFlatLists, path)
|
||||
|
|
|
@ -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 := result.ModuleProvider(artFragment, java.HiddenAPIInfoProvider).(java.HiddenAPIInfo)
|
||||
artInfo, _ := android.SingletonModuleProvider(result, artFragment, java.HiddenAPIInfoProvider)
|
||||
|
||||
bazPublicStubs := "out/soong/.intermediates/baz.stubs/android_common/dex/baz.stubs.jar"
|
||||
bazSystemStubs := "out/soong/.intermediates/baz.stubs.system/android_common/dex/baz.stubs.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 := result.ModuleProvider(otherFragment, java.HiddenAPIInfoProvider).(java.HiddenAPIInfo)
|
||||
otherInfo, _ := android.SingletonModuleProvider(result, otherFragment, java.HiddenAPIInfoProvider)
|
||||
|
||||
fooPublicStubs := "out/soong/.intermediates/foo.stubs/android_common/dex/foo.stubs.jar"
|
||||
fooSystemStubs := "out/soong/.intermediates/foo.stubs.system/android_common/dex/foo.stubs.system.jar"
|
||||
|
@ -655,7 +655,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 := result.ModuleProvider(fragment, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
|
||||
info, _ := android.SingletonModuleProvider(result, fragment, java.BootclasspathFragmentApexContentInfoProvider)
|
||||
|
||||
checkFragmentExportedDexJar := func(name string, expectedDexJar string) {
|
||||
module := result.Module(name, "android_common_apex10000")
|
||||
|
|
|
@ -152,7 +152,7 @@ func TestPlatformBootclasspath_Fragments(t *testing.T) {
|
|||
).RunTest(t)
|
||||
|
||||
pbcp := result.Module("platform-bootclasspath", "android_common")
|
||||
info := result.ModuleProvider(pbcp, java.MonolithicHiddenAPIInfoProvider).(java.MonolithicHiddenAPIInfo)
|
||||
info, _ := android.SingletonModuleProvider(result, pbcp, java.MonolithicHiddenAPIInfoProvider)
|
||||
|
||||
for _, category := range java.HiddenAPIFlagFileCategories {
|
||||
name := category.PropertyName
|
||||
|
@ -234,7 +234,7 @@ func TestPlatformBootclasspath_LegacyPrebuiltFragment(t *testing.T) {
|
|||
)
|
||||
|
||||
pbcp := result.Module("myplatform-bootclasspath", "android_common")
|
||||
info := result.ModuleProvider(pbcp, java.MonolithicHiddenAPIInfoProvider).(java.MonolithicHiddenAPIInfo)
|
||||
info, _ := android.SingletonModuleProvider(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())
|
||||
|
|
|
@ -85,10 +85,10 @@ func fileSizesSingleton() android.Singleton {
|
|||
func (singleton *sizesSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
var deps android.Paths
|
||||
ctx.VisitAllModules(func(m android.Module) {
|
||||
if !ctx.ModuleHasProvider(m, fileSizeMeasurerKey) {
|
||||
filePaths, ok := android.SingletonModuleProvider(ctx, m, fileSizeMeasurerKey)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
filePaths := ctx.ModuleProvider(m, fileSizeMeasurerKey).(measuredFiles)
|
||||
for _, path := range filePaths.paths {
|
||||
filePath := path.(android.ModuleOutPath)
|
||||
sizeFile := filePath.InSameDir(ctx, filePath.Base()+bloatyDescriptorExt)
|
||||
|
|
|
@ -2544,8 +2544,8 @@ func TestStaticLibDepReordering(t *testing.T) {
|
|||
|
||||
variant := "android_arm64_armv8-a_static"
|
||||
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
||||
actual := android.Paths(ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).
|
||||
TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop()
|
||||
staticLibInfo, _ := android.SingletonModuleProvider(ctx, moduleA, StaticLibraryInfoProvider)
|
||||
actual := android.Paths(staticLibInfo.TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop()
|
||||
expected := GetOutputPaths(ctx, variant, []string{"a", "c", "b", "d"})
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
|
@ -2580,8 +2580,8 @@ func TestStaticLibDepReorderingWithShared(t *testing.T) {
|
|||
|
||||
variant := "android_arm64_armv8-a_static"
|
||||
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
||||
actual := android.Paths(ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).
|
||||
TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop()
|
||||
staticLibInfo, _ := android.SingletonModuleProvider(ctx, moduleA, StaticLibraryInfoProvider)
|
||||
actual := android.Paths(staticLibInfo.TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop()
|
||||
expected := GetOutputPaths(ctx, variant, []string{"a", "c", "b"})
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
|
@ -2681,7 +2681,7 @@ func TestLlndkLibrary(t *testing.T) {
|
|||
checkExportedIncludeDirs := func(module, variant string, expectedDirs ...string) {
|
||||
t.Helper()
|
||||
m := result.ModuleForTests(module, variant).Module()
|
||||
f := result.ModuleProvider(m, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||
f, _ := android.SingletonModuleProvider(result, m, FlagExporterInfoProvider)
|
||||
android.AssertPathsRelativeToTopEquals(t, "exported include dirs for "+module+"["+variant+"]",
|
||||
expectedDirs, f.IncludeDirs)
|
||||
}
|
||||
|
@ -4113,7 +4113,7 @@ func TestIncludeDirsExporting(t *testing.T) {
|
|||
|
||||
checkIncludeDirs := func(t *testing.T, ctx *android.TestContext, module android.Module, checkers ...exportedChecker) {
|
||||
t.Helper()
|
||||
exported := ctx.ModuleProvider(module, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||
exported, _ := android.SingletonModuleProvider(ctx, module, FlagExporterInfoProvider)
|
||||
name := module.Name()
|
||||
|
||||
for _, checker := range checkers {
|
||||
|
|
|
@ -22,8 +22,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
)
|
||||
|
||||
var prepareForAsanTest = android.FixtureAddFile("asan/Android.bp", []byte(`
|
||||
|
@ -49,7 +47,7 @@ var prepareForTsanTest = android.FixtureAddFile("tsan/Android.bp", []byte(`
|
|||
`))
|
||||
|
||||
type providerInterface interface {
|
||||
ModuleProvider(blueprint.Module, blueprint.AnyProviderKey) interface{}
|
||||
android.SingletonModuleProviderContext
|
||||
}
|
||||
|
||||
// expectSharedLinkDep verifies that the from module links against the to module as a
|
||||
|
@ -57,7 +55,7 @@ type providerInterface interface {
|
|||
func expectSharedLinkDep(t *testing.T, ctx providerInterface, from, to android.TestingModule) {
|
||||
t.Helper()
|
||||
fromLink := from.Description("link")
|
||||
toInfo := ctx.ModuleProvider(to.Module(), SharedLibraryInfoProvider).(SharedLibraryInfo)
|
||||
toInfo, _ := android.SingletonModuleProvider(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",
|
||||
|
@ -70,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 := ctx.ModuleProvider(to.Module(), SharedLibraryInfoProvider).(SharedLibraryInfo)
|
||||
toInfo, _ := android.SingletonModuleProvider(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",
|
||||
|
@ -83,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 := ctx.ModuleProvider(to.Module(), StaticLibraryInfoProvider).(StaticLibraryInfo)
|
||||
toInfo, _ := android.SingletonModuleProvider(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",
|
||||
|
@ -97,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 := ctx.ModuleProvider(to.Module(), StaticLibraryInfoProvider).(StaticLibraryInfo)
|
||||
toInfo, _ := android.SingletonModuleProvider(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",
|
||||
|
|
|
@ -275,7 +275,7 @@ var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotS
|
|||
var propOut string
|
||||
|
||||
if m.IsSnapshotLibrary() {
|
||||
exporterInfo := ctx.ModuleProvider(m.Module(), FlagExporterInfoProvider).(FlagExporterInfo)
|
||||
exporterInfo, _ := android.SingletonModuleProvider(ctx, m.Module(), FlagExporterInfoProvider)
|
||||
|
||||
// library flags
|
||||
prop.ExportedFlags = exporterInfo.Flags
|
||||
|
@ -407,7 +407,7 @@ var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotS
|
|||
|
||||
moduleDir := ctx.ModuleDir(module)
|
||||
inProprietaryPath := s.Image.IsProprietaryPath(moduleDir, ctx.DeviceConfig())
|
||||
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
||||
apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)
|
||||
|
||||
if s.Image.ExcludeFromSnapshot(m) {
|
||||
if inProprietaryPath {
|
||||
|
|
|
@ -772,7 +772,7 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
|
|||
prop.MinSdkVersion = m.MinSdkVersion()
|
||||
|
||||
if ctx.Config().VndkSnapshotBuildArtifacts() {
|
||||
exportedInfo := ctx.ModuleProvider(m, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||
exportedInfo, _ := android.SingletonModuleProvider(ctx, m, FlagExporterInfoProvider)
|
||||
prop.ExportedFlags = exportedInfo.Flags
|
||||
prop.ExportedDirs = exportedInfo.IncludeDirs.Strings()
|
||||
prop.ExportedSystemDirs = exportedInfo.SystemIncludeDirs.Strings()
|
||||
|
@ -797,7 +797,7 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
|
|||
return
|
||||
}
|
||||
|
||||
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
||||
apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)
|
||||
|
||||
vndkType, ok := isVndkSnapshotAware(ctx.DeviceConfig(), m, apexInfo)
|
||||
if !ok {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -119,7 +119,7 @@ func (c *hostFakeSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||
if !module.Enabled() || module.IsHideFromMake() {
|
||||
return
|
||||
}
|
||||
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
||||
apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)
|
||||
if !apexInfo.IsForPlatform() {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -21,14 +21,9 @@ func (this *allCodeMetadataSingleton) GenerateBuildActions(ctx android.Singleton
|
|||
|
||||
ctx.VisitAllModules(
|
||||
func(module android.Module) {
|
||||
if !ctx.ModuleHasProvider(module, CodeMetadataProviderKey) {
|
||||
return
|
||||
if metadata, ok := android.SingletonModuleProvider(ctx, module, CodeMetadataProviderKey); ok {
|
||||
intermediateMetadataPaths = append(intermediateMetadataPaths, metadata.IntermediatePath)
|
||||
}
|
||||
intermediateMetadataPaths = append(
|
||||
intermediateMetadataPaths, ctx.ModuleProvider(
|
||||
module, CodeMetadataProviderKey,
|
||||
).(CodeMetadataProviderData).IntermediatePath,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -21,10 +21,9 @@ func (this *allTestSpecsSingleton) GenerateBuildActions(ctx android.SingletonCon
|
|||
var intermediateMetadataPaths android.Paths
|
||||
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
if !ctx.ModuleHasProvider(module, TestSpecProviderKey) {
|
||||
return
|
||||
if metadata, ok := android.SingletonModuleProvider(ctx, module, TestSpecProviderKey); ok {
|
||||
intermediateMetadataPaths = append(intermediateMetadataPaths, metadata.IntermediatePath)
|
||||
}
|
||||
intermediateMetadataPaths = append(intermediateMetadataPaths, ctx.ModuleProvider(module, TestSpecProviderKey).(TestSpecProviderData).IntermediatePath)
|
||||
})
|
||||
|
||||
rspFile := android.PathForOutput(ctx, fileContainingFilePaths)
|
||||
|
|
Loading…
Reference in a new issue