Merge "Disable dexpreopt if optional_uses_libs does not have an impl" into main

This commit is contained in:
Spandan Das
2024-02-20 08:08:35 +00:00
committed by Gerrit Code Review
6 changed files with 60 additions and 0 deletions

View File

@@ -778,6 +778,9 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.onDeviceDir = android.InstallPathToOnDevicePath(ctx, a.installDir)
a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
if a.usesLibrary.shouldDisableDexpreopt {
a.dexpreopter.disableDexpreopt()
}
var noticeAssetPath android.WritablePath
if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
@@ -1566,6 +1569,9 @@ type usesLibrary struct {
// Whether to enforce verify_uses_library check.
enforce bool
// Whether dexpreopt should be disabled
shouldDisableDexpreopt bool
}
func (u *usesLibrary) addLib(lib string, optional bool) {
@@ -1647,6 +1653,15 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext
}
}
// Skip java_sdk_library dependencies that provide stubs, but not an implementation.
// This will be restricted to optional_uses_libs
if sdklib, ok := m.(SdkLibraryDependency); ok {
if tag == usesLibOptTag && sdklib.DexJarBuildPath(ctx).PathOrNil() == nil {
u.shouldDisableDexpreopt = true
return
}
}
if lib, ok := m.(UsesLibraryDependency); ok {
libName := dep
if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {