diff options
author | 2025-02-21 20:46:25 +0000 | |
---|---|---|
committer | 2025-02-25 19:05:07 +0000 | |
commit | 2a815b6d8ea8f29b54f780b1219c28b0c8c977aa (patch) | |
tree | 3637bda1bc41a893d7d0a502798d47c74434cb70 | |
parent | a88b86ff5d86306ec15bc1de7892d17b4154210e (diff) |
Convert the following singletons to use ModuleProxy:
buildTargetSingleton
exportedJavaDeclarationsLibrarySingleton
javaFuzzPackager
kytheExtractAllSingleton
kytheExtractJavaSingleton
kytheExtractRustSingleton
lintSingleton
logtagsSingleton
makeVarsSingleton
ndkAbiDiffSingleton
ndkAbiDumpSingleton
phonySingleton
platformCompatConfigSingleton
sdkSingleton
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I625ac8a209ca93755b2ba232202cfb44ecefde0a
-rw-r--r-- | aconfig/exported_java_aconfig_library.go | 5 | ||||
-rw-r--r-- | android/filegroup.go | 5 | ||||
-rw-r--r-- | android/logtags.go | 4 | ||||
-rw-r--r-- | android/makevars.go | 31 | ||||
-rw-r--r-- | android/module.go | 12 | ||||
-rw-r--r-- | android/paths.go | 2 | ||||
-rw-r--r-- | android/phony.go | 2 | ||||
-rw-r--r-- | android/prebuilt_build_tool.go | 11 | ||||
-rw-r--r-- | cc/cc.go | 21 | ||||
-rw-r--r-- | cc/ndk_abi.go | 22 | ||||
-rw-r--r-- | filesystem/android_device.go | 5 | ||||
-rw-r--r-- | filesystem/filesystem.go | 5 | ||||
-rw-r--r-- | java/aar.go | 8 | ||||
-rw-r--r-- | java/java.go | 16 | ||||
-rw-r--r-- | java/lint.go | 19 | ||||
-rw-r--r-- | java/platform_compat_config.go | 30 | ||||
-rw-r--r-- | java/sdk.go | 2 | ||||
-rw-r--r-- | java/support_libraries.go | 15 | ||||
-rw-r--r-- | rust/rust.go | 8 |
19 files changed, 156 insertions, 67 deletions
diff --git a/aconfig/exported_java_aconfig_library.go b/aconfig/exported_java_aconfig_library.go index 63d824a88..ffb2a0cbe 100644 --- a/aconfig/exported_java_aconfig_library.go +++ b/aconfig/exported_java_aconfig_library.go @@ -15,8 +15,9 @@ package aconfig import ( - "android/soong/android" "strconv" + + "android/soong/android" ) func ExportedJavaDeclarationsLibraryFactory() android.Singleton { @@ -30,7 +31,7 @@ type exportedJavaDeclarationsLibrarySingleton struct { func (this *exportedJavaDeclarationsLibrarySingleton) GenerateBuildActions(ctx android.SingletonContext) { // Find all of the aconfig_declarations modules var cacheFiles android.Paths - ctx.VisitAllModules(func(module android.Module) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { decl, ok := android.OtherModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey) if !ok { return diff --git a/android/filegroup.go b/android/filegroup.go index 47102b915..4fad52aaa 100644 --- a/android/filegroup.go +++ b/android/filegroup.go @@ -131,10 +131,11 @@ func (fg *fileGroup) Srcs() Paths { return append(Paths{}, fg.srcs...) } -func (fg *fileGroup) MakeVars(ctx MakeVarsModuleContext) { +func (fg *fileGroup) MakeVars(_ MakeVarsModuleContext) []ModuleMakeVarsValue { if makeVar := String(fg.properties.Export_to_make_var); makeVar != "" { - ctx.StrictRaw(makeVar, strings.Join(fg.srcs.Strings(), " ")) + return []ModuleMakeVarsValue{{makeVar, strings.Join(fg.srcs.Strings(), " ")}} } + return nil } // Defaults diff --git a/android/logtags.go b/android/logtags.go index abc37f997..88d36ec72 100644 --- a/android/logtags.go +++ b/android/logtags.go @@ -42,8 +42,8 @@ func MergedLogtagsPath(ctx PathContext) OutputPath { func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) { var allLogtags Paths - ctx.VisitAllModules(func(module Module) { - if !module.ExportedToMake() { + ctx.VisitAllModuleProxies(func(module ModuleProxy) { + if !OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoKey).ExportedToMake { return } if logtagsInfo, ok := OtherModuleProvider(ctx, module, LogtagsProviderKey); ok { diff --git a/android/makevars.go b/android/makevars.go index 2931d0bed..692b27ec6 100644 --- a/android/makevars.go +++ b/android/makevars.go @@ -84,6 +84,7 @@ type MakeVarsContext interface { Errorf(format string, args ...interface{}) VisitAllModules(visit func(Module)) + VisitAllModuleProxies(visit func(proxy ModuleProxy)) VisitAllModulesIf(pred func(Module) bool, visit func(Module)) // Verify the make variable matches the Soong version, fail the build @@ -108,7 +109,7 @@ type MakeVarsContext interface { // MakeVarsModuleContext contains the set of functions available for modules // implementing the ModuleMakeVarsProvider interface. type MakeVarsModuleContext interface { - BaseMakeVarsContext + Config() Config } var _ PathContext = MakeVarsContext(nil) @@ -150,14 +151,21 @@ func singletonMakeVarsProviderAdapter(singleton SingletonMakeVarsProvider) MakeV return func(ctx MakeVarsContext) { singleton.MakeVars(ctx) } } +type ModuleMakeVarsValue struct { + // Make variable name. + Name string + // Make variable value. + Value string +} + // ModuleMakeVarsProvider is a Module with an extra method to provide extra values to be exported to Make. type ModuleMakeVarsProvider interface { - Module - // MakeVars uses a MakeVarsModuleContext to provide extra values to be exported to Make. - MakeVars(ctx MakeVarsModuleContext) + MakeVars(ctx MakeVarsModuleContext) []ModuleMakeVarsValue } +var ModuleMakeVarsInfoProvider = blueprint.NewProvider[[]ModuleMakeVarsValue]() + // ///////////////////////////////////////////////////////////////////////////// func makeVarsSingletonFunc() Singleton { @@ -250,19 +258,24 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) { dists = append(dists, singletonDists.dists...) singletonDists.lock.Unlock() - ctx.VisitAllModules(func(m Module) { - if provider, ok := m.(ModuleMakeVarsProvider); ok && m.Enabled(ctx) { + ctx.VisitAllModuleProxies(func(m ModuleProxy) { + commonInfo, _ := OtherModuleProvider(ctx, m, CommonModuleInfoKey) + if provider, ok := OtherModuleProvider(ctx, m, ModuleMakeVarsInfoProvider); ok && + commonInfo.Enabled { mctx := &makeVarsContext{ SingletonContext: ctx, } - - provider.MakeVars(mctx) + for _, val := range provider { + if val.Name != "" { + mctx.StrictRaw(val.Name, val.Value) + } + } vars = append(vars, mctx.vars...) phonies = append(phonies, mctx.phonies...) } - if m.ExportedToMake() { + if commonInfo.ExportedToMake { info := OtherModuleProviderOrDefault(ctx, m, InstallFilesProvider) katiInstalls = append(katiInstalls, info.KatiInstalls...) katiInitRcInstalls = append(katiInitRcInstalls, info.KatiInitRcInstalls...) diff --git a/android/module.go b/android/module.go index 996c64e52..984f0372a 100644 --- a/android/module.go +++ b/android/module.go @@ -1939,6 +1939,7 @@ type CommonModuleInfo struct { TargetRequiredModuleNames []string VintfFragmentModuleNames []string Dists []Dist + ExportedToMake bool } type ApiLevelOrPlatform struct { @@ -2298,6 +2299,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) TargetRequiredModuleNames: m.module.TargetRequiredModuleNames(), VintfFragmentModuleNames: m.module.VintfFragmentModuleNames(ctx), Dists: m.Dists(), + ExportedToMake: m.ExportedToMake(), } if mm, ok := m.module.(interface { MinSdkVersion(ctx EarlyModuleContext) ApiLevel @@ -2368,6 +2370,10 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) GeneratedDeps: s.GeneratedDeps(), }) } + + if v, ok := m.module.(ModuleMakeVarsProvider); m.Enabled(ctx) && ok { + SetProvider(ctx, ModuleMakeVarsInfoProvider, v.MakeVars(ctx)) + } } func SetJarJarPrefixHandler(handler func(ModuleContext)) { @@ -2884,6 +2890,8 @@ func OutputFilesForModule(ctx PathContext, module Module, tag string) Paths { // OutputFileForModule returns the output file paths with the given tag. On error, including if the // module produced zero or multiple paths, it reports errors to the ctx and returns nil. +// TODO(b/397766191): Change the signature to take ModuleProxy +// Please only access the module's internal data through providers. func OutputFileForModule(ctx PathContext, module Module, tag string) Path { paths, err := outputFilesForModule(ctx, module, tag) if err != nil { @@ -2924,6 +2932,8 @@ type OutputFilesProviderModuleContext interface { EqualModules(m1, m2 Module) bool } +// TODO(b/397766191): Change the signature to take ModuleProxy +// Please only access the module's internal data through providers. func outputFilesForModule(ctx PathContext, module Module, tag string) (Paths, error) { outputFilesFromProvider, err := outputFilesForModuleFromProvider(ctx, module, tag) if outputFilesFromProvider != nil || err != OutputFilesProviderNotSet { @@ -3069,7 +3079,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) { modulesInDir := make(map[string]Paths) - ctx.VisitAllModules(func(module Module) { + ctx.VisitAllModuleProxies(func(module ModuleProxy) { info := OtherModuleProviderOrDefault(ctx, module, FinalModuleBuildTargetsProvider) if info.CheckbuildTarget != nil { diff --git a/android/paths.go b/android/paths.go index 1c0321c02..a944c48db 100644 --- a/android/paths.go +++ b/android/paths.go @@ -229,6 +229,8 @@ func ReportPathErrorf(ctx PathContext, format string, args ...interface{}) { } } +// TODO(b/397766191): Change the signature to take ModuleProxy +// Please only access the module's internal data through providers. func pathContextName(ctx PathContext, module blueprint.Module) string { if x, ok := ctx.(interface{ ModuleName(blueprint.Module) string }); ok { return x.ModuleName(module) diff --git a/android/phony.go b/android/phony.go index 7bdd9d31d..99ff0aaa4 100644 --- a/android/phony.go +++ b/android/phony.go @@ -55,7 +55,7 @@ var _ SingletonMakeVarsProvider = (*phonySingleton)(nil) func (p *phonySingleton) GenerateBuildActions(ctx SingletonContext) { p.phonyMap = getSingletonPhonyMap(ctx.Config()) - ctx.VisitAllModules(func(m Module) { + ctx.VisitAllModuleProxies(func(m ModuleProxy) { if info, ok := OtherModuleProvider(ctx, m, ModulePhonyProvider); ok { for k, v := range info.Phonies { p.phonyMap[k] = append(p.phonyMap[k], v...) diff --git a/android/prebuilt_build_tool.go b/android/prebuilt_build_tool.go index 17b323067..7773bf8af 100644 --- a/android/prebuilt_build_tool.go +++ b/android/prebuilt_build_tool.go @@ -84,13 +84,12 @@ func (t *prebuiltBuildTool) GenerateAndroidBuildActions(ctx ModuleContext) { t.toolPath = OptionalPathForPath(installedPath) } -func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) { - if makeVar := String(t.properties.Export_to_make_var); makeVar != "" { - if t.Target().Os != ctx.Config().BuildOS { - return - } - ctx.StrictRaw(makeVar, t.toolPath.String()) +func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) []ModuleMakeVarsValue { + if makeVar := String(t.properties.Export_to_make_var); makeVar != "" && + t.Target().Os == ctx.Config().BuildOS { + return []ModuleMakeVarsValue{{makeVar, t.toolPath.String()}} } + return nil } func (t *prebuiltBuildTool) HostToolPath() OptionalPath { @@ -104,7 +104,11 @@ type TestBinaryInfo struct { } type BenchmarkDecoratorInfo struct{} -type StubDecoratorInfo struct{} +type StubDecoratorInfo struct { + AbiDumpPath android.OutputPath + HasAbiDump bool + AbiDiffPaths android.Paths +} type ObjectLinkerInfo struct{} @@ -112,6 +116,10 @@ type LibraryInfo struct { BuildStubs bool } +type InstallerInfo struct { + StubDecoratorInfo *StubDecoratorInfo +} + // Common info about the cc module. type CcInfo struct { IsPrebuilt bool @@ -122,6 +130,7 @@ type CcInfo struct { LinkerInfo *LinkerInfo SnapshotInfo *SnapshotInfo LibraryInfo *LibraryInfo + InstallerInfo *InstallerInfo } var CcInfoProvider = blueprint.NewProvider[*CcInfo]() @@ -2362,6 +2371,16 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { BuildStubs: c.library.BuildStubs(), } } + if c.installer != nil { + ccInfo.InstallerInfo = &InstallerInfo{} + if installer, ok := c.installer.(*stubDecorator); ok { + ccInfo.InstallerInfo.StubDecoratorInfo = &StubDecoratorInfo{ + HasAbiDump: installer.hasAbiDump, + AbiDumpPath: installer.abiDumpPath, + AbiDiffPaths: installer.abiDiffPaths, + } + } + } android.SetProvider(ctx, CcInfoProvider, &ccInfo) c.setOutputFiles(ctx) diff --git a/cc/ndk_abi.go b/cc/ndk_abi.go index 2706261a8..a9f26a40e 100644 --- a/cc/ndk_abi.go +++ b/cc/ndk_abi.go @@ -39,15 +39,15 @@ type ndkAbiDumpSingleton struct{} func (n *ndkAbiDumpSingleton) GenerateBuildActions(ctx android.SingletonContext) { var depPaths android.Paths - ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled(ctx) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).Enabled { return } - if m, ok := module.(*Module); ok { - if installer, ok := m.installer.(*stubDecorator); ok { - if installer.hasAbiDump { - depPaths = append(depPaths, installer.abiDumpPath) + if ccInfo, ok := android.OtherModuleProvider(ctx, module, CcInfoProvider); ok { + if ccInfo.InstallerInfo != nil && ccInfo.InstallerInfo.StubDecoratorInfo != nil { + if ccInfo.InstallerInfo.StubDecoratorInfo.HasAbiDump { + depPaths = append(depPaths, ccInfo.InstallerInfo.StubDecoratorInfo.AbiDumpPath) } } } @@ -77,14 +77,14 @@ type ndkAbiDiffSingleton struct{} func (n *ndkAbiDiffSingleton) GenerateBuildActions(ctx android.SingletonContext) { var depPaths android.Paths - ctx.VisitAllModules(func(module android.Module) { - if m, ok := module.(android.Module); ok && !m.Enabled(ctx) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).Enabled { return } - if m, ok := module.(*Module); ok { - if installer, ok := m.installer.(*stubDecorator); ok { - depPaths = append(depPaths, installer.abiDiffPaths...) + if ccInfo, ok := android.OtherModuleProvider(ctx, module, CcInfoProvider); ok { + if ccInfo.InstallerInfo != nil && ccInfo.InstallerInfo.StubDecoratorInfo != nil { + depPaths = append(depPaths, ccInfo.InstallerInfo.StubDecoratorInfo.AbiDiffPaths...) } } }) diff --git a/filesystem/android_device.go b/filesystem/android_device.go index fef4aeb43..178c716d4 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -325,10 +325,11 @@ func (a *androidDevice) distFiles(ctx android.ModuleContext) { } } -func (a *androidDevice) MakeVars(ctx android.MakeVarsModuleContext) { +func (a *androidDevice) MakeVars(_ android.MakeVarsModuleContext) []android.ModuleMakeVarsValue { if proptools.Bool(a.deviceProps.Main_device) { - ctx.StrictRaw("SOONG_ONLY_ALL_IMAGES_ZIP", a.allImagesZip.String()) + return []android.ModuleMakeVarsValue{{"SOONG_ONLY_ALL_IMAGES_ZIP", a.allImagesZip.String()}} } + return nil } func (a *androidDevice) buildProguardZips(ctx android.ModuleContext, allInstalledModules []android.Module) { diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 28eb36d1e..d4ea6a34c 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -1525,10 +1525,11 @@ func addAutogeneratedRroDeps(ctx android.BottomUpMutatorContext) { }) } -func (f *filesystem) MakeVars(ctx android.MakeVarsModuleContext) { +func (f *filesystem) MakeVars(ctx android.MakeVarsModuleContext) []android.ModuleMakeVarsValue { if f.Name() == ctx.Config().SoongDefinedSystemImage() { - ctx.StrictRaw("SOONG_DEFINED_SYSTEM_IMAGE_PATH", f.output.String()) + return []android.ModuleMakeVarsValue{{"SOONG_DEFINED_SYSTEM_IMAGE_PATH", f.output.String()}} } + return nil } func setCommonFilesystemInfo(ctx android.ModuleContext, m Filesystem) { diff --git a/java/aar.go b/java/aar.go index 976e4fcb1..0e27cb8fd 100644 --- a/java/aar.go +++ b/java/aar.go @@ -945,6 +945,12 @@ type AndroidLibraryInfo struct { var AndroidLibraryInfoProvider = blueprint.NewProvider[AndroidLibraryInfo]() +type AARImportInfo struct { + // Empty for now +} + +var AARImportInfoProvider = blueprint.NewProvider[AARImportInfo]() + type AndroidLibrary struct { Library aapt @@ -1571,6 +1577,8 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { JniPackages: a.jniPackages, }) + android.SetProvider(ctx, AARImportInfoProvider, AARImportInfo{}) + ctx.SetOutputFiles([]android.Path{a.implementationAndResourcesJarFile}, "") ctx.SetOutputFiles([]android.Path{a.aarPath}, ".aar") diff --git a/java/java.go b/java/java.go index b18c56130..38361bfa7 100644 --- a/java/java.go +++ b/java/java.go @@ -432,6 +432,9 @@ type JavaInfo struct { DexJarBuildPath OptionalDexJarPath DexpreopterInfo *DexpreopterInfo + + XrefJavaFiles android.Paths + XrefKotlinFiles android.Paths } var JavaInfoProvider = blueprint.NewProvider[*JavaInfo]() @@ -3649,10 +3652,10 @@ type kytheExtractJavaSingleton struct { func (ks *kytheExtractJavaSingleton) GenerateBuildActions(ctx android.SingletonContext) { var xrefTargets android.Paths var xrefKotlinTargets android.Paths - ctx.VisitAllModules(func(module android.Module) { - if javaModule, ok := module.(xref); ok { - xrefTargets = append(xrefTargets, javaModule.XrefJavaFiles()...) - xrefKotlinTargets = append(xrefKotlinTargets, javaModule.XrefKotlinFiles()...) + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + if javaInfo, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { + xrefTargets = append(xrefTargets, javaInfo.XrefJavaFiles...) + xrefKotlinTargets = append(xrefKotlinTargets, javaInfo.XrefKotlinFiles...) } }) // TODO(asmundak): perhaps emit a rule to output a warning if there were no xrefTargets @@ -3853,4 +3856,9 @@ func setExtraJavaInfo(ctx android.ModuleContext, module android.Module, javaInfo ApexSystemServerDexJars: di.ApexSystemServerDexJars(), } } + + if xr, ok := module.(xref); ok { + javaInfo.XrefJavaFiles = xr.XrefJavaFiles() + javaInfo.XrefKotlinFiles = xr.XrefKotlinFiles() + } } diff --git a/java/lint.go b/java/lint.go index 66f7f8549..c31dfd005 100644 --- a/java/lint.go +++ b/java/lint.go @@ -595,12 +595,12 @@ func (l *lintSingleton) GenerateBuildActions(ctx android.SingletonContext) { l.copyLintDependencies(ctx) } -func findModuleOrErr(ctx android.SingletonContext, moduleName string) android.Module { - var res android.Module - ctx.VisitAllModules(func(m android.Module) { +func findModuleOrErr(ctx android.SingletonContext, moduleName string) *android.ModuleProxy { + var res *android.ModuleProxy + ctx.VisitAllModuleProxies(func(m android.ModuleProxy) { if ctx.ModuleName(m) == moduleName { if res == nil { - res = m + res = &m } else { ctx.Errorf("lint: multiple %s modules found: %s and %s", moduleName, ctx.ModuleSubDir(m), ctx.ModuleSubDir(res)) @@ -635,13 +635,13 @@ func (l *lintSingleton) copyLintDependencies(ctx android.SingletonContext) { ctx.Build(pctx, android.BuildParams{ Rule: android.CpIfChanged, - Input: android.OutputFileForModule(ctx, sdkAnnotations, ""), + Input: android.OutputFileForModule(ctx, *sdkAnnotations, ""), Output: copiedLintDatabaseFilesPath(ctx, files.annotationCopiedName), }) ctx.Build(pctx, android.BuildParams{ Rule: android.CpIfChanged, - Input: android.OutputFileForModule(ctx, apiVersionsDb, ".api_versions.xml"), + Input: android.OutputFileForModule(ctx, *apiVersionsDb, ".api_versions.xml"), Output: copiedLintDatabaseFilesPath(ctx, files.apiVersionsCopiedName), }) } @@ -658,12 +658,13 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) { var outputs []*LintInfo var dirs []string - ctx.VisitAllModules(func(m android.Module) { - if ctx.Config().KatiEnabled() && !m.ExportedToMake() { + ctx.VisitAllModuleProxies(func(m android.ModuleProxy) { + commonInfo, _ := android.OtherModuleProvider(ctx, m, android.CommonModuleInfoKey) + if ctx.Config().KatiEnabled() && !commonInfo.ExportedToMake { return } - if apex, ok := m.(android.ApexModule); ok && apex.NotAvailableForPlatform() { + if commonInfo.IsApexModule && commonInfo.NotAvailableForPlatform { apexInfo, _ := android.OtherModuleProvider(ctx, m, android.ApexInfoProvider) if apexInfo.IsForPlatform() { // There are stray platform variants of modules in apexes that are not available for diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 363521a7f..ab4f8f81f 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -99,6 +99,14 @@ type platformCompatConfigMetadataProvider interface { includeInMergedXml() bool } +type PlatformCompatConfigMetadataInfo struct { + CompatConfigMetadata android.Path + // Whether to include it in the "merged" XML (merged_compat_config.xml) or not. + IncludeInMergedXml bool +} + +var PlatformCompatConfigMetadataInfoProvider = blueprint.NewProvider[PlatformCompatConfigMetadataInfo]() + type PlatformCompatConfigIntf interface { android.Module @@ -136,6 +144,11 @@ func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleCon CompatConfig: p.CompatConfig(), SubDir: p.SubDir(), }) + + android.SetProvider(ctx, PlatformCompatConfigMetadataInfoProvider, PlatformCompatConfigMetadataInfo{ + CompatConfigMetadata: p.compatConfigMetadata(), + IncludeInMergedXml: p.includeInMergedXml(), + }) } func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries { @@ -238,6 +251,11 @@ var _ platformCompatConfigMetadataProvider = (*prebuiltCompatConfigModule)(nil) func (module *prebuiltCompatConfigModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { module.metadataFile = module.prebuilt.SingleSourcePath(ctx) + + android.SetProvider(ctx, PlatformCompatConfigMetadataInfoProvider, PlatformCompatConfigMetadataInfo{ + CompatConfigMetadata: module.compatConfigMetadata(), + IncludeInMergedXml: module.includeInMergedXml(), + }) } // A prebuilt version of platform_compat_config that provides the metadata. @@ -258,18 +276,18 @@ func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.Singlet var compatConfigMetadata android.Paths - ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled(ctx) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).Enabled { return } - if c, ok := module.(platformCompatConfigMetadataProvider); ok { - if !android.IsModulePreferred(module) { + if c, ok := android.OtherModuleProvider(ctx, module, PlatformCompatConfigMetadataInfoProvider); ok { + if !android.IsModulePreferredProxy(ctx, module) { return } - if !c.includeInMergedXml() { + if !c.IncludeInMergedXml { return } - metadata := c.compatConfigMetadata() + metadata := c.CompatConfigMetadata compatConfigMetadata = append(compatConfigMetadata, metadata) } }) diff --git a/java/sdk.go b/java/sdk.go index 8510959df..ab1c653d1 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -274,7 +274,7 @@ func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) { func createFrameworkAidl(stubsModules []string, path android.WritablePath, ctx android.SingletonContext) *android.RuleBuilder { stubsJars := make([]android.Paths, len(stubsModules)) - ctx.VisitAllModules(func(module android.Module) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { // Collect dex jar paths for the modules listed above. if j, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { name := ctx.ModuleName(module) diff --git a/java/support_libraries.go b/java/support_libraries.go index c483fc17a..f76eb116e 100644 --- a/java/support_libraries.go +++ b/java/support_libraries.go @@ -28,7 +28,7 @@ func init() { func supportLibrariesMakeVarsProvider(ctx android.MakeVarsContext) { var supportAars, supportJars []string - ctx.VisitAllModules(func(module android.Module) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { dir := ctx.ModuleDir(module) switch { case strings.HasPrefix(dir, "prebuilts/sdk/current/extras"), @@ -47,11 +47,16 @@ func supportLibrariesMakeVarsProvider(ctx android.MakeVarsContext) { return } - switch module.(type) { - case *AndroidLibrary, *AARImport: + _, isAndroidLibrary := android.OtherModuleProvider(ctx, module, AndroidLibraryInfoProvider) + _, isAARImport := android.OtherModuleProvider(ctx, module, AARImportInfoProvider) + if isAndroidLibrary || isAARImport { supportAars = append(supportAars, name) - case *Library, *Import: - supportJars = append(supportJars, name) + } else { + _, isJavaLibrary := android.OtherModuleProvider(ctx, module, JavaLibraryInfoProvider) + _, isJavaPlugin := android.OtherModuleProvider(ctx, module, JavaPluginInfoProvider) + if isJavaLibrary && !isJavaPlugin { + supportJars = append(supportJars, name) + } } }) diff --git a/rust/rust.go b/rust/rust.go index 4eebda301..d8a044423 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -60,6 +60,7 @@ type RustInfo struct { CompilerInfo *CompilerInfo SnapshotInfo *cc.SnapshotInfo SourceProviderInfo *SourceProviderInfo + XrefRustFiles android.Paths } var RustInfoProvider = blueprint.NewProvider[*RustInfo]() @@ -1171,6 +1172,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { AndroidMkSuffix: mod.AndroidMkSuffix(), RustSubName: mod.Properties.RustSubName, TransitiveAndroidMkSharedLibs: mod.transitiveAndroidMkSharedLibs, + XrefRustFiles: mod.XrefRustFiles(), } if mod.compiler != nil { rustInfo.CompilerInfo = &CompilerInfo{ @@ -2236,9 +2238,9 @@ type kytheExtractRustSingleton struct { func (k kytheExtractRustSingleton) GenerateBuildActions(ctx android.SingletonContext) { var xrefTargets android.Paths - ctx.VisitAllModules(func(module android.Module) { - if rustModule, ok := module.(xref); ok { - xrefTargets = append(xrefTargets, rustModule.XrefRustFiles()...) + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + if rustModule, ok := android.OtherModuleProvider(ctx, module, RustInfoProvider); ok { + xrefTargets = append(xrefTargets, rustModule.XrefRustFiles...) } }) if len(xrefTargets) > 0 { |