Merge "Don't attempt to add stub libraries to class loader context."
This commit is contained in:
commit
fe261473b8
3 changed files with 37 additions and 23 deletions
|
@ -286,11 +286,19 @@ func (clcMap ClassLoaderContextMap) addContext(ctx android.ModuleInstallPathCont
|
||||||
}
|
}
|
||||||
subcontexts := nestedClcMap[AnySdkVersion]
|
subcontexts := nestedClcMap[AnySdkVersion]
|
||||||
|
|
||||||
// If the library with this name is already present as one of the unconditional top-level
|
// Check if the library with this name is already present in unconditional top-level CLC.
|
||||||
// components, do not re-add it.
|
|
||||||
for _, clc := range clcMap[sdkVer] {
|
for _, clc := range clcMap[sdkVer] {
|
||||||
if clc.Name == lib {
|
if clc.Name != lib {
|
||||||
|
// Ok, a different library.
|
||||||
|
} else if clc.Host == hostPath && clc.Device == devicePath {
|
||||||
|
// Ok, the same library with the same paths. Don't re-add it, but don't raise an error
|
||||||
|
// either, as the same library may be reachable via different transitional dependencies.
|
||||||
return nil
|
return nil
|
||||||
|
} else {
|
||||||
|
// Fail, as someone is trying to add the same library with different paths. This likely
|
||||||
|
// indicates an error somewhere else, like trying to add a stub library.
|
||||||
|
return fmt.Errorf("a <uses-library> named %q is already in class loader context,"+
|
||||||
|
"but the library paths are different:\t\n", lib)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1264,6 +1264,15 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext
|
||||||
|
|
||||||
dep := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(m))
|
dep := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(m))
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if lib, ok := m.(UsesLibraryDependency); ok {
|
if lib, ok := m.(UsesLibraryDependency); ok {
|
||||||
libName := dep
|
libName := dep
|
||||||
if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
|
if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
|
||||||
|
|
37
java/java.go
37
java/java.go
|
@ -1786,22 +1786,16 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out if the dependency is either an SDK library or an ordinary library that is disguised
|
depName := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(depModule))
|
||||||
// as an SDK library by the means of `provides_uses_lib` property. If yes, the library is itself
|
|
||||||
// a <uses-library> and should be added as a node in the CLC tree, and its CLC should be added
|
var sdkLib *string
|
||||||
// as subtree of that node. Otherwise the library is not a <uses_library> and should not be
|
if lib, ok := depModule.(SdkLibraryDependency); ok && lib.sharedLibrary() {
|
||||||
// added to CLC, but the transitive <uses-library> dependencies from its CLC should be added to
|
// A shared SDK library. This should be added as a top-level CLC element.
|
||||||
// the current CLC.
|
sdkLib = &depName
|
||||||
var implicitSdkLib *string
|
} else if ulib, ok := depModule.(ProvidesUsesLib); ok {
|
||||||
comp, isComp := depModule.(SdkLibraryComponentDependency)
|
// A non-SDK library disguised as an SDK library by the means of `provides_uses_lib`
|
||||||
if isComp {
|
// property. This should be handled in the same way as a shared SDK library.
|
||||||
implicitSdkLib = comp.OptionalImplicitSdkLibrary()
|
sdkLib = ulib.ProvidesUsesLib()
|
||||||
// OptionalImplicitSdkLibrary() may be nil so need to fall through to ProvidesUsesLib().
|
|
||||||
}
|
|
||||||
if implicitSdkLib == nil {
|
|
||||||
if ulib, ok := depModule.(ProvidesUsesLib); ok {
|
|
||||||
implicitSdkLib = ulib.ProvidesUsesLib()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
depTag := ctx.OtherModuleDependencyTag(depModule)
|
depTag := ctx.OtherModuleDependencyTag(depModule)
|
||||||
|
@ -1811,7 +1805,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
|
||||||
// Propagate <uses-library> through static library dependencies, unless it is a component
|
// Propagate <uses-library> through static library dependencies, unless it is a component
|
||||||
// library (such as stubs). Component libraries have a dependency on their SDK library,
|
// library (such as stubs). Component libraries have a dependency on their SDK library,
|
||||||
// which should not be pulled just because of a static component library.
|
// which should not be pulled just because of a static component library.
|
||||||
if implicitSdkLib != nil {
|
if sdkLib != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1819,11 +1813,14 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if implicitSdkLib != nil {
|
// If this is an SDK (or SDK-like) library, then it should be added as a node in the CLC tree,
|
||||||
clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *implicitSdkLib,
|
// and its CLC should be added as subtree of that node. Otherwise the library is not a
|
||||||
|
// <uses_library> and should not be added to CLC, but the transitive <uses-library> dependencies
|
||||||
|
// from its CLC should be added to the current CLC.
|
||||||
|
if sdkLib != nil {
|
||||||
|
clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib,
|
||||||
dep.DexJarBuildPath(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
|
dep.DexJarBuildPath(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
|
||||||
} else {
|
} else {
|
||||||
depName := ctx.OtherModuleName(depModule)
|
|
||||||
clcMap.AddContextMap(dep.ClassLoaderContexts(), depName)
|
clcMap.AddContextMap(dep.ClassLoaderContexts(), depName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue