diff options
author | 2025-01-10 22:26:01 +0000 | |
---|---|---|
committer | 2025-01-10 22:27:14 +0000 | |
commit | c0a3630e4d807be5f2e0d0d1e61cad8d67de610c (patch) | |
tree | 4bab08284604019662b3378c52710a95b128990f /java/base.go | |
parent | 460cf3783713a82c0f8c41d97c76f3e92451f3e6 (diff) |
Convert checkSdkVersions to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I5d7150feb8dbb84ac4e01059e76f451fbfc5f7eb
Diffstat (limited to 'java/base.go')
-rw-r--r-- | java/base.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/java/base.go b/java/base.go index ac8619e23..49a60f0d1 100644 --- a/java/base.go +++ b/java/base.go @@ -652,14 +652,17 @@ func (j *Module) checkSdkVersions(ctx android.ModuleContext) { // Make sure this module doesn't statically link to modules with lower-ranked SDK link type. // See rank() for details. - ctx.VisitDirectDeps(func(module android.Module) { + ctx.VisitDirectDepsProxy(func(module android.ModuleProxy) { tag := ctx.OtherModuleDependencyTag(module) - switch module.(type) { - // TODO(satayev): cover other types as well, e.g. imports - case *Library, *AndroidLibrary: + _, isJavaLibrary := android.OtherModuleProvider(ctx, module, JavaLibraryInfoProvider) + _, isAndroidLibrary := android.OtherModuleProvider(ctx, module, AndroidLibraryInfoProvider) + _, isJavaAconfigLibrary := android.OtherModuleProvider(ctx, module, android.CodegenInfoProvider) + // Exclude java_aconfig_library modules to maintain consistency with existing behavior. + if (isJavaLibrary && !isJavaAconfigLibrary) || isAndroidLibrary { + // TODO(satayev): cover other types as well, e.g. imports switch tag { case bootClasspathTag, sdkLibTag, libTag, staticLibTag, java9LibTag: - j.checkSdkLinkType(ctx, module.(moduleWithSdkDep), tag.(dependencyTag)) + j.checkSdkLinkType(ctx, module) } } }) @@ -2375,7 +2378,7 @@ func (m *Module) getSdkLinkType(ctx android.BaseModuleContext, name string) (ret // checkSdkLinkType make sures the given dependency doesn't have a lower SDK link type rank than // this module's. See the comment on rank() for details and an example. func (j *Module) checkSdkLinkType( - ctx android.ModuleContext, dep moduleWithSdkDep, tag dependencyTag) { + ctx android.ModuleContext, dep android.ModuleProxy) { if ctx.Host() { return } @@ -2384,7 +2387,12 @@ func (j *Module) checkSdkLinkType( if stubs { return } - depLinkType, _ := dep.getSdkLinkType(ctx, ctx.OtherModuleName(dep)) + info, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider) + if !ok || info.ModuleWithSdkDepInfo == nil { + panic(fmt.Errorf("dependency doesn't have ModuleWithSdkDepInfo: %v", dep)) + } + + depLinkType := info.ModuleWithSdkDepInfo.SdkLinkType if myLinkType.rank() < depLinkType.rank() { ctx.ModuleErrorf("compiles against %v, but dependency %q is compiling against %v. "+ |