diff options
author | 2025-01-14 01:03:08 +0000 | |
---|---|---|
committer | 2025-01-15 20:54:26 +0000 | |
commit | c41eae5e45123a48fd3ec9a3723fdf7adbb6f148 (patch) | |
tree | 48472e3499925ef195176d14c2fb2732b4fef261 | |
parent | 39f5fb3db37a307081cd96d334feb6a7fcc7a7d7 (diff) |
Convert collectDirectDepsProviders, collectTransitiveSrcFiles and
r8Flags to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: Ib3d45c317e1f2669808d0c785454fb8d8fb9cd3b
-rw-r--r-- | android/module.go | 6 | ||||
-rw-r--r-- | java/base.go | 12 | ||||
-rw-r--r-- | java/dex.go | 2 | ||||
-rw-r--r-- | java/droiddoc.go | 2 | ||||
-rw-r--r-- | rust/rust.go | 2 |
5 files changed, 11 insertions, 13 deletions
diff --git a/android/module.go b/android/module.go index 089f1271f..c88d04556 100644 --- a/android/module.go +++ b/android/module.go @@ -1850,7 +1850,7 @@ type SourceFilesInfo struct { Srcs Paths } -var SourceFilesInfoKey = blueprint.NewProvider[SourceFilesInfo]() +var SourceFilesInfoProvider = blueprint.NewProvider[SourceFilesInfo]() // FinalModuleBuildTargetsInfo is used by buildTargetSingleton to create checkbuild and // per-directory build targets. Only set on the final variant of each module @@ -2086,7 +2086,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) } if sourceFileProducer, ok := m.module.(SourceFileProducer); ok { - SetProvider(ctx, SourceFilesInfoKey, SourceFilesInfo{Srcs: sourceFileProducer.Srcs()}) + SetProvider(ctx, SourceFilesInfoProvider, SourceFilesInfo{Srcs: sourceFileProducer.Srcs()}) } if ctx.IsFinalModule(m.module) { @@ -2798,7 +2798,7 @@ func outputFilesForModule(ctx PathContext, module Module, tag string) (Paths, er if sourceFileProducer, ok := module.(SourceFileProducer); ok { return sourceFileProducer.Srcs(), nil } - } else if sourceFiles, ok := OtherModuleProvider(octx, module, SourceFilesInfoKey); ok { + } else if sourceFiles, ok := OtherModuleProvider(octx, module, SourceFilesInfoProvider); ok { if tag != "" { return nil, fmt.Errorf("module %q is a SourceFileProducer, which does not support tag %q", pathContextName(ctx, module), tag) } diff --git a/java/base.go b/java/base.go index 9e448c64b..8e013b954 100644 --- a/java/base.go +++ b/java/base.go @@ -2275,7 +2275,7 @@ func (j *Module) JacocoReportClassesFile() android.Path { func (j *Module) collectTransitiveSrcFiles(ctx android.ModuleContext, mine android.Paths) { var fromDeps []depset.DepSet[android.Path] - ctx.VisitDirectDeps(func(module android.Module) { + ctx.VisitDirectDepsProxy(func(module android.ModuleProxy) { tag := ctx.OtherModuleDependencyTag(module) if tag == staticLibTag { if depInfo, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { @@ -2550,7 +2550,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { JavaInfo: dep, }) } - } else if dep, ok := android.OtherModuleProvider(ctx, module, android.SourceFilesInfoKey); ok { + } else if dep, ok := android.OtherModuleProvider(ctx, module, android.SourceFilesInfoProvider); ok { switch tag { case sdkLibTag, libTag: checkProducesJars(ctx, dep, module) @@ -2740,7 +2740,7 @@ func collectDirectDepsProviders(ctx android.ModuleContext) (result *JarJarProvid module := ctx.Module() moduleName := module.Name() - ctx.VisitDirectDeps(func(m android.Module) { + ctx.VisitDirectDepsProxy(func(m android.ModuleProxy) { tag := ctx.OtherModuleDependencyTag(m) // This logic mirrors that in (*Module).collectDeps above. There are several places // where we explicitly return RenameUseExclude, even though it is the default, to @@ -2779,10 +2779,8 @@ func collectDirectDepsProviders(ctx android.ModuleContext) (result *JarJarProvid //fmt.Printf("collectDirectDepsProviders: %v -> %v StubsLinkType unknown\n", module, m) // Fall through to the heuristic logic. } - switch reflect.TypeOf(m).String() { - case "*java.GeneratedJavaLibraryModule": + if _, ok := android.OtherModuleProvider(ctx, m, android.CodegenInfoProvider); ok { // Probably a java_aconfig_library module. - // TODO: make this check better. return RenameUseInclude } switch tag { @@ -2805,7 +2803,7 @@ func collectDirectDepsProviders(ctx android.ModuleContext) (result *JarJarProvid default: return RenameUseExclude } - } else if _, ok := m.(android.SourceFileProducer); ok { + } else if _, ok := android.OtherModuleProvider(ctx, m, android.SourceFilesInfoProvider); ok { switch tag { case sdkLibTag, libTag, staticLibTag: return RenameUseInclude diff --git a/java/dex.go b/java/dex.go index 4a7e9dcc4..bc142909e 100644 --- a/java/dex.go +++ b/java/dex.go @@ -320,7 +320,7 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams, // TODO(b/360905238): Remove SdkSystemServer exception after resolving missing class references. if !dexParams.sdkVersion.Stable() || dexParams.sdkVersion.Kind == android.SdkSystemServer { var proguardRaiseDeps classpath - ctx.VisitDirectDepsWithTag(proguardRaiseTag, func(m android.Module) { + ctx.VisitDirectDepsProxyWithTag(proguardRaiseTag, func(m android.ModuleProxy) { if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok { proguardRaiseDeps = append(proguardRaiseDeps, dep.RepackagedHeaderJars...) } diff --git a/java/droiddoc.go b/java/droiddoc.go index dcbe48dfb..49674b98a 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -381,7 +381,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps { deps.classpath = append(deps.classpath, dep.HeaderJars...) deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...) deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.AconfigIntermediateCacheOutputPaths...) - } else if dep, ok := android.OtherModuleProvider(ctx, module, android.SourceFilesInfoKey); ok { + } else if dep, ok := android.OtherModuleProvider(ctx, module, android.SourceFilesInfoProvider); ok { checkProducesJars(ctx, dep, module) deps.classpath = append(deps.classpath, dep.Srcs...) } else { diff --git a/rust/rust.go b/rust/rust.go index c7aabcd7c..64288595f 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -1690,7 +1690,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } } - if srcDep, ok := android.OtherModuleProvider(ctx, dep, android.SourceFilesInfoKey); ok { + if srcDep, ok := android.OtherModuleProvider(ctx, dep, android.SourceFilesInfoProvider); ok { if android.IsSourceDepTagWithOutputTag(depTag, "") { // These are usually genrules which don't have per-target variants. directSrcDeps = append(directSrcDeps, srcDep) |