diff options
| author | 2025-01-11 00:04:41 +0000 | |
|---|---|---|
| committer | 2025-01-11 00:04:41 +0000 | |
| commit | 27b74aa99ad90bc3e913edcdede208dac4db0f7c (patch) | |
| tree | 9a284524acaefb1800109d8c6260c34a2cc9a02e | |
| parent | c0a3630e4d807be5f2e0d0d1e61cad8d67de610c (diff) | |
Convert classLoaderContextForUsesLibDeps to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I4fb8fc3690314ccd6edc704f89731dd61cfa6c59
| -rw-r--r-- | java/app.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/java/app.go b/java/app.go index 31aefcfa0..cc05cdeb2 100644 --- a/java/app.go +++ b/java/app.go @@ -1944,7 +1944,7 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext return clcMap } - ctx.VisitDirectDeps(func(m android.Module) { + ctx.VisitDirectDepsProxy(func(m android.ModuleProxy) { tag, isUsesLibTag := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag) if !isUsesLibTag { return @@ -1952,31 +1952,35 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext dep := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(m)) + javaInfo, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider) + if !ok { + return + } // Skip stub libraries. A dependency on the implementation library has been added earlier, // so it will be added to CLC, but the stub shouldn't be. Stub libraries can be distingushed // from implementation libraries by their name, which is different as it has a suffix. - if comp, ok := m.(SdkLibraryComponentDependency); ok { - if impl := comp.OptionalSdkLibraryImplementation(); impl != nil && *impl != dep { + if comp := javaInfo.SdkLibraryComponentDependencyInfo; comp != nil { + if impl := comp.OptionalSdkLibraryImplementation; impl != nil && *impl != dep { return } } - if lib, ok := m.(UsesLibraryDependency); ok { + if lib := javaInfo.UsesLibraryDependencyInfo; lib != nil { if _, ok := android.OtherModuleProvider(ctx, m, SdkLibraryInfoProvider); ok { // Skip java_sdk_library dependencies that provide stubs, but not an implementation. // This will be restricted to optional_uses_libs - if tag == usesLibOptTag && lib.DexJarBuildPath(ctx).PathOrNil() == nil { + if tag == usesLibOptTag && lib.DexJarBuildPath.PathOrNil() == nil { u.shouldDisableDexpreopt = true return } } libName := dep - if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil { - libName = *ulib.ProvidesUsesLib() + if ulib := javaInfo.ProvidesUsesLibInfo; ulib != nil && ulib.ProvidesUsesLib != nil { + libName = *ulib.ProvidesUsesLib } clcMap.AddContext(ctx, tag.sdkVersion, libName, tag.optional, - lib.DexJarBuildPath(ctx).PathOrNil(), lib.DexJarInstallPath(), - lib.ClassLoaderContexts()) + lib.DexJarBuildPath.PathOrNil(), lib.DexJarInstallPath, + lib.ClassLoaderContexts) } else if ctx.Config().AllowMissingDependencies() { ctx.AddMissingDependencies([]string{dep}) } else { |