Merge "Properly package aconfig files for product and system_ext partitions" into main
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go
index 8cadd21..14438c8 100644
--- a/aconfig/aconfig_declarations.go
+++ b/aconfig/aconfig_declarations.go
@@ -134,16 +134,13 @@
// Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag
valuesFiles := make([]android.Path, 0)
ctx.VisitDirectDeps(func(dep android.Module) {
- if !ctx.OtherModuleHasProvider(dep, valueSetProviderKey) {
- // Other modules get injected as dependencies too, for example the license modules
- return
- }
- depData := ctx.OtherModuleProvider(dep, valueSetProviderKey).(valueSetProviderData)
- paths, ok := depData.AvailablePackages[module.properties.Package]
- if ok {
- valuesFiles = append(valuesFiles, paths...)
- for _, path := range paths {
- module.properties.Values = append(module.properties.Values, path.String())
+ if depData, ok := android.OtherModuleProvider(ctx, dep, valueSetProviderKey); ok {
+ paths, ok := depData.AvailablePackages[module.properties.Package]
+ if ok {
+ valuesFiles = append(valuesFiles, paths...)
+ for _, path := range paths {
+ module.properties.Values = append(module.properties.Values, path.String())
+ }
}
}
})
@@ -177,7 +174,7 @@
Description: "aconfig_text",
})
- ctx.SetProvider(DeclarationsProviderKey, DeclarationsProviderData{
+ android.SetProvider(ctx, DeclarationsProviderKey, DeclarationsProviderData{
Package: module.properties.Package,
Container: module.properties.Container,
IntermediateCacheOutputPath: intermediateCacheFilePath,
@@ -190,11 +187,11 @@
*mergedAconfigFiles = make(map[string]android.Paths)
}
ctx.VisitDirectDeps(func(module android.Module) {
- if dep := ctx.OtherModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData); dep.IntermediateCacheOutputPath != nil {
+ if dep, _ := android.OtherModuleProvider(ctx, module, DeclarationsProviderKey); dep.IntermediateCacheOutputPath != nil {
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath)
return
}
- if dep := ctx.OtherModuleProvider(module, TransitiveDeclarationsInfoProvider).(TransitiveDeclarationsInfo); len(dep.AconfigFiles) > 0 {
+ if dep, _ := android.OtherModuleProvider(ctx, module, TransitiveDeclarationsInfoProvider); len(dep.AconfigFiles) > 0 {
for container, v := range dep.AconfigFiles {
(*mergedAconfigFiles)[container] = append((*mergedAconfigFiles)[container], v...)
}
@@ -205,7 +202,7 @@
(*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, aconfigFiles)
}
- ctx.SetProvider(TransitiveDeclarationsInfoProvider, TransitiveDeclarationsInfo{
+ android.SetProvider(ctx, TransitiveDeclarationsInfoProvider, TransitiveDeclarationsInfo{
AconfigFiles: *mergedAconfigFiles,
})
}
diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go
index 9035c71..1b4acab 100644
--- a/aconfig/aconfig_declarations_test.go
+++ b/aconfig/aconfig_declarations_test.go
@@ -38,7 +38,7 @@
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") {
diff --git a/aconfig/aconfig_value_set.go b/aconfig/aconfig_value_set.go
index 4f142e5..7ba76c0 100644
--- a/aconfig/aconfig_value_set.go
+++ b/aconfig/aconfig_value_set.go
@@ -73,18 +73,14 @@
// to append values to their aconfig actions.
packages := make(map[string]android.Paths)
ctx.VisitDirectDeps(func(dep android.Module) {
- if !ctx.OtherModuleHasProvider(dep, valuesProviderKey) {
- // Other modules get injected as dependencies too, for example the license modules
- return
+ if depData, ok := android.OtherModuleProvider(ctx, dep, valuesProviderKey); ok {
+ srcs := make([]android.Path, len(depData.Values))
+ copy(srcs, depData.Values)
+ packages[depData.Package] = srcs
}
- depData := ctx.OtherModuleProvider(dep, valuesProviderKey).(valuesProviderData)
-
- srcs := make([]android.Path, len(depData.Values))
- copy(srcs, depData.Values)
- packages[depData.Package] = srcs
})
- ctx.SetProvider(valueSetProviderKey, valueSetProviderData{
+ android.SetProvider(ctx, valueSetProviderKey, valueSetProviderData{
AvailablePackages: packages,
})
}
diff --git a/aconfig/aconfig_value_set_test.go b/aconfig/aconfig_value_set_test.go
index 9127872..7d18999 100644
--- a/aconfig/aconfig_value_set_test.go
+++ b/aconfig/aconfig_value_set_test.go
@@ -38,6 +38,6 @@
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())
}
diff --git a/aconfig/aconfig_values.go b/aconfig/aconfig_values.go
index 10205bb..239b10c 100644
--- a/aconfig/aconfig_values.go
+++ b/aconfig/aconfig_values.go
@@ -64,5 +64,5 @@
Package: module.properties.Package,
Values: android.PathsForModuleSrc(ctx, module.properties.Srcs),
}
- ctx.SetProvider(valuesProviderKey, providerData)
+ android.SetProvider(ctx, valuesProviderKey, providerData)
}
diff --git a/aconfig/aconfig_values_test.go b/aconfig/aconfig_values_test.go
index ab457f0..526579c 100644
--- a/aconfig/aconfig_values_test.go
+++ b/aconfig/aconfig_values_test.go
@@ -33,7 +33,7 @@
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)
}
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go
index 2686e76..d860498 100644
--- a/aconfig/all_aconfig_declarations.go
+++ b/aconfig/all_aconfig_declarations.go
@@ -37,10 +37,10 @@
// 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)
})
diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go
index 30f6863..2c8369b 100644
--- a/aconfig/codegen/cc_aconfig_library.go
+++ b/aconfig/codegen/cc_aconfig_library.go
@@ -92,7 +92,7 @@
if len(declarationsModules) != 1 {
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
}
- declarations := ctx.OtherModuleProvider(declarationsModules[0], aconfig.DeclarationsProviderKey).(aconfig.DeclarationsProviderData)
+ declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], aconfig.DeclarationsProviderKey)
// Figure out the generated file paths. This has to match aconfig's codegen_cpp.rs.
this.generatedDir = android.PathForModuleGen(ctx)
@@ -122,7 +122,7 @@
if len(declarationsModules) != 1 {
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
}
- declarations := ctx.OtherModuleProvider(declarationsModules[0], aconfig.DeclarationsProviderKey).(aconfig.DeclarationsProviderData)
+ declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], aconfig.DeclarationsProviderKey)
mode := proptools.StringDefault(this.properties.Mode, "production")
if !isModeSupported(mode) {
diff --git a/aconfig/codegen/java_aconfig_library.go b/aconfig/codegen/java_aconfig_library.go
index 202e358..b33481b 100644
--- a/aconfig/codegen/java_aconfig_library.go
+++ b/aconfig/codegen/java_aconfig_library.go
@@ -74,7 +74,7 @@
if len(declarationsModules) != 1 {
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
}
- declarations := ctx.OtherModuleProvider(declarationsModules[0], aconfig.DeclarationsProviderKey).(aconfig.DeclarationsProviderData)
+ declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], aconfig.DeclarationsProviderKey)
// Generate the action to build the srcjar
srcJarPath := android.PathForModuleGen(ctx, ctx.ModuleName()+".srcjar")
diff --git a/aconfig/codegen/rust_aconfig_library.go b/aconfig/codegen/rust_aconfig_library.go
index e587056..88f5b45 100644
--- a/aconfig/codegen/rust_aconfig_library.go
+++ b/aconfig/codegen/rust_aconfig_library.go
@@ -65,7 +65,7 @@
if len(declarationsModules) != 1 {
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
}
- declarations := ctx.OtherModuleProvider(declarationsModules[0], aconfig.DeclarationsProviderKey).(aconfig.DeclarationsProviderData)
+ declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], aconfig.DeclarationsProviderKey)
mode := proptools.StringDefault(a.Properties.Mode, "production")
if !isModeSupported(mode) {
diff --git a/aconfig/exported_java_aconfig_library.go b/aconfig/exported_java_aconfig_library.go
index 45c5e39..8644810 100644
--- a/aconfig/exported_java_aconfig_library.go
+++ b/aconfig/exported_java_aconfig_library.go
@@ -30,10 +30,10 @@
// 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)
})
diff --git a/aidl_library/aidl_library.go b/aidl_library/aidl_library.go
index c2f97d9..0141545 100644
--- a/aidl_library/aidl_library.go
+++ b/aidl_library/aidl_library.go
@@ -99,14 +99,13 @@
includeDirsDepSetBuilder.Direct(includeDir)
for _, dep := range ctx.GetDirectDepsWithTag(aidlLibraryTag) {
- if ctx.OtherModuleHasProvider(dep, AidlLibraryProvider) {
- info := ctx.OtherModuleProvider(dep, AidlLibraryProvider).(AidlLibraryInfo)
+ if info, ok := android.OtherModuleProvider(ctx, dep, AidlLibraryProvider); ok {
includeDirsDepSetBuilder.Transitive(&info.IncludeDirs)
hdrsDepSetBuilder.Transitive(&info.Hdrs)
}
}
- ctx.SetProvider(AidlLibraryProvider, AidlLibraryInfo{
+ android.SetProvider(ctx, AidlLibraryProvider, AidlLibraryInfo{
Srcs: srcs,
IncludeDirs: *includeDirsDepSetBuilder.Build(),
Hdrs: *hdrsDepSetBuilder.Build(),
diff --git a/aidl_library/aidl_library_test.go b/aidl_library/aidl_library_test.go
index 0205629..01eab0e 100644
--- a/aidl_library/aidl_library_test.go
+++ b/aidl_library/aidl_library_test.go
@@ -46,7 +46,7 @@
).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 @@
).RunTest(t).TestContext
foo := ctx.ModuleForTests("foo", "").Module().(*AidlLibrary)
- actualInfo := ctx.ModuleProvider(foo, AidlLibraryProvider).(AidlLibraryInfo)
+ actualInfo, _ := android.SingletonModuleProvider(ctx, foo, AidlLibraryProvider)
android.AssertArrayString(
t,
diff --git a/android/androidmk.go b/android/androidmk.go
index 097075e..a0ed1e4 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -492,8 +492,6 @@
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
}
@@ -624,8 +622,7 @@
}
}
- if ctx.ModuleHasProvider(mod, LicenseMetadataProvider) {
- licenseMetadata := ctx.ModuleProvider(mod, LicenseMetadataProvider).(*LicenseMetadataInfo)
+ if licenseMetadata, ok := SingletonModuleProvider(ctx, mod, LicenseMetadataProvider); ok {
a.SetPath("LOCAL_SOONG_LICENSE_METADATA", licenseMetadata.LicenseMetadataPath)
}
diff --git a/android/apex_contributions.go b/android/apex_contributions.go
index 89058fd..34941c0 100644
--- a/android/apex_contributions.go
+++ b/android/apex_contributions.go
@@ -119,7 +119,7 @@
ctx.ModuleErrorf("%s is not an apex_contributions module\n", child.Name())
}
})
- ctx.SetProvider(PrebuiltSelectionInfoProvider, p)
+ SetProvider(ctx, PrebuiltSelectionInfoProvider, p)
}
// A provider containing metadata about whether source or prebuilt should be used
diff --git a/android/deapexer.go b/android/deapexer.go
index a674b42..de933d1 100644
--- a/android/deapexer.go
+++ b/android/deapexer.go
@@ -150,7 +150,7 @@
func FindDeapexerProviderForModule(ctx ModuleContext) *DeapexerInfo {
var di *DeapexerInfo
ctx.VisitDirectDepsWithTag(DeapexerTag, func(m Module) {
- c := ctx.OtherModuleProvider(m, DeapexerProvider).(DeapexerInfo)
+ c, _ := OtherModuleProvider(ctx, m, DeapexerProvider)
p := &c
if di != nil {
// If two DeapexerInfo providers have been found then check if they are
@@ -167,7 +167,7 @@
if di != nil {
return di
}
- ai := ctx.Provider(ApexInfoProvider).(ApexInfo)
+ ai, _ := ModuleProvider(ctx, ApexInfoProvider)
ctx.ModuleErrorf("No prebuilt APEX provides a deapexer module for APEX variant %s", ai.ApexVariationName)
return nil
}
diff --git a/android/filegroup.go b/android/filegroup.go
index 04bd8a8..0aabb68 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -92,7 +92,7 @@
if fg.properties.Path != nil {
fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
}
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: fg.srcs.Strings()})
+ SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: fg.srcs.Strings()})
}
func (fg *fileGroup) Srcs() Paths {
diff --git a/android/license_metadata.go b/android/license_metadata.go
index b2ba5e5..463fd07 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -78,8 +78,7 @@
return
}
- if ctx.OtherModuleHasProvider(dep, LicenseMetadataProvider) {
- info := ctx.OtherModuleProvider(dep, LicenseMetadataProvider).(*LicenseMetadataInfo)
+ if info, ok := OtherModuleProvider(ctx, dep, LicenseMetadataProvider); ok {
allDepMetadataFiles = append(allDepMetadataFiles, info.LicenseMetadataPath)
if isContainer || isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) {
allDepMetadataDepSets = append(allDepMetadataDepSets, info.LicenseMetadataDepSet)
@@ -175,7 +174,7 @@
},
})
- ctx.SetProvider(LicenseMetadataProvider, &LicenseMetadataInfo{
+ SetProvider(ctx, LicenseMetadataProvider, &LicenseMetadataInfo{
LicenseMetadataPath: licenseMetadataFile,
LicenseMetadataDepSet: NewDepSet(TOPOLOGICAL, Paths{licenseMetadataFile}, allDepMetadataDepSets),
})
diff --git a/android/licenses.go b/android/licenses.go
index 45c914f..be1eede 100644
--- a/android/licenses.go
+++ b/android/licenses.go
@@ -230,7 +230,7 @@
licenseInfo := LicenseInfo{
Licenses: licenses,
}
- ctx.SetProvider(LicenseInfoProvider, licenseInfo)
+ SetProvider(ctx, LicenseInfoProvider, licenseInfo)
}
// Update a property string array with a distinct union of its values and a list of new values.
diff --git a/android/makevars.go b/android/makevars.go
index 5a9fe7c..d4cfd29 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -92,7 +92,6 @@
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
diff --git a/android/module.go b/android/module.go
index f571157..7e88797 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1648,7 +1648,7 @@
if !ctx.PrimaryArch() {
suffix = append(suffix, ctx.Arch().ArchType.String())
}
- if apexInfo := ctx.Provider(ApexInfoProvider).(ApexInfo); !apexInfo.IsForPlatform() {
+ if apexInfo, _ := ModuleProvider(ctx, ApexInfoProvider); !apexInfo.IsForPlatform() {
suffix = append(suffix, apexInfo.ApexVariationName)
}
diff --git a/android/prebuilt.go b/android/prebuilt.go
index a32a37d..6a417a8 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -461,8 +461,8 @@
// Propagate the provider received from `all_apex_contributions`
// to the source module
ctx.VisitDirectDepsWithTag(acDepTag, func(am Module) {
- psi := ctx.OtherModuleProvider(am, PrebuiltSelectionInfoProvider).(PrebuiltSelectionInfoMap)
- ctx.SetProvider(PrebuiltSelectionInfoProvider, psi)
+ psi, _ := OtherModuleProvider(ctx, am, PrebuiltSelectionInfoProvider)
+ SetProvider(ctx, PrebuiltSelectionInfoProvider, psi)
})
} else if s, ok := ctx.Module().(Module); ok {
@@ -548,9 +548,7 @@
// Use `all_apex_contributions` for source vs prebuilt selection.
psi := PrebuiltSelectionInfoMap{}
ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(am Module) {
- if ctx.OtherModuleHasProvider(am, PrebuiltSelectionInfoProvider) {
- psi = ctx.OtherModuleProvider(am, PrebuiltSelectionInfoProvider).(PrebuiltSelectionInfoMap)
- }
+ psi, _ = OtherModuleProvider(ctx, am, PrebuiltSelectionInfoProvider)
})
// If the source module is explicitly listed in the metadata module, use that
diff --git a/android/singleton.go b/android/singleton.go
index 8936cac..47cfb28 100644
--- a/android/singleton.go
+++ b/android/singleton.go
@@ -35,16 +35,6 @@
// 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 @@
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)
}
diff --git a/apex/apex.go b/apex/apex.go
index 5372764..56559b1 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1020,7 +1020,7 @@
// The membership information is saved for later access
apexContents := android.NewApexContents(contents)
- mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{
+ android.SetProvider(mctx, ApexBundleInfoProvider, ApexBundleInfo{
Contents: apexContents,
})
@@ -1058,7 +1058,7 @@
})
if a.dynamic_common_lib_apex() {
- mctx.SetProvider(DCLAInfoProvider, DCLAInfo{
+ android.SetProvider(mctx, DCLAInfoProvider, DCLAInfo{
ProvidedLibs: a.properties.Native_shared_libs,
})
}
@@ -1201,10 +1201,10 @@
if _, ok := mctx.Module().(android.ApexModule); ok {
var contents []*android.ApexContents
for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) {
- abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo)
+ abInfo, _ := android.OtherModuleProvider(mctx, testFor, ApexBundleInfoProvider)
contents = append(contents, abInfo.Contents)
}
- mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{
+ android.SetProvider(mctx, android.ApexTestForInfoProvider, android.ApexTestForInfo{
ApexContents: contents,
})
}
@@ -1465,7 +1465,7 @@
panic(fmt.Errorf("expected exactly at most one dcla dependency, got %d", len(dclaModules)))
}
if len(dclaModules) > 0 {
- DCLAInfo := ctx.OtherModuleProvider(dclaModules[0], DCLAInfoProvider).(DCLAInfo)
+ DCLAInfo, _ := android.OtherModuleProvider(ctx, dclaModules[0], DCLAInfoProvider)
return DCLAInfo.ProvidedLibs
}
return []string{}
@@ -1783,7 +1783,7 @@
return false
}
- ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
+ ai, _ := android.OtherModuleProvider(ctx, child, android.ApexInfoProvider)
externalDep := !android.InList(ctx.ModuleName(), ai.InApexVariants)
// Visit actually
@@ -2150,7 +2150,7 @@
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
af.transitiveDep = true
- abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
+ abInfo, _ := android.ModuleProvider(ctx, ApexBundleInfoProvider)
if !abInfo.Contents.DirectlyInApex(depName) && (ch.IsStubs() || ch.HasStubsVariants()) {
// If the dependency is a stubs lib, don't include it in this APEX,
// but make sure that the lib is installed on the device.
@@ -2272,7 +2272,7 @@
}
func addAconfigFiles(vctx *visitorContext, ctx android.ModuleContext, module blueprint.Module) {
- dep := ctx.OtherModuleProvider(module, aconfig.TransitiveDeclarationsInfoProvider).(aconfig.TransitiveDeclarationsInfo)
+ dep, _ := android.OtherModuleProvider(ctx, module, aconfig.TransitiveDeclarationsInfoProvider)
if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil {
vctx.aconfigFiles = append(vctx.aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...)
}
@@ -2376,7 +2376,7 @@
// apexBootclasspathFragmentFiles returns the list of apexFile structures defining the files that
// the bootclasspath_fragment contributes to the apex.
func apexBootclasspathFragmentFiles(ctx android.ModuleContext, module blueprint.Module) []apexFile {
- bootclasspathFragmentInfo := ctx.OtherModuleProvider(module, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
+ bootclasspathFragmentInfo, _ := android.OtherModuleProvider(ctx, module, java.BootclasspathFragmentApexContentInfoProvider)
var filesToAdd []apexFile
// Add classpaths.proto config.
@@ -2425,7 +2425,7 @@
// apexClasspathFragmentProtoFile returns *apexFile structure defining the classpath.proto config that
// the module contributes to the apex; or nil if the proto config was not generated.
func apexClasspathFragmentProtoFile(ctx android.ModuleContext, module blueprint.Module) *apexFile {
- info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
+ info, _ := android.OtherModuleProvider(ctx, module, java.ClasspathFragmentProtoContentInfoProvider)
if !info.ClasspathFragmentProtoGenerated {
return nil
}
@@ -2437,7 +2437,7 @@
// apexFileForBootclasspathFragmentContentModule creates an apexFile for a bootclasspath_fragment
// content module, i.e. a library that is part of the bootclasspath.
func apexFileForBootclasspathFragmentContentModule(ctx android.ModuleContext, fragmentModule blueprint.Module, javaModule javaModule) apexFile {
- bootclasspathFragmentInfo := ctx.OtherModuleProvider(fragmentModule, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
+ bootclasspathFragmentInfo, _ := android.OtherModuleProvider(ctx, fragmentModule, java.BootclasspathFragmentApexContentInfoProvider)
// Get the dexBootJar from the bootclasspath_fragment as that is responsible for performing the
// hidden API encpding.
@@ -2589,7 +2589,7 @@
return
}
- abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
+ abInfo, _ := android.ModuleProvider(ctx, ApexBundleInfoProvider)
a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
if ccm, ok := to.(*cc.Module); ok {
@@ -2650,7 +2650,7 @@
func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) {
ctx.VisitDirectDeps(func(module android.Module) {
if tag := ctx.OtherModuleDependencyTag(module); tag == bcpfTag || tag == sscpfTag {
- info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
+ info, _ := android.OtherModuleProvider(ctx, module, java.ClasspathFragmentProtoContentInfoProvider)
if !info.ClasspathFragmentProtoGenerated {
ctx.OtherModuleErrorf(module, "is included in updatable apex %v, it must not set generate_classpaths_proto to false", ctx.ModuleName())
}
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index a63344f..25c0cc4 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -83,7 +83,7 @@
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)
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index 43be310..42f5cd4 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -152,7 +152,7 @@
// 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 @@
// 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 @@
// 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")
diff --git a/apex/classpath_element_test.go b/apex/classpath_element_test.go
index 1ce60ce..b9a9198 100644
--- a/apex/classpath_element_test.go
+++ b/apex/classpath_element_test.go
@@ -20,7 +20,6 @@
"android/soong/android"
"android/soong/java"
- "github.com/google/blueprint"
)
// Contains tests for java.CreateClasspathElements logic from java/classpath_element.go that
@@ -28,19 +27,12 @@
// testClasspathElementContext is a ClasspathElementContext suitable for use in tests.
type testClasspathElementContext struct {
+ android.OtherModuleProviderContext
testContext *android.TestContext
module android.Module
errs []error
}
-func (t *testClasspathElementContext) OtherModuleHasProvider(module blueprint.Module, provider blueprint.AnyProviderKey) bool {
- return t.testContext.ModuleHasProvider(module, provider)
-}
-
-func (t *testClasspathElementContext) OtherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) interface{} {
- return t.testContext.ModuleProvider(module, provider)
-}
-
func (t *testClasspathElementContext) ModuleErrorf(fmt string, args ...interface{}) {
t.errs = append(t.errs, t.testContext.ModuleErrorf(t.module, fmt, args...))
}
@@ -238,7 +230,11 @@
}
newCtx := func() *testClasspathElementContext {
- return &testClasspathElementContext{testContext: result.TestContext, module: bootclasspath}
+ return &testClasspathElementContext{
+ OtherModuleProviderContext: result.TestContext.OtherModuleProviderAdaptor(),
+ testContext: result.TestContext,
+ module: bootclasspath,
+ }
}
// Verify that CreateClasspathElements works when given valid input.
diff --git a/apex/deapexer.go b/apex/deapexer.go
index 3b7c77d..5aeea63 100644
--- a/apex/deapexer.go
+++ b/apex/deapexer.go
@@ -127,7 +127,7 @@
if len(exports) > 0 {
// Make the information available for other modules.
di := android.NewDeapexerInfo(apexModuleName(ctx.ModuleName()), exports)
- ctx.SetProvider(android.DeapexerProvider, di)
+ android.SetProvider(ctx, android.DeapexerProvider, di)
// Create a sorted list of the files that this exports.
exportedPaths = android.SortedUniquePaths(exportedPaths)
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index 05bb136..b741963 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -152,7 +152,7 @@
).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 @@
)
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())
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 7d339d5..179d90b 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -428,7 +428,7 @@
// Create contents for the prebuilt_apex and store it away for later use.
apexContents := android.NewApexContents(contents)
- mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{
+ android.SetProvider(mctx, ApexBundleInfoProvider, ApexBundleInfo{
Contents: apexContents,
})
diff --git a/bloaty/bloaty.go b/bloaty/bloaty.go
index 97eba70..43fb71d 100644
--- a/bloaty/bloaty.go
+++ b/bloaty/bloaty.go
@@ -73,7 +73,7 @@
mf.paths = append(mf.paths, p)
}
}
- ctx.SetProvider(fileSizeMeasurerKey, mf)
+ android.SetProvider(ctx, fileSizeMeasurerKey, mf)
}
type sizesSingleton struct{}
@@ -85,10 +85,10 @@
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)
diff --git a/bpf/bpf.go b/bpf/bpf.go
index ce57b46..32d62b5 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -203,7 +203,7 @@
}
}
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()})
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()})
}
func (bpf *bpf) AndroidMk() android.AndroidMkData {
diff --git a/cc/afdo.go b/cc/afdo.go
index bad16a1..79fbae1 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -137,8 +137,7 @@
}
ctx.VisitDirectDepsWithTag(FdoProfileTag, func(m android.Module) {
- if ctx.OtherModuleHasProvider(m, FdoProfileProvider) {
- info := ctx.OtherModuleProvider(m, FdoProfileProvider).(FdoProfileInfo)
+ if info, ok := android.OtherModuleProvider(ctx, m, FdoProfileProvider); ok {
c.afdo.Properties.FdoProfilePath = proptools.StringPtr(info.Path.String())
}
})
diff --git a/cc/cc.go b/cc/cc.go
index 7a06128..e6b9d8b 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1744,11 +1744,13 @@
}
func (ctx *moduleContextImpl) isForPlatform() bool {
- return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+ apexInfo, _ := android.ModuleProvider(ctx.ctx, android.ApexInfoProvider)
+ return apexInfo.IsForPlatform()
}
func (ctx *moduleContextImpl) apexVariationName() string {
- return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).ApexVariationName
+ apexInfo, _ := android.ModuleProvider(ctx.ctx, android.ApexInfoProvider)
+ return apexInfo.ApexVariationName
}
func (ctx *moduleContextImpl) apexSdkVersion() android.ApiLevel {
@@ -1991,7 +1993,7 @@
}
c.Properties.SubName = GetSubnameProperty(actx, c)
- apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
c.hideApexVariantFromMake = true
}
@@ -2131,9 +2133,9 @@
}
}
if c.testModule {
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: deps.GeneratedSources.Strings()})
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: deps.GeneratedSources.Strings()})
aconfig.CollectDependencyAconfigFiles(ctx, &c.mergedAconfigFiles)
@@ -2368,9 +2370,9 @@
if actx.OtherModuleExists("api_imports") {
apiImportModule = actx.AddDependency(c, nil, "api_imports")
if len(apiImportModule) > 0 && apiImportModule[0] != nil {
- apiInfo := actx.OtherModuleProvider(apiImportModule[0], multitree.ApiImportsProvider).(multitree.ApiImportInfo)
+ apiInfo, _ := android.OtherModuleProvider(actx, apiImportModule[0], multitree.ApiImportsProvider)
apiImportInfo = apiInfo
- actx.SetProvider(multitree.ApiImportsProvider, apiInfo)
+ android.SetProvider(actx, multitree.ApiImportsProvider, apiInfo)
}
}
}
@@ -2391,10 +2393,10 @@
snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot")
}
if len(snapshotModule) > 0 && snapshotModule[0] != nil {
- snapshot := actx.OtherModuleProvider(snapshotModule[0], SnapshotInfoProvider).(SnapshotInfo)
+ snapshot, _ := android.OtherModuleProvider(actx, snapshotModule[0], SnapshotInfoProvider)
*snapshotInfo = &snapshot
// republish the snapshot for use in later mutators on this module
- actx.SetProvider(SnapshotInfoProvider, snapshot)
+ android.SetProvider(actx, SnapshotInfoProvider, snapshot)
}
}
if *snapshotInfo == nil {
@@ -2982,7 +2984,7 @@
depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, exporter.GeneratedHeaders...)
}
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
c.apexSdkVersion = findApexSdkVersion(ctx, apexInfo)
skipModuleList := map[string]bool{}
@@ -2992,7 +2994,7 @@
ctx.VisitDirectDeps(func(dep android.Module) {
if dep.Name() == "api_imports" {
- apiImportInfo = ctx.OtherModuleProvider(dep, multitree.ApiImportsProvider).(multitree.ApiImportInfo)
+ apiImportInfo, _ = android.OtherModuleProvider(ctx, dep, multitree.ApiImportsProvider)
hasApiImportInfo = true
}
})
@@ -3043,12 +3045,10 @@
}
if depTag == aidlLibraryTag {
- if ctx.OtherModuleHasProvider(dep, aidl_library.AidlLibraryProvider) {
+ if aidlLibraryInfo, ok := android.OtherModuleProvider(ctx, dep, aidl_library.AidlLibraryProvider); ok {
depPaths.AidlLibraryInfos = append(
depPaths.AidlLibraryInfos,
- ctx.OtherModuleProvider(
- dep,
- aidl_library.AidlLibraryProvider).(aidl_library.AidlLibraryInfo),
+ aidlLibraryInfo,
)
}
}
@@ -3113,10 +3113,10 @@
// version mutator, so the stubs variant is created from the shared variant that
// already has the reuseObjTag dependency on the static variant.
if !c.library.buildStubs() {
- staticAnalogue := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
+ staticAnalogue, _ := android.OtherModuleProvider(ctx, dep, StaticLibraryInfoProvider)
objs := staticAnalogue.ReuseObjects
depPaths.Objs = depPaths.Objs.Append(objs)
- depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
+ depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
reexportExporter(depExporterInfo)
}
return
@@ -3137,7 +3137,7 @@
return
}
- depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
+ depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
var ptr *android.Paths
var depPtr *android.Paths
@@ -3146,7 +3146,7 @@
switch {
case libDepTag.header():
- if !ctx.OtherModuleHasProvider(dep, HeaderLibraryInfoProvider) {
+ if _, isHeaderLib := android.OtherModuleProvider(ctx, dep, HeaderLibraryInfoProvider); !isHeaderLib {
if !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("module %q is not a header library", depName)
} else {
@@ -3155,7 +3155,7 @@
return
}
case libDepTag.shared():
- if !ctx.OtherModuleHasProvider(dep, SharedLibraryInfoProvider) {
+ if _, isSharedLib := android.OtherModuleProvider(ctx, dep, SharedLibraryInfoProvider); !isSharedLib {
if !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("module %q is not a shared library", depName)
} else {
@@ -3192,7 +3192,8 @@
panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
}
case libDepTag.static():
- if !ctx.OtherModuleHasProvider(dep, StaticLibraryInfoProvider) {
+ staticLibraryInfo, isStaticLib := android.OtherModuleProvider(ctx, dep, StaticLibraryInfoProvider)
+ if !isStaticLib {
if !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("module %q is not a static library", depName)
} else {
@@ -3207,7 +3208,6 @@
break
}
- staticLibraryInfo := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
linkFile = android.OptionalPathForPath(staticLibraryInfo.StaticLibrary)
if libDepTag.wholeStatic {
ptr = &depPaths.WholeStaticLibs
@@ -3317,7 +3317,7 @@
if lib.buildStubs() && dep.(android.ApexModule).InAnyApex() {
// Add the dependency to the APEX(es) providing the library so that
// m <module> can trigger building the APEXes as well.
- depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo)
+ depApexInfo, _ := android.OtherModuleProvider(ctx, dep, android.ApexInfoProvider)
for _, an := range depApexInfo.InApexVariants {
c.Properties.ApexesProvidingSharedLibs = append(
c.Properties.ApexesProvidingSharedLibs, an)
@@ -3402,7 +3402,7 @@
bootstrap = linkable.Bootstrap()
}
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
useStubs := false
@@ -3436,7 +3436,7 @@
// Another exception: if this module is a test for an APEX, then
// it is linked with the non-stub variant of a module in the APEX
// as if this is part of the APEX.
- testFor := ctx.Provider(android.ApexTestForInfoProvider).(android.ApexTestForInfo)
+ testFor, _ := android.ModuleProvider(ctx, android.ApexTestForInfoProvider)
for _, apexContents := range testFor.ApexContents {
if apexContents.DirectlyInApex(depName) {
useStubs = false
@@ -3482,9 +3482,9 @@
panic(fmt.Errorf("Unexpected dependency tag: %T", depTag))
}
- sharedLibraryInfo := ctx.OtherModuleProvider(dep, SharedLibraryInfoProvider).(SharedLibraryInfo)
- depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
- sharedLibraryStubsInfo := ctx.OtherModuleProvider(dep, SharedLibraryStubsProvider).(SharedLibraryStubsInfo)
+ sharedLibraryInfo, _ := android.OtherModuleProvider(ctx, dep, SharedLibraryInfoProvider)
+ depExporterInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
+ sharedLibraryStubsInfo, _ := android.OtherModuleProvider(ctx, dep, SharedLibraryStubsProvider)
if !libDepTag.explicitlyVersioned && len(sharedLibraryStubsInfo.SharedStubLibraries) > 0 {
// when to use (unspecified) stubs, use the latest one.
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 3631f19..cebf129 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -2544,8 +2544,8 @@
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 @@
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 @@
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 @@
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 {
diff --git a/cc/fdo_profile.go b/cc/fdo_profile.go
index 74d511a..0893da5 100644
--- a/cc/fdo_profile.go
+++ b/cc/fdo_profile.go
@@ -62,7 +62,7 @@
func (fp *fdoProfile) fdoProfileMutator(ctx android.BottomUpMutatorContext) {
if fp.properties.Profile != nil {
path := android.PathForModuleSrc(ctx, *fp.properties.Profile)
- ctx.SetProvider(FdoProfileProvider, FdoProfileInfo{
+ android.SetProvider(ctx, FdoProfileProvider, FdoProfileInfo{
Path: path,
})
}
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 6b3a739..f5642d6 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -544,7 +544,8 @@
if !IsValidSharedDependency(dep) {
return
}
- if !ctx.OtherModuleHasProvider(dep, SharedLibraryInfoProvider) {
+ sharedLibraryInfo, hasSharedLibraryInfo := android.OtherModuleProvider(ctx, dep, SharedLibraryInfoProvider)
+ if !hasSharedLibraryInfo {
return
}
if seen[ctx.OtherModuleName(dep)] {
@@ -553,7 +554,6 @@
seen[ctx.OtherModuleName(dep)] = true
deps = append(deps, dep)
- sharedLibraryInfo := ctx.OtherModuleProvider(dep, SharedLibraryInfoProvider).(SharedLibraryInfo)
installDestination := sharedLibraryInfo.SharedLibrary.Base()
ruleBuilderInstall := android.RuleBuilderInstall{android.OutputFileForModule(ctx, dep, "unstripped"), installDestination}
sharedLibraries = append(sharedLibraries, ruleBuilderInstall)
@@ -574,14 +574,14 @@
if !IsValidSharedDependency(child) {
return false
}
- if !ctx.OtherModuleHasProvider(child, SharedLibraryInfoProvider) {
+ sharedLibraryInfo, hasSharedLibraryInfo := android.OtherModuleProvider(ctx, child, SharedLibraryInfoProvider)
+ if !hasSharedLibraryInfo {
return false
}
if !seen[ctx.OtherModuleName(child)] {
seen[ctx.OtherModuleName(child)] = true
deps = append(deps, child)
- sharedLibraryInfo := ctx.OtherModuleProvider(child, SharedLibraryInfoProvider).(SharedLibraryInfo)
installDestination := sharedLibraryInfo.SharedLibrary.Base()
ruleBuilderInstall := android.RuleBuilderInstall{android.OutputFileForModule(ctx, child, "unstripped"), installDestination}
sharedLibraries = append(sharedLibraries, ruleBuilderInstall)
diff --git a/cc/library.go b/cc/library.go
index 4d5a254..4c8deef 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -341,7 +341,7 @@
}
func (f *flagExporter) setProvider(ctx android.ModuleContext) {
- ctx.SetProvider(FlagExporterInfoProvider, FlagExporterInfo{
+ android.SetProvider(ctx, FlagExporterInfoProvider, FlagExporterInfo{
// Comes from Export_include_dirs property, and those of exported transitive deps
IncludeDirs: android.FirstUniquePaths(f.dirs),
// Comes from Export_system_include_dirs property, and those of exported transitive deps
@@ -1071,7 +1071,7 @@
ctx.CheckbuildFile(outputFile)
if library.static() {
- ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
+ android.SetProvider(ctx, StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: outputFile,
ReuseObjects: library.reuseObjects,
Objects: library.objects,
@@ -1085,7 +1085,7 @@
}
if library.header() {
- ctx.SetProvider(HeaderLibraryInfoProvider, HeaderLibraryInfo{})
+ android.SetProvider(ctx, HeaderLibraryInfoProvider, HeaderLibraryInfo{})
}
return outputFile
@@ -1235,11 +1235,11 @@
var transitiveStaticLibrariesForOrdering *android.DepSet[android.Path]
if static := ctx.GetDirectDepsWithTag(staticVariantTag); len(static) > 0 {
- s := ctx.OtherModuleProvider(static[0], StaticLibraryInfoProvider).(StaticLibraryInfo)
+ s, _ := android.OtherModuleProvider(ctx, static[0], StaticLibraryInfoProvider)
transitiveStaticLibrariesForOrdering = s.TransitiveStaticLibrariesForOrdering
}
- ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
+ android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
TableOfContents: android.OptionalPathForPath(tocFile),
SharedLibrary: unstrippedOutputFile,
TransitiveStaticLibrariesForOrdering: transitiveStaticLibrariesForOrdering,
@@ -1256,15 +1256,15 @@
if len(stubs) > 0 {
var stubsInfo []SharedStubLibrary
for _, stub := range stubs {
- stubInfo := ctx.OtherModuleProvider(stub, SharedLibraryInfoProvider).(SharedLibraryInfo)
- flagInfo := ctx.OtherModuleProvider(stub, FlagExporterInfoProvider).(FlagExporterInfo)
+ stubInfo, _ := android.OtherModuleProvider(ctx, stub, SharedLibraryInfoProvider)
+ flagInfo, _ := android.OtherModuleProvider(ctx, stub, FlagExporterInfoProvider)
stubsInfo = append(stubsInfo, SharedStubLibrary{
Version: moduleLibraryInterface(stub).stubsVersion(),
SharedLibraryInfo: stubInfo,
FlagExporterInfo: flagInfo,
})
}
- ctx.SetProvider(SharedLibraryStubsProvider, SharedLibraryStubsInfo{
+ android.SetProvider(ctx, SharedLibraryStubsProvider, SharedLibraryStubsInfo{
SharedStubLibraries: stubsInfo,
IsLLNDK: ctx.IsLlndk(),
})
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 52e78d7..a65b1ba 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -511,7 +511,7 @@
}
}
- exportedInfo := ctx.SdkModuleContext().OtherModuleProvider(variant, FlagExporterInfoProvider).(FlagExporterInfo)
+ exportedInfo, _ := android.OtherModuleProvider(ctx.SdkModuleContext(), variant, FlagExporterInfoProvider)
// Separate out the generated include dirs (which are arch specific) from the
// include dirs (which may not be).
diff --git a/cc/library_stub.go b/cc/library_stub.go
index 18d3f21..1183b29 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -244,7 +244,7 @@
},
})
- ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
+ android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
SharedLibrary: outputFile,
Target: ctx.Target(),
@@ -262,15 +262,15 @@
if len(stubs) > 0 {
var stubsInfo []SharedStubLibrary
for _, stub := range stubs {
- stubInfo := ctx.OtherModuleProvider(stub, SharedLibraryInfoProvider).(SharedLibraryInfo)
- flagInfo := ctx.OtherModuleProvider(stub, FlagExporterInfoProvider).(FlagExporterInfo)
+ stubInfo, _ := android.OtherModuleProvider(ctx, stub, SharedLibraryInfoProvider)
+ flagInfo, _ := android.OtherModuleProvider(ctx, stub, FlagExporterInfoProvider)
stubsInfo = append(stubsInfo, SharedStubLibrary{
Version: moduleLibraryInterface(stub).stubsVersion(),
SharedLibraryInfo: stubInfo,
FlagExporterInfo: flagInfo,
})
}
- ctx.SetProvider(SharedLibraryStubsProvider, SharedLibraryStubsInfo{
+ android.SetProvider(ctx, SharedLibraryStubsProvider, SharedLibraryStubsInfo{
SharedStubLibraries: stubsInfo,
IsLLNDK: ctx.IsLlndk(),
diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go
index 842bdf6..f503982 100644
--- a/cc/ndk_prebuilt.go
+++ b/cc/ndk_prebuilt.go
@@ -117,13 +117,13 @@
if ndk.static() {
depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(lib).Build()
- ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
+ android.SetProvider(ctx, StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: lib,
TransitiveStaticLibrariesForOrdering: depSet,
})
} else {
- ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
+ android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
SharedLibrary: lib,
Target: ctx.Target(),
})
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index f68fa24..e721c53 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -132,7 +132,7 @@
if p.static() {
depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(in).Build()
- ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
+ android.SetProvider(ctx, StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: in,
TransitiveStaticLibrariesForOrdering: depSet,
@@ -190,7 +190,7 @@
},
})
- ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
+ android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
SharedLibrary: outputFile,
Target: ctx.Target(),
@@ -213,7 +213,7 @@
}
if p.header() {
- ctx.SetProvider(HeaderLibraryInfoProvider, HeaderLibraryInfo{})
+ android.SetProvider(ctx, HeaderLibraryInfoProvider, HeaderLibraryInfo{})
// Need to return an output path so that the AndroidMk logic doesn't skip
// the prebuilt header. For compatibility, in case Android.mk files use a
diff --git a/cc/sabi.go b/cc/sabi.go
index 4cd776a..1310685 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -194,8 +194,8 @@
return false
}
- isPlatformVariant := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
- if isPlatformVariant {
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ if apexInfo.IsForPlatform() {
// Bionic libraries that are installed to the bootstrap directory are not ABI checked.
// Only the runtime APEX variants, which are the implementation libraries of bionic NDK stubs,
// are checked.
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 31c0500..52b5be9 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -1627,7 +1627,7 @@
addStaticDeps := func(dep string, hideSymbols bool) {
// If we're using snapshots, redirect to snapshot whenever possible
- snapshot := mctx.Provider(SnapshotInfoProvider).(SnapshotInfo)
+ snapshot, _ := android.ModuleProvider(mctx, SnapshotInfoProvider)
if lib, ok := snapshot.StaticLibs[dep]; ok {
dep = lib
}
@@ -1714,7 +1714,7 @@
addStaticDeps(runtimeSharedLibrary, true)
} else if !c.static() && !c.Header() {
// If we're using snapshots, redirect to snapshot whenever possible
- snapshot := mctx.Provider(SnapshotInfoProvider).(SnapshotInfo)
+ snapshot, _ := android.ModuleProvider(mctx, SnapshotInfoProvider)
if lib, ok := snapshot.SharedLibs[runtimeSharedLibrary]; ok {
runtimeSharedLibrary = lib
}
diff --git a/cc/sanitize_test.go b/cc/sanitize_test.go
index cfc9ed2..44f38e1 100644
--- a/cc/sanitize_test.go
+++ b/cc/sanitize_test.go
@@ -22,8 +22,6 @@
"testing"
"android/soong/android"
-
- "github.com/google/blueprint"
)
var prepareForAsanTest = android.FixtureAddFile("asan/Android.bp", []byte(`
@@ -49,7 +47,7 @@
`))
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 @@
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 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 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 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",
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index a9c4c85..e769fe9 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -194,7 +194,7 @@
sharedLibs[k] = v
}
- ctx.SetProvider(SnapshotInfoProvider, SnapshotInfo{
+ android.SetProvider(ctx, SnapshotInfoProvider, SnapshotInfo{
HeaderLibs: headers,
Binaries: binaries,
Objects: objects,
@@ -494,7 +494,7 @@
p.tocFile = android.OptionalPathForPath(tocFile)
TransformSharedObjectToToc(ctx, in, tocFile)
- ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
+ android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
SharedLibrary: in,
Target: ctx.Target(),
@@ -504,7 +504,7 @@
if p.static() {
depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(in).Build()
- ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
+ android.SetProvider(ctx, StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: in,
TransitiveStaticLibrariesForOrdering: depSet,
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index e8e930e..a33ed5f 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -275,7 +275,7 @@
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 @@
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 {
diff --git a/cc/vndk.go b/cc/vndk.go
index a849455..b2c6e0d 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -772,7 +772,7 @@
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 @@
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 {
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 5e526db..3f3a025 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -171,7 +171,7 @@
p.androidMkSuffix = ""
}
- ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
+ android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{
SharedLibrary: in,
Target: ctx.Target(),
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 0512c15..87f6392 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -393,7 +393,7 @@
return srcFiles
}
srcFiles := addLabelsForInputs("srcs", g.properties.Srcs, g.properties.Exclude_srcs)
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcFiles.Strings()})
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcFiles.Strings()})
var copyFrom android.Paths
var outputFiles android.WritablePaths
diff --git a/java/aar.go b/java/aar.go
index bb24f2d..2ad8fdf 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -805,7 +805,8 @@
},
)
- a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ a.hideApexVariantFromMake = !apexInfo.IsForPlatform()
a.stem = proptools.StringDefault(a.overridableDeviceProperties.Stem, ctx.ModuleName())
@@ -825,7 +826,7 @@
a.linter.resources = a.aapt.resourceFiles
proguardSpecInfo := a.collectProguardSpecInfo(ctx)
- ctx.SetProvider(ProguardSpecInfoProvider, proguardSpecInfo)
+ android.SetProvider(ctx, ProguardSpecInfoProvider, proguardSpecInfo)
exportedProguardFlagsFiles := proguardSpecInfo.ProguardFlagsFiles.ToList()
a.extraProguardFlagsFiles = append(a.extraProguardFlagsFiles, exportedProguardFlagsFiles...)
a.extraProguardFlagsFiles = append(a.extraProguardFlagsFiles, a.proguardOptionsFile)
@@ -860,12 +861,12 @@
prebuiltJniPackages := android.Paths{}
ctx.VisitDirectDeps(func(module android.Module) {
- if info, ok := ctx.OtherModuleProvider(module, JniPackageProvider).(JniPackageInfo); ok {
+ if info, ok := android.OtherModuleProvider(ctx, module, JniPackageProvider); ok {
prebuiltJniPackages = append(prebuiltJniPackages, info.JniPackages...)
}
})
if len(prebuiltJniPackages) > 0 {
- ctx.SetProvider(JniPackageProvider, JniPackageInfo{
+ android.SetProvider(ctx, JniPackageProvider, JniPackageInfo{
JniPackages: prebuiltJniPackages,
})
}
@@ -1106,7 +1107,8 @@
a.sdkVersion = a.SdkVersion(ctx)
a.minSdkVersion = a.MinSdkVersion(ctx)
- a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ a.hideApexVariantFromMake = !apexInfo.IsForPlatform()
aarName := ctx.ModuleName() + ".aar"
a.aarPath = android.PathForModuleSrc(ctx, a.properties.Aars[0])
@@ -1123,7 +1125,7 @@
aarRTxt := extractedAARDir.Join(ctx, "R.txt")
a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip")
a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt")
- ctx.SetProvider(ProguardSpecInfoProvider, ProguardSpecInfo{
+ android.SetProvider(ctx, ProguardSpecInfoProvider, ProguardSpecInfo{
ProguardFlagsFiles: android.NewDepSet[android.Path](
android.POSTORDER,
android.Paths{a.proguardFlags},
@@ -1228,7 +1230,7 @@
a.transitiveAaptResourcePackagesFile = transitiveAaptResourcePackagesFile
a.collectTransitiveHeaderJars(ctx)
- ctx.SetProvider(JavaInfoProvider, JavaInfo{
+ android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
HeaderJars: android.PathsIfNonNil(a.classpathFile),
TransitiveLibsHeaderJars: a.transitiveLibsHeaderJars,
TransitiveStaticLibsHeaderJars: a.transitiveStaticLibsHeaderJars,
@@ -1258,7 +1260,7 @@
}
}
- ctx.SetProvider(JniPackageProvider, JniPackageInfo{
+ android.SetProvider(ctx, JniPackageProvider, JniPackageInfo{
JniPackages: a.jniPackages,
})
}
diff --git a/java/aar_test.go b/java/aar_test.go
index 8afa039..4d4e5d0 100644
--- a/java/aar_test.go
+++ b/java/aar_test.go
@@ -52,7 +52,7 @@
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")
}
diff --git a/java/app.go b/java/app.go
index ee82a32..7f0303a 100755
--- a/java/app.go
+++ b/java/app.go
@@ -411,7 +411,7 @@
ctx.PropertyErrorf("min_sdk_version", "invalid value %q: %s", a.MinSdkVersion(ctx), err)
}
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
return (minSdkVersion.FinalOrFutureInt() >= 23 && Bool(a.appProperties.Use_embedded_native_libs)) ||
!apexInfo.IsForPlatform()
}
@@ -436,7 +436,7 @@
}
func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool {
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
return ctx.Config().UnbundledBuild() || Bool(a.appProperties.Use_embedded_native_libs) ||
!apexInfo.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
}
@@ -509,7 +509,7 @@
var aconfigTextFilePaths android.Paths
ctx.VisitDirectDepsWithTag(aconfigDeclarationTag, func(dep android.Module) {
- if provider, ok := ctx.OtherModuleProvider(dep, aconfig.DeclarationsProviderKey).(aconfig.DeclarationsProviderData); ok {
+ if provider, ok := android.OtherModuleProvider(ctx, dep, aconfig.DeclarationsProviderKey); ok {
aconfigTextFilePaths = append(aconfigTextFilePaths, provider.IntermediateDumpOutputPath)
} else {
ctx.ModuleErrorf("Only aconfig_declarations module type is allowed for "+
@@ -537,7 +537,7 @@
func (a *AndroidApp) proguardBuildActions(ctx android.ModuleContext) {
var staticLibProguardFlagFiles android.Paths
ctx.VisitDirectDeps(func(m android.Module) {
- depProguardInfo := ctx.OtherModuleProvider(m, ProguardSpecInfoProvider).(ProguardSpecInfo)
+ depProguardInfo, _ := android.OtherModuleProvider(ctx, m, ProguardSpecInfoProvider)
staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, depProguardInfo.UnconditionallyExportedProguardFlags.ToList()...)
if ctx.OtherModuleDependencyTag(m) == staticLibTag {
staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, depProguardInfo.ProguardFlagsFiles.ToList()...)
@@ -745,7 +745,8 @@
func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
var apkDeps android.Paths
- if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ if !apexInfo.IsForPlatform() {
a.hideApexVariantFromMake = true
}
@@ -890,8 +891,6 @@
a.privAppAllowlist = android.OptionalPathForPath(allowlist)
}
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
-
// Install the app package.
shouldInstallAppPackage := (Bool(a.Module.properties.Installable) || ctx.Host()) && apexInfo.IsForPlatform() && !a.appProperties.PreventInstall
if shouldInstallAppPackage {
@@ -975,7 +974,7 @@
return shouldCollectRecursiveNativeDeps
}
- if info, ok := ctx.OtherModuleProvider(module, JniPackageProvider).(JniPackageInfo); ok {
+ if info, ok := android.OtherModuleProvider(ctx, module, JniPackageProvider); ok {
prebuiltJniPackages = append(prebuiltJniPackages, info.JniPackages...)
}
@@ -1295,7 +1294,7 @@
a.testConfig = a.FixTestConfig(ctx, testConfig)
a.extraTestConfigs = android.PathsForModuleSrc(ctx, a.testProperties.Test_options.Extra_test_configs)
a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
func (a *AndroidTest) FixTestConfig(ctx android.ModuleContext, testConfig android.Path) android.Path {
diff --git a/java/app_import.go b/java/app_import.go
index c5d09fd..ff0f5fe 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -257,7 +257,7 @@
ctx.ModuleErrorf("prebuilt_framework-res found. This used to have special handling in soong, but was removed due to prebuilt_framework-res no longer existing. This check is to ensure it doesn't come back without readding the special handling.")
}
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
a.hideApexVariantFromMake = true
}
diff --git a/java/base.go b/java/base.go
index 7cd2820..41f2fcc 100644
--- a/java/base.go
+++ b/java/base.go
@@ -618,7 +618,7 @@
// Populate with package rules from the properties.
hiddenAPIInfo.extractPackageRulesFromProperties(&j.deviceProperties.HiddenAPIPackageProperties)
- ctx.SetProvider(hiddenAPIPropertyInfoProvider, hiddenAPIInfo)
+ android.SetProvider(ctx, hiddenAPIPropertyInfoProvider, hiddenAPIInfo)
}
func (j *Module) OutputFiles(tag string) (android.Paths, error) {
@@ -685,7 +685,7 @@
// Force enable the instrumentation for java code that is built for APEXes ...
// except for the jacocoagent itself (because instrumenting jacocoagent using jacocoagent
// doesn't make sense) or framework libraries (e.g. libraries found in the InstrumentFrameworkModules list) unless EMMA_INSTRUMENT_FRAMEWORK is true.
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
isJacocoAgent := ctx.ModuleName() == "jacocoagent"
if j.DirectlyInAnyApex() && !isJacocoAgent && !apexInfo.IsForPlatform() {
if !inList(ctx.ModuleName(), config.InstrumentFrameworkModules) {
@@ -1143,7 +1143,7 @@
uniqueSrcFiles = append(uniqueSrcFiles, uniqueJavaFiles...)
uniqueSrcFiles = append(uniqueSrcFiles, uniqueKtFiles...)
j.uniqueSrcFiles = uniqueSrcFiles
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: uniqueSrcFiles.Strings()})
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: uniqueSrcFiles.Strings()})
// We don't currently run annotation processors in turbine, which means we can't use turbine
// generated header jars when an annotation processor that generates API is enabled. One
@@ -1178,7 +1178,7 @@
return
}
- ctx.SetProvider(JavaInfoProvider, JavaInfo{
+ android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
TransitiveStaticLibsHeaderJars: j.transitiveStaticLibsHeaderJars,
@@ -1572,7 +1572,7 @@
// Enable dex compilation for the APEX variants, unless it is disabled explicitly
compileDex := j.dexProperties.Compile_dex
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if j.DirectlyInAnyApex() && !apexInfo.IsForPlatform() {
if compileDex == nil {
compileDex = proptools.BoolPtr(true)
@@ -1696,7 +1696,7 @@
aconfig.CollectDependencyAconfigFiles(ctx, &j.mergedAconfigFiles)
- ctx.SetProvider(JavaInfoProvider, JavaInfo{
+ android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
TransitiveStaticLibsHeaderJars: j.transitiveStaticLibsHeaderJars,
@@ -1726,7 +1726,7 @@
transitiveProguardFlags := []*android.DepSet[android.Path]{}
ctx.VisitDirectDeps(func(m android.Module) {
- depProguardInfo := ctx.OtherModuleProvider(m, ProguardSpecInfoProvider).(ProguardSpecInfo)
+ depProguardInfo, _ := android.OtherModuleProvider(ctx, m, ProguardSpecInfoProvider)
depTag := ctx.OtherModuleDependencyTag(m)
if depProguardInfo.UnconditionallyExportedProguardFlags != nil {
@@ -1912,7 +1912,7 @@
return
}
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ dep, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
tag := ctx.OtherModuleDependencyTag(module)
_, isUsesLibDep := tag.(usesLibraryDependencyTag)
if tag == libTag || tag == r8LibraryJarTag || isUsesLibDep {
@@ -2037,7 +2037,7 @@
ctx.VisitDirectDeps(func(module android.Module) {
tag := ctx.OtherModuleDependencyTag(module)
if tag == staticLibTag {
- depInfo := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ depInfo, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
if depInfo.TransitiveSrcFiles != nil {
fromDeps = append(fromDeps, depInfo.TransitiveSrcFiles)
}
@@ -2209,15 +2209,14 @@
case staticLibTag:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}
- } else if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
- if sdkLinkType != javaPlatform &&
- ctx.OtherModuleHasProvider(module, SyspropPublicStubInfoProvider) {
- // dep is a sysprop implementation library, but this module is not linking against
- // the platform, so it gets the sysprop public stubs library instead. Replace
- // dep with the JavaInfo from the SyspropPublicStubInfoProvider.
- syspropDep := ctx.OtherModuleProvider(module, SyspropPublicStubInfoProvider).(SyspropPublicStubInfo)
- dep = syspropDep.JavaInfo
+ } else if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
+ if sdkLinkType != javaPlatform {
+ if syspropDep, ok := android.OtherModuleProvider(ctx, module, SyspropPublicStubInfoProvider); ok {
+ // dep is a sysprop implementation library, but this module is not linking against
+ // the platform, so it gets the sysprop public stubs library instead. Replace
+ // dep with the JavaInfo from the SyspropPublicStubInfoProvider.
+ dep = syspropDep.JavaInfo
+ }
}
switch tag {
case bootClasspathTag:
@@ -2289,7 +2288,7 @@
case syspropPublicStubDepTag:
// This is a sysprop implementation library, forward the JavaInfoProvider from
// the corresponding sysprop public stub library as SyspropPublicStubInfoProvider.
- ctx.SetProvider(SyspropPublicStubInfoProvider, SyspropPublicStubInfo{
+ android.SetProvider(ctx, SyspropPublicStubInfoProvider, SyspropPublicStubInfo{
JavaInfo: dep,
})
}
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index 4eb916d..d2bb523 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -500,7 +500,7 @@
if ctx.Module() != ctx.FinalModule() {
b.HideFromMake()
}
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
// getProfileProviderApex returns the name of the apex that provides a boot image profile, or an
@@ -512,7 +512,7 @@
}
// Bootclasspath fragment modules that are for the platform do not produce boot related files.
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
for _, apex := range apexInfo.InApexVariants {
if isProfileProviderApex(ctx, apex) {
return apex
@@ -537,7 +537,7 @@
}
// Make the apex content info available for other modules.
- ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, info)
+ android.SetProvider(ctx, BootclasspathFragmentApexContentInfoProvider, info)
}
// generateClasspathProtoBuildActions generates all required build actions for classpath.proto config
@@ -623,7 +623,7 @@
hiddenAPIInfo.HiddenAPIFlagOutput = output.HiddenAPIFlagOutput
// Provide it for use by other modules.
- ctx.SetProvider(HiddenAPIInfoProvider, hiddenAPIInfo)
+ android.SetProvider(ctx, HiddenAPIInfoProvider, hiddenAPIInfo)
return output
}
@@ -744,7 +744,7 @@
}
// Make the information available for the sdk snapshot.
- ctx.SetProvider(HiddenAPIInfoForSdkProvider, HiddenAPIInfoForSdk{
+ android.SetProvider(ctx, HiddenAPIInfoForSdkProvider, HiddenAPIInfoForSdk{
FlagFilesByCategory: flagFilesByCategory,
HiddenAPIFlagOutput: flagOutput,
})
@@ -876,7 +876,7 @@
// Get the hidden API information from the module.
mctx := ctx.SdkModuleContext()
- hiddenAPIInfo := mctx.OtherModuleProvider(module, HiddenAPIInfoForSdkProvider).(HiddenAPIInfoForSdk)
+ hiddenAPIInfo, _ := android.OtherModuleProvider(mctx, module, HiddenAPIInfoForSdkProvider)
b.Flag_files_by_category = hiddenAPIInfo.FlagFilesByCategory
// Copy all the generated file paths.
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index 828de21..216c3b3 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -272,7 +272,7 @@
`)
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 @@
// 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)
diff --git a/java/classpath_element.go b/java/classpath_element.go
index af99fb4..abbcae7 100644
--- a/java/classpath_element.go
+++ b/java/classpath_element.go
@@ -21,7 +21,6 @@
"strings"
"android/soong/android"
- "github.com/google/blueprint"
)
// Supports constructing a list of ClasspathElement from a set of fragments and modules.
@@ -72,8 +71,7 @@
// ClasspathElementContext defines the context methods needed by CreateClasspathElements
type ClasspathElementContext interface {
- OtherModuleHasProvider(m blueprint.Module, provider blueprint.AnyProviderKey) bool
- OtherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) interface{}
+ android.OtherModuleProviderContext
ModuleErrorf(fmt string, args ...interface{})
}
@@ -123,12 +121,12 @@
// associated with a particular apex.
apexToFragment := map[string]android.Module{}
for _, fragment := range fragments {
- if !ctx.OtherModuleHasProvider(fragment, android.ApexInfoProvider) {
+ apexInfo, ok := android.OtherModuleProvider(ctx, fragment, android.ApexInfoProvider)
+ if !ok {
ctx.ModuleErrorf("fragment %s is not part of an apex", fragment)
continue
}
- apexInfo := ctx.OtherModuleProvider(fragment, android.ApexInfoProvider).(android.ApexInfo)
for _, apex := range apexInfo.InApexVariants {
if existing, ok := apexToFragment[apex]; ok {
ctx.ModuleErrorf("apex %s has multiple fragments, %s and %s", apex, fragment, existing)
@@ -146,8 +144,7 @@
// Iterate over the libraries to construct the ClasspathElements list.
for _, library := range libraries {
var element ClasspathElement
- if ctx.OtherModuleHasProvider(library, android.ApexInfoProvider) {
- apexInfo := ctx.OtherModuleProvider(library, android.ApexInfoProvider).(android.ApexInfo)
+ if apexInfo, ok := android.OtherModuleProvider(ctx, library, android.ApexInfoProvider); ok {
var fragment android.Module
diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go
index eecaebd..2017801 100644
--- a/java/classpath_fragment.go
+++ b/java/classpath_fragment.go
@@ -178,7 +178,7 @@
ClasspathFragmentProtoInstallDir: c.installDirPath,
ClasspathFragmentProtoOutput: c.outputFilepath,
}
- ctx.SetProvider(ClasspathFragmentProtoContentInfoProvider, classpathProtoInfo)
+ android.SetProvider(ctx, ClasspathFragmentProtoContentInfoProvider, classpathProtoInfo)
}
func writeClasspathsTextproto(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) {
diff --git a/java/code_metadata_test.go b/java/code_metadata_test.go
index 8f8abd7..509e701 100644
--- a/java/code_metadata_test.go
+++ b/java/code_metadata_test.go
@@ -30,9 +30,7 @@
).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",
) {
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index ee8a15a..834651f 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -97,8 +97,7 @@
}
ctx.VisitDirectDepsWithTag(deviceHostConverterDepTag, func(m android.Module) {
- if ctx.OtherModuleHasProvider(m, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
+ if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok {
d.headerJars = append(d.headerJars, dep.HeaderJars...)
d.implementationJars = append(d.implementationJars, dep.ImplementationJars...)
d.implementationAndResourceJars = append(d.implementationAndResourceJars, dep.ImplementationAndResourcesJars...)
@@ -131,7 +130,7 @@
d.combinedHeaderJar = d.headerJars[0]
}
- ctx.SetProvider(JavaInfoProvider, JavaInfo{
+ android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
HeaderJars: d.headerJars,
ImplementationAndResourcesJars: d.implementationAndResourceJars,
ImplementationJars: d.implementationJars,
diff --git a/java/dex.go b/java/dex.go
index 6f1c09d..cdae0a2 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -261,7 +261,7 @@
// See b/20667396
var proguardRaiseDeps classpath
ctx.VisitDirectDepsWithTag(proguardRaiseTag, func(m android.Module) {
- dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
+ dep, _ := android.OtherModuleProvider(ctx, m, JavaInfoProvider)
proguardRaiseDeps = append(proguardRaiseDeps, dep.HeaderJars...)
})
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index fe8c5fb..0f69dc3 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -166,12 +166,12 @@
}
func isApexVariant(ctx android.BaseModuleContext) bool {
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
return !apexInfo.IsForPlatform()
}
func forPrebuiltApex(ctx android.BaseModuleContext) bool {
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
return apexInfo.ForPrebuiltApex
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 5fb36df..5a19945 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -544,7 +544,7 @@
return true
}
if tag == bootclasspathFragmentDepTag {
- apexInfo := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.OtherModuleProvider(ctx, child, android.ApexInfoProvider)
for _, apex := range apexInfo.InApexVariants {
fragments[apex] = child
}
@@ -682,7 +682,7 @@
pair.jarModule.Name(),
pair.apex)
}
- bootclasspathFragmentInfo := ctx.OtherModuleProvider(fragment, BootclasspathFragmentApexContentInfoProvider).(BootclasspathFragmentApexContentInfo)
+ bootclasspathFragmentInfo, _ := android.OtherModuleProvider(ctx, fragment, BootclasspathFragmentApexContentInfoProvider)
jar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(pair.jarModule)
if err != nil {
ctx.ModuleErrorf("%s", err)
diff --git a/java/droiddoc.go b/java/droiddoc.go
index b0d5376..138c9c3 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -363,8 +363,7 @@
switch tag {
case bootClasspathTag:
- if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars...)
} else if sm, ok := module.(SystemModulesProvider); ok {
// A system modules dependency has been added to the bootclasspath
@@ -376,8 +375,7 @@
case libTag, sdkLibTag:
if dep, ok := module.(SdkLibraryDependency); ok {
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))...)
- } else if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ } else if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.classpath = append(deps.classpath, dep.HeaderJars...)
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...)
} else if dep, ok := module.(android.SourceFileProducer); ok {
@@ -387,8 +385,7 @@
ctx.ModuleErrorf("depends on non-java module %q", otherName)
}
case java9LibTag:
- if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars...)
} else {
ctx.ModuleErrorf("depends on non-java module %q", otherName)
diff --git a/java/fuzz.go b/java/fuzz.go
index b3c2fd4..dc4c6be 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -121,7 +121,7 @@
_, sharedDeps := cc.CollectAllSharedDependencies(ctx)
for _, dep := range sharedDeps {
- sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo)
+ sharedLibInfo, _ := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider)
if sharedLibInfo.SharedLibrary != nil {
arch := "lib"
if sharedLibInfo.Target.Arch.ArchType.Multilib == "lib64" {
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index fe3fe7b..e9ee3a2 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -94,7 +94,7 @@
// processing.
classesJars := android.Paths{classesJar}
ctx.VisitDirectDepsWithTag(hiddenApiAnnotationsTag, func(dep android.Module) {
- javaInfo := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
+ javaInfo, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
classesJars = append(classesJars, javaInfo.ImplementationJars...)
})
h.classesJarPaths = classesJars
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index 3fc0883..8011f34 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -579,8 +579,7 @@
// Merge all the information from the fragments. The fragments form a DAG so it is possible that
// this will introduce duplicates so they will be resolved after processing all the fragments.
for _, fragment := range fragments {
- if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) {
- info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
+ if info, ok := android.OtherModuleProvider(ctx, fragment, HiddenAPIInfoProvider); ok {
i.TransitiveStubDexJarsByScope.addStubDexJarsByModule(info.TransitiveStubDexJarsByScope)
}
}
@@ -777,8 +776,7 @@
func (i *HiddenAPIPropertyInfo) gatherPropertyInfo(ctx android.ModuleContext, contents []android.Module) {
for _, module := range contents {
- if ctx.OtherModuleHasProvider(module, hiddenAPIPropertyInfoProvider) {
- info := ctx.OtherModuleProvider(module, hiddenAPIPropertyInfoProvider).(HiddenAPIPropertyInfo)
+ if info, ok := android.OtherModuleProvider(ctx, module, hiddenAPIPropertyInfoProvider); ok {
i.FlagFilesByCategory.append(info.FlagFilesByCategory)
i.PackagePrefixes = append(i.PackagePrefixes, info.PackagePrefixes...)
i.SinglePackages = append(i.SinglePackages, info.SinglePackages...)
@@ -1404,7 +1402,7 @@
}
if am, ok := module.(android.ApexModule); ok && am.InAnyApex() {
- apexInfo := ctx.OtherModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider)
if apexInfo.IsForPlatform() {
return true
}
diff --git a/java/hiddenapi_monolithic.go b/java/hiddenapi_monolithic.go
index c1594e9..a61018d 100644
--- a/java/hiddenapi_monolithic.go
+++ b/java/hiddenapi_monolithic.go
@@ -67,8 +67,7 @@
case *ClasspathFragmentElement:
fragment := e.Module()
- if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) {
- info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
+ if info, ok := android.OtherModuleProvider(ctx, fragment, HiddenAPIInfoProvider); ok {
monolithicInfo.append(&info)
} else {
ctx.ModuleErrorf("%s does not provide hidden API information", fragment)
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index 8ec1797..8cb78cd 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -162,7 +162,7 @@
return false
}
- apexInfo := ctx.OtherModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider)
// Now match the apex part of the boot image configuration.
requiredApex := configuredBootJars.Apex(index)
diff --git a/java/java.go b/java/java.go
index d38af13..630318e 100644
--- a/java/java.go
+++ b/java/java.go
@@ -647,7 +647,7 @@
func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bool {
// Store uncompressed (and aligned) any dex files from jars in APEXes.
- if apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo); !apexInfo.IsForPlatform() {
+ if apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider); !apexInfo.IsForPlatform() {
return true
}
@@ -687,7 +687,7 @@
j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName())
proguardSpecInfo := j.collectProguardSpecInfo(ctx)
- ctx.SetProvider(ProguardSpecInfoProvider, proguardSpecInfo)
+ android.SetProvider(ctx, ProguardSpecInfoProvider, proguardSpecInfo)
exportedProguardFlagsFiles := proguardSpecInfo.ProguardFlagsFiles.ToList()
j.extraProguardFlagsFiles = append(j.extraProguardFlagsFiles, exportedProguardFlagsFiles...)
@@ -695,7 +695,7 @@
writeCombinedProguardFlagsFile(ctx, combinedExportedProguardFlagFile, exportedProguardFlagsFiles)
j.combinedExportedProguardFlagsFile = combinedExportedProguardFlagFile
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
j.hideApexVariantFromMake = true
}
@@ -1216,12 +1216,12 @@
}
j.Test.generateAndroidBuildActionsWithConfig(ctx, configs)
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.generateAndroidBuildActionsWithConfig(ctx, nil)
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, configs []tradefed.Config) {
@@ -1257,7 +1257,7 @@
})
ctx.VisitDirectDepsWithTag(jniLibTag, func(dep android.Module) {
- sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo)
+ sharedLibInfo, _ := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider)
if sharedLibInfo.SharedLibrary != nil {
// Copy to an intermediate output directory to append "lib[64]" to the path,
// so that it's compatible with the default rpath values.
@@ -1632,7 +1632,7 @@
apiFile = android.PathForModuleSrc(ctx, String(apiFileString))
}
- ctx.SetProvider(JavaApiImportProvider, JavaApiImportInfo{
+ android.SetProvider(ctx, JavaApiImportProvider, JavaApiImportInfo{
ApiFile: apiFile,
ApiSurface: proptools.String(ap.properties.Api_surface),
})
@@ -1902,19 +1902,19 @@
tag := ctx.OtherModuleDependencyTag(dep)
switch tag {
case javaApiContributionTag:
- provider := ctx.OtherModuleProvider(dep, JavaApiImportProvider).(JavaApiImportInfo)
+ provider, _ := android.OtherModuleProvider(ctx, dep, JavaApiImportProvider)
if provider.ApiFile == nil && !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("Error: %s has an empty api file.", dep.Name())
}
srcFilesInfo = append(srcFilesInfo, provider)
case libTag:
- provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
+ provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
classPaths = append(classPaths, provider.HeaderJars...)
case staticLibTag:
- provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
+ provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
staticLibs = append(staticLibs, provider.HeaderJars...)
case depApiSrcsTag:
- provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
+ provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
depApiSrcsStubsJar = provider.HeaderJars[0]
case systemModulesTag:
module := dep.(SystemModulesProvider)
@@ -2002,7 +2002,7 @@
ctx.Phony(ctx.ModuleName(), al.stubsJar)
- ctx.SetProvider(JavaInfoProvider, JavaInfo{
+ android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
HeaderJars: android.PathsIfNonNil(al.stubsJar),
ImplementationAndResourcesJars: android.PathsIfNonNil(al.stubsJar),
ImplementationJars: android.PathsIfNonNil(al.stubsJar),
@@ -2188,7 +2188,8 @@
j.sdkVersion = j.SdkVersion(ctx)
j.minSdkVersion = j.MinSdkVersion(ctx)
- if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ if !apexInfo.IsForPlatform() {
j.hideApexVariantFromMake = true
}
@@ -2219,8 +2220,7 @@
j.collectTransitiveHeaderJars(ctx)
ctx.VisitDirectDeps(func(module android.Module) {
tag := ctx.OtherModuleDependencyTag(module)
- if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
switch tag {
case libTag, sdkLibTag:
flags.classpath = append(flags.classpath, dep.HeaderJars...)
@@ -2247,7 +2247,7 @@
if ctx.Device() {
// If this is a variant created for a prebuilt_apex then use the dex implementation jar
// obtained from the associated deapexer module.
- ai := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ ai, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if ai.ForPrebuiltApex {
// Get the path of the dex implementation jar from the `deapexer` module.
di := android.FindDeapexerProviderForModule(ctx)
@@ -2320,7 +2320,7 @@
}
}
- ctx.SetProvider(JavaInfoProvider, JavaInfo{
+ android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
HeaderJars: android.PathsIfNonNil(j.combinedClasspathFile),
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
TransitiveStaticLibsHeaderJars: j.transitiveStaticLibsHeaderJars,
@@ -2570,7 +2570,7 @@
ctx.PropertyErrorf("jars", "exactly one jar must be provided")
}
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
j.hideApexVariantFromMake = true
}
diff --git a/java/java_test.go b/java/java_test.go
index 8e83fc4..e21018c 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2226,7 +2226,8 @@
}
`)
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())
}
diff --git a/java/jdeps.go b/java/jdeps.go
index 7e3a14f..91f7ce7 100644
--- a/java/jdeps.go
+++ b/java/jdeps.go
@@ -89,8 +89,7 @@
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)
diff --git a/java/lint.go b/java/lint.go
index eb46ea8..5a684a8 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -413,8 +413,7 @@
extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag)
for _, extraLintCheckModule := range extraLintCheckModules {
- if ctx.OtherModuleHasProvider(extraLintCheckModule, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(extraLintCheckModule, JavaInfoProvider).(JavaInfo)
+ if dep, ok := android.OtherModuleProvider(ctx, extraLintCheckModule, JavaInfoProvider); ok {
l.extraLintCheckJars = append(l.extraLintCheckJars, dep.ImplementationAndResourcesJars...)
} else {
ctx.PropertyErrorf("lint.extra_check_modules",
@@ -661,7 +660,7 @@
}
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.
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index 0d52614..88d1ae8 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -180,7 +180,7 @@
var transitiveSrcFiles android.Paths
for _, module := range allModules {
- depInfo := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ depInfo, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
if depInfo.TransitiveSrcFiles != nil {
transitiveSrcFiles = append(transitiveSrcFiles, depInfo.TransitiveSrcFiles.ToList()...)
}
@@ -219,7 +219,7 @@
// Include jars from APEXes that don't populate their classpath proto config.
remainingJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars
for _, fragment := range b.fragments {
- info := ctx.OtherModuleProvider(fragment, ClasspathFragmentProtoContentInfoProvider).(ClasspathFragmentProtoContentInfo)
+ info, _ := android.OtherModuleProvider(ctx, fragment, ClasspathFragmentProtoContentInfoProvider)
if info.ClasspathFragmentProtoGenerated {
remainingJars = remainingJars.RemoveList(info.ClasspathFragmentProtoContents)
}
@@ -241,7 +241,7 @@
func (b *platformBootclasspathModule) checkPlatformModules(ctx android.ModuleContext, modules []android.Module) {
// TODO(satayev): change this check to only allow core-icu4j, all apex jars should not be here.
for _, m := range modules {
- apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.OtherModuleProvider(ctx, m, android.ApexInfoProvider)
fromUpdatableApex := apexInfo.Updatable
if fromUpdatableApex {
// error: this jar is part of an updatable apex
@@ -255,7 +255,7 @@
// checkApexModules ensures that the apex modules supplied are not from the platform.
func (b *platformBootclasspathModule) checkApexModules(ctx android.ModuleContext, modules []android.Module) {
for _, m := range modules {
- apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.OtherModuleProvider(ctx, m, android.ApexInfoProvider)
fromUpdatableApex := apexInfo.Updatable
if fromUpdatableApex {
// ok: this jar is part of an updatable apex
@@ -389,7 +389,7 @@
monolithicInfo := newMonolithicHiddenAPIInfo(ctx, temporaryInput.FlagFilesByCategory, classpathElements)
// Store the information for testing.
- ctx.SetProvider(MonolithicHiddenAPIInfoProvider, monolithicInfo)
+ android.SetProvider(ctx, MonolithicHiddenAPIInfoProvider, monolithicInfo)
return monolithicInfo
}
diff --git a/java/robolectric.go b/java/robolectric.go
index 45621fd..9e8850c 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -193,7 +193,7 @@
}
handleLibDeps := func(dep android.Module) {
- m := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
+ m, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
r.libs = append(r.libs, ctx.OtherModuleName(dep))
if !android.InList(ctx.OtherModuleName(dep), config.FrameworkLibraries) {
combinedJarJars = append(combinedJarJars, m.ImplementationAndResourcesJars...)
@@ -254,7 +254,7 @@
}
r.installFile = ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.combinedJar, installDeps...)
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
func generateRoboTestConfig(ctx android.ModuleContext, outputFile android.WritablePath,
@@ -305,8 +305,7 @@
srcJarDeps := append(android.Paths(nil), instrumentedApp.srcJarDeps...)
for _, m := range ctx.GetDirectDepsWithTag(roboCoverageLibsTag) {
- if ctx.OtherModuleHasProvider(m, JavaInfoProvider) {
- dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
+ if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok {
srcJarArgs = append(srcJarArgs, dep.SrcJarArgs...)
srcJarDeps = append(srcJarDeps, dep.SrcJarDeps...)
}
diff --git a/java/sdk.go b/java/sdk.go
index ad71fb2..352b243 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -262,8 +262,7 @@
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
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 176bda0..0584281 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -673,8 +673,7 @@
}
func (paths *scopePaths) extractStubsLibraryInfoFromDependency(ctx android.ModuleContext, dep android.Module) error {
- if ctx.OtherModuleHasProvider(dep, JavaInfoProvider) {
- lib := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
+ if lib, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok {
paths.stubsHeaderPath = lib.HeaderJars
paths.stubsImplPath = lib.ImplementationJars
@@ -1451,7 +1450,7 @@
// Make the set of components exported by this module available for use elsewhere.
exportedComponentInfo := android.ExportedComponentsInfo{Components: android.SortedKeys(exportedComponents)}
- ctx.SetProvider(android.ExportedComponentsInfoProvider, exportedComponentInfo)
+ android.SetProvider(ctx, android.ExportedComponentsInfoProvider, exportedComponentInfo)
// Provide additional information for inclusion in an sdk's generated .info file.
additionalSdkInfo := map[string]interface{}{}
@@ -1471,7 +1470,7 @@
scopeInfo["latest_removed_api"] = p.Path().String()
}
}
- ctx.SetProvider(android.AdditionalSdkInfoProvider, android.AdditionalSdkInfo{additionalSdkInfo})
+ android.SetProvider(ctx, android.AdditionalSdkInfoProvider, android.AdditionalSdkInfo{additionalSdkInfo})
}
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
@@ -2036,8 +2035,8 @@
// If either this or the other module are on the platform then this will return
// false.
func withinSameApexesAs(ctx android.BaseModuleContext, other android.Module) bool {
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
- otherApexInfo := ctx.OtherModuleProvider(other, android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ otherApexInfo, _ := android.OtherModuleProvider(ctx, other, android.ApexInfoProvider)
return len(otherApexInfo.InApexVariants) > 0 && reflect.DeepEqual(apexInfo.InApexVariants, otherApexInfo.InApexVariants)
}
@@ -2693,7 +2692,7 @@
if ctx.Device() {
// If this is a variant created for a prebuilt_apex then use the dex implementation jar
// obtained from the associated deapexer module.
- ai := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ ai, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if ai.ForPrebuiltApex {
// Get the path of the dex implementation jar from the `deapexer` module.
di := android.FindDeapexerProviderForModule(ctx)
@@ -2960,7 +2959,7 @@
// File path to the runtime implementation library
func (module *sdkLibraryXml) implPath(ctx android.ModuleContext) string {
implName := proptools.String(module.properties.Lib_name)
- if apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo); !apexInfo.IsForPlatform() {
+ if apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider); !apexInfo.IsForPlatform() {
// TODO(b/146468504): ApexVariationName() is only a soong module name, not apex name.
// In most cases, this works fine. But when apex_name is set or override_apex is used
// this can be wrong.
@@ -3067,7 +3066,8 @@
}
func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- module.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ module.hideApexVariantFromMake = !apexInfo.IsForPlatform()
libName := proptools.String(module.properties.Lib_name)
module.selfValidate(ctx)
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index a136818..0965fc2 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -132,7 +132,7 @@
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",
diff --git a/java/system_modules.go b/java/system_modules.go
index 0efa1a4..1c79171 100644
--- a/java/system_modules.go
+++ b/java/system_modules.go
@@ -159,7 +159,7 @@
var jars android.Paths
ctx.VisitDirectDepsWithTag(systemModulesLibsTag, func(module android.Module) {
- dep, _ := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
+ dep, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
jars = append(jars, dep.HeaderJars...)
})
diff --git a/java/system_modules_test.go b/java/system_modules_test.go
index 7b5a386..2ceca5d 100644
--- a/java/system_modules_test.go
+++ b/java/system_modules_test.go
@@ -24,7 +24,7 @@
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
diff --git a/java/test_spec_test.go b/java/test_spec_test.go
index 1409b28..f628b4b 100644
--- a/java/test_spec_test.go
+++ b/java/test_spec_test.go
@@ -34,9 +34,7 @@
).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",
) {
diff --git a/java/testing.go b/java/testing.go
index e883bcb..d55cffc 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -617,7 +617,7 @@
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 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 {
diff --git a/multitree/api_imports.go b/multitree/api_imports.go
index e4c21f8..51b9e07 100644
--- a/multitree/api_imports.go
+++ b/multitree/api_imports.go
@@ -81,7 +81,7 @@
headerLibs := generateNameMapWithSuffix(imports.properties.Header_libs)
apexSharedLibs := generateNameMapWithSuffix(imports.properties.Apex_shared_libs)
- ctx.SetProvider(ApiImportsProvider, ApiImportInfo{
+ android.SetProvider(ctx, ApiImportsProvider, ApiImportInfo{
SharedLibs: sharedLibs,
HeaderLibs: headerLibs,
ApexSharedLibs: apexSharedLibs,
diff --git a/python/python.go b/python/python.go
index 79b1515..d3cbd76 100644
--- a/python/python.go
+++ b/python/python.go
@@ -420,7 +420,7 @@
// GenerateAndroidBuildActions performs build actions common to all Python modules
func (p *PythonLibraryModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
expandedSrcs := android.PathsForModuleSrcExcludes(ctx, p.properties.Srcs, p.properties.Exclude_srcs)
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: expandedSrcs.Strings()})
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: expandedSrcs.Strings()})
// expand data files from "data" property.
expandedData := android.PathsForModuleSrc(ctx, p.properties.Data)
diff --git a/python/test.go b/python/test.go
index f15a8fc..782f39f 100644
--- a/python/test.go
+++ b/python/test.go
@@ -208,7 +208,7 @@
installedData := ctx.InstallTestData(installDir, p.data)
p.installedDest = ctx.InstallFile(installDir, p.installSource.Base(), p.installSource, installedData...)
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
func (p *PythonTestModule) AndroidMkEntries() []android.AndroidMkEntries {
diff --git a/rust/afdo.go b/rust/afdo.go
index 3534ee6..323ee36 100644
--- a/rust/afdo.go
+++ b/rust/afdo.go
@@ -67,8 +67,7 @@
}
ctx.VisitDirectDepsWithTag(cc.FdoProfileTag, func(m android.Module) {
- if ctx.OtherModuleHasProvider(m, cc.FdoProfileProvider) {
- info := ctx.OtherModuleProvider(m, cc.FdoProfileProvider).(cc.FdoProfileInfo)
+ if info, ok := android.OtherModuleProvider(ctx, m, cc.FdoProfileProvider); ok {
path := info.Path
profileUseFlag := fmt.Sprintf(afdoFlagFormat, path.String())
flags.RustFlags = append(flags.RustFlags, profileUseFlag)
diff --git a/rust/library.go b/rust/library.go
index 199ffbb..7f004fc 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -547,7 +547,7 @@
}
if library.static() || library.shared() {
- ctx.SetProvider(cc.FlagExporterInfoProvider, cc.FlagExporterInfo{
+ android.SetProvider(ctx, cc.FlagExporterInfoProvider, cc.FlagExporterInfo{
IncludeDirs: library.includeDirs,
})
}
@@ -559,7 +559,7 @@
library.tocFile = android.OptionalPathForPath(tocFile)
cc.TransformSharedObjectToToc(ctx, outputFile, tocFile)
- ctx.SetProvider(cc.SharedLibraryInfoProvider, cc.SharedLibraryInfo{
+ android.SetProvider(ctx, cc.SharedLibraryInfoProvider, cc.SharedLibraryInfo{
TableOfContents: android.OptionalPathForPath(tocFile),
SharedLibrary: outputFile,
Target: ctx.Target(),
@@ -568,7 +568,7 @@
if library.static() {
depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(outputFile).Build()
- ctx.SetProvider(cc.StaticLibraryInfoProvider, cc.StaticLibraryInfo{
+ android.SetProvider(ctx, cc.StaticLibraryInfoProvider, cc.StaticLibraryInfo{
StaticLibrary: outputFile,
TransitiveStaticLibrariesForOrdering: depSet,
diff --git a/rust/protobuf.go b/rust/protobuf.go
index c80e5f4..d021076 100644
--- a/rust/protobuf.go
+++ b/rust/protobuf.go
@@ -178,7 +178,7 @@
// stemFile must be first here as the first path in BaseSourceProvider.OutputFiles is the library entry-point.
proto.BaseSourceProvider.OutputFiles = append(android.Paths{stemFile}, outputs.Paths()...)
- ctx.SetProvider(cc.FlagExporterInfoProvider, cc.FlagExporterInfo{
+ android.SetProvider(ctx, cc.FlagExporterInfoProvider, cc.FlagExporterInfo{
IncludeDirs: android.PathsForModuleSrc(ctx, proto.Properties.Exported_include_dirs),
})
diff --git a/rust/rust.go b/rust/rust.go
index c07966b..521f624 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -509,7 +509,7 @@
}
func (flagExporter *flagExporter) setProvider(ctx ModuleContext) {
- ctx.SetProvider(FlagExporterInfoProvider, FlagExporterInfo{
+ android.SetProvider(ctx, FlagExporterInfoProvider, FlagExporterInfo{
LinkDirs: flagExporter.linkDirs,
LinkObjects: flagExporter.linkObjects,
})
@@ -747,7 +747,8 @@
}
func (ctx moduleContext) apexVariationName() string {
- return ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).ApexVariationName
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ return apexInfo.ApexVariationName
}
var _ cc.LinkableInterface = (*Module)(nil)
@@ -897,7 +898,7 @@
ModuleContext: actx,
}
- apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
mod.hideApexVariantFromMake = true
}
@@ -950,7 +951,7 @@
sourceLib := sourceMod.(*Module).compiler.(*libraryDecorator)
mod.sourceProvider.setOutputFiles(sourceLib.sourceProvider.Srcs())
}
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: mod.sourceProvider.Srcs().Strings()})
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: mod.sourceProvider.Srcs().Strings()})
}
if mod.compiler != nil && !mod.compiler.Disabled() {
@@ -978,7 +979,7 @@
}
}
- apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !proptools.BoolDefault(mod.Installable(), mod.EverInstallable()) && !mod.ProcMacro() {
// If the module has been specifically configure to not be installed then
// hide from make as otherwise it will break when running inside make as the
@@ -1003,7 +1004,7 @@
ctx.Phony("rust", ctx.RustModule().OutputFile().Path())
}
if mod.testModule {
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
aconfig.CollectDependencyAconfigFiles(ctx, &mod.mergedAconfigFiles)
@@ -1148,7 +1149,7 @@
// For the dependency from platform to apex, use the latest stubs
mod.apexSdkVersion = android.FutureApiLevel
- apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
mod.apexSdkVersion = apexInfo.MinSdkVersion
}
@@ -1167,7 +1168,7 @@
ctx.VisitDirectDeps(func(dep android.Module) {
if dep.Name() == "api_imports" {
- apiImportInfo = ctx.OtherModuleProvider(dep, multitree.ApiImportsProvider).(multitree.ApiImportInfo)
+ apiImportInfo, _ = android.OtherModuleProvider(ctx, dep, multitree.ApiImportsProvider)
hasApiImportInfo = true
}
})
@@ -1278,7 +1279,7 @@
//Append the dependencies exportedDirs, except for proc-macros which target a different arch/OS
if depTag != procMacroDepTag {
- exportedInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
+ exportedInfo, _ := android.OtherModuleProvider(ctx, dep, FlagExporterInfoProvider)
depPaths.linkDirs = append(depPaths.linkDirs, exportedInfo.LinkDirs...)
depPaths.depFlags = append(depPaths.depFlags, exportedInfo.Flags...)
depPaths.linkObjects = append(depPaths.linkObjects, exportedInfo.LinkObjects...)
@@ -1294,7 +1295,7 @@
if depTag == sourceDepTag {
if _, ok := mod.sourceProvider.(*protobufDecorator); ok && mod.Source() {
if _, ok := rustDep.sourceProvider.(*protobufDecorator); ok {
- exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
+ exportedInfo, _ := android.OtherModuleProvider(ctx, dep, cc.FlagExporterInfoProvider)
depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
}
}
@@ -1347,7 +1348,7 @@
depPaths.linkObjects = append(depPaths.linkObjects, linkObject.String())
depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
- exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
+ exportedInfo, _ := android.OtherModuleProvider(ctx, dep, cc.FlagExporterInfoProvider)
depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
depPaths.depClangFlags = append(depPaths.depClangFlags, exportedInfo.Flags...)
@@ -1391,7 +1392,7 @@
directAndroidMkSharedLibs = append(directAndroidMkSharedLibs, makeLibName)
exportDep = true
case cc.IsHeaderDepTag(depTag):
- exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
+ exportedInfo, _ := android.OtherModuleProvider(ctx, dep, cc.FlagExporterInfoProvider)
depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
diff --git a/rust/sanitize.go b/rust/sanitize.go
index 0b10435..9dda43f 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -270,7 +270,7 @@
}
// If we're using snapshots, redirect to snapshot whenever possible
// TODO(b/178470649): clean manual snapshot redirections
- snapshot := mctx.Provider(cc.SnapshotInfoProvider).(cc.SnapshotInfo)
+ snapshot, _ := android.ModuleProvider(mctx, cc.SnapshotInfoProvider)
if lib, ok := snapshot.StaticLibs[noteDep]; ok {
noteDep = lib
}
diff --git a/sdk/update.go b/sdk/update.go
index 4c39fae..095e0c2 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -166,10 +166,7 @@
// Keep track of which multilib variants are used by the sdk.
s.multilibUsages = s.multilibUsages.addArchType(child.Target().Arch.ArchType)
- var exportedComponentsInfo android.ExportedComponentsInfo
- if ctx.OtherModuleHasProvider(child, android.ExportedComponentsInfoProvider) {
- exportedComponentsInfo = ctx.OtherModuleProvider(child, android.ExportedComponentsInfoProvider).(android.ExportedComponentsInfo)
- }
+ exportedComponentsInfo, _ := android.OtherModuleProvider(ctx, child, android.ExportedComponentsInfoProvider)
var container android.Module
if parent != ctx.Module() {
@@ -607,7 +604,7 @@
name: name,
}
- additionalSdkInfo := ctx.OtherModuleProvider(module, android.AdditionalSdkInfoProvider).(android.AdditionalSdkInfo)
+ additionalSdkInfo, _ := android.OtherModuleProvider(ctx, module, android.AdditionalSdkInfoProvider)
info.memberSpecific = additionalSdkInfo.Properties
name2Info[name] = info
@@ -1171,7 +1168,7 @@
// The licenses are the same for all variants.
mctx := s.ctx
- licenseInfo := mctx.OtherModuleProvider(variant, android.LicenseInfoProvider).(android.LicenseInfo)
+ licenseInfo, _ := android.OtherModuleProvider(mctx, variant, android.LicenseInfoProvider)
if len(licenseInfo.Licenses) > 0 {
m.AddPropertyWithTag("licenses", licenseInfo.Licenses, s.OptionalSdkMemberReferencePropertyTag())
}
@@ -1417,7 +1414,7 @@
variantsByApex := make(map[string]android.Module)
conflictDetected := false
for _, variant := range list {
- apexInfo := moduleCtx.OtherModuleProvider(variant, android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.OtherModuleProvider(moduleCtx, variant, android.ApexInfoProvider)
apexVariationName := apexInfo.ApexVariationName
// If there are two variants for a specific APEX variation then there is conflict.
if _, ok := variantsByApex[apexVariationName]; ok {
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index 1e27375..97adeed 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -270,7 +270,7 @@
Output: s.outputFilePath,
Input: s.sourceFilePath,
})
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: []string{s.sourceFilePath.String()}})
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: []string{s.sourceFilePath.String()}})
}
func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -457,7 +457,7 @@
installedData := ctx.InstallTestData(s.installDir, s.data)
s.installedFile = ctx.InstallExecutable(s.installDir, s.outputFilePath.Base(), s.outputFilePath, installedData...)
- ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
func (s *ShTest) InstallInData() bool {
diff --git a/snapshot/host_fake_snapshot.go b/snapshot/host_fake_snapshot.go
index c4cfbb5..63cd4e1 100644
--- a/snapshot/host_fake_snapshot.go
+++ b/snapshot/host_fake_snapshot.go
@@ -119,7 +119,7 @@
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
}
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index c89c6b0..4a0796b 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -251,7 +251,7 @@
ctx.PropertyErrorf("srcs", "srcs contains non-sysprop file %q", syspropFile.String())
}
}
- ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()})
+ android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()})
if ctx.Failed() {
return
diff --git a/testing/all_code_metadata.go b/testing/all_code_metadata.go
index 16d7aae..12aa7b5 100644
--- a/testing/all_code_metadata.go
+++ b/testing/all_code_metadata.go
@@ -21,14 +21,9 @@
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,
- )
},
)
diff --git a/testing/all_test_specs.go b/testing/all_test_specs.go
index 9d4645b..b035435 100644
--- a/testing/all_test_specs.go
+++ b/testing/all_test_specs.go
@@ -21,10 +21,9 @@
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)
diff --git a/testing/code_metadata.go b/testing/code_metadata.go
index 53bd07b..3cf7c59 100644
--- a/testing/code_metadata.go
+++ b/testing/code_metadata.go
@@ -96,10 +96,8 @@
for _, m := range ctx.GetDirectDepsWithTag(codeDepTag) {
targetName := m.Name()
var moduleSrcs []string
- if ctx.OtherModuleHasProvider(m, blueprint.SrcsFileProviderKey) {
- moduleSrcs = ctx.OtherModuleProvider(
- m, blueprint.SrcsFileProviderKey,
- ).(blueprint.SrcsFileProviderData).SrcPaths
+ if srcsFileInfo, ok := android.OtherModuleProvider(ctx, m, blueprint.SrcsFileProviderKey); ok {
+ moduleSrcs = srcsFileInfo.SrcPaths
}
if module.properties.MultiOwnership {
metadata := &code_metadata_internal_proto.CodeMetadataInternal_TargetOwnership{
@@ -132,7 +130,7 @@
)
android.WriteFileRule(ctx, intermediatePath, string(protoData))
- ctx.SetProvider(
+ android.SetProvider(ctx,
CodeMetadataProviderKey,
CodeMetadataProviderData{IntermediatePath: intermediatePath},
)
diff --git a/testing/test_spec.go b/testing/test_spec.go
index 2a05456..d259612 100644
--- a/testing/test_spec.go
+++ b/testing/test_spec.go
@@ -91,7 +91,7 @@
func (module *TestSpecModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
for _, m := range ctx.GetDirectDepsWithTag(testsDepTag) {
- if !ctx.OtherModuleHasProvider(m, TestModuleProviderKey) {
+ if _, ok := android.OtherModuleProvider(ctx, m, TestModuleProviderKey); !ok {
ctx.ModuleErrorf(ErrTestModuleDataNotFound, m.Name())
}
}
@@ -119,7 +119,7 @@
}
android.WriteFileRule(ctx, intermediatePath, string(protoData))
- ctx.SetProvider(
+ android.SetProvider(ctx,
TestSpecProviderKey, TestSpecProviderData{
IntermediatePath: intermediatePath,
},