Convert collectDirectDepsProviders, collectTransitiveSrcFiles and
r8Flags to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: Ib3d45c317e1f2669808d0c785454fb8d8fb9cd3b
diff --git a/java/base.go b/java/base.go
index 9e448c6..8e013b9 100644
--- a/java/base.go
+++ b/java/base.go
@@ -2275,7 +2275,7 @@
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 @@
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 @@
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 @@
//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 @@
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 4a7e9dc..bc14290 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -320,7 +320,7 @@
// 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 dcbe48d..49674b9 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -381,7 +381,7 @@
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 {