Merge "Don't add uses_libs
/optional_uses_libs
to the manifest_fixer." am: 81a1adb6db
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1803744 Change-Id: Id5c9f8a14ddd00eaedde4d404d4773fc2c214c1a
This commit is contained in:
committed by
Automerger Merge Worker
commit
affc7d8116
@@ -71,7 +71,9 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
|
||||
args = append(args, "--use-embedded-dex")
|
||||
}
|
||||
|
||||
requiredUsesLibs, optionalUsesLibs := classLoaderContexts.UsesLibs()
|
||||
// manifest_fixer should add only the implicit SDK libraries inferred by Soong, not those added
|
||||
// explicitly via `uses_libs`/`optional_uses_libs`.
|
||||
requiredUsesLibs, optionalUsesLibs := classLoaderContexts.ImplicitUsesLibs()
|
||||
for _, usesLib := range requiredUsesLibs {
|
||||
args = append(args, "--uses-library", usesLib)
|
||||
}
|
||||
|
27
java/app.go
27
java/app.go
@@ -1224,17 +1224,28 @@ func (u *usesLibrary) addLib(lib string, optional bool) {
|
||||
|
||||
func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs bool) {
|
||||
if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() {
|
||||
ctx.AddVariationDependencies(nil, usesLibReqTag, u.usesLibraryProperties.Uses_libs...)
|
||||
ctx.AddVariationDependencies(nil, usesLibOptTag, u.presentOptionalUsesLibs(ctx)...)
|
||||
reqTag := makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, false, false)
|
||||
ctx.AddVariationDependencies(nil, reqTag, u.usesLibraryProperties.Uses_libs...)
|
||||
|
||||
optTag := makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, true, false)
|
||||
ctx.AddVariationDependencies(nil, optTag, u.presentOptionalUsesLibs(ctx)...)
|
||||
|
||||
// Only add these extra dependencies if the module depends on framework libs. This avoids
|
||||
// creating a cyclic dependency:
|
||||
// e.g. framework-res -> org.apache.http.legacy -> ... -> framework-res.
|
||||
if hasFrameworkLibs {
|
||||
// Dexpreopt needs paths to the dex jars of these libraries in order to construct
|
||||
// class loader context for dex2oat. Add them as a dependency with a special tag.
|
||||
ctx.AddVariationDependencies(nil, usesLibCompat29ReqTag, dexpreopt.CompatUsesLibs29...)
|
||||
ctx.AddVariationDependencies(nil, usesLibCompat28OptTag, dexpreopt.OptionalCompatUsesLibs28...)
|
||||
ctx.AddVariationDependencies(nil, usesLibCompat30OptTag, dexpreopt.OptionalCompatUsesLibs30...)
|
||||
// Add implicit <uses-library> dependencies on compatibility libraries. Some of them are
|
||||
// optional, and some required --- this depends on the most common usage of the library
|
||||
// and may be wrong for some apps (they need explicit `uses_libs`/`optional_uses_libs`).
|
||||
|
||||
compat28OptTag := makeUsesLibraryDependencyTag(28, true, true)
|
||||
ctx.AddVariationDependencies(nil, compat28OptTag, dexpreopt.OptionalCompatUsesLibs28...)
|
||||
|
||||
compat29ReqTag := makeUsesLibraryDependencyTag(29, false, true)
|
||||
ctx.AddVariationDependencies(nil, compat29ReqTag, dexpreopt.CompatUsesLibs29...)
|
||||
|
||||
compat30OptTag := makeUsesLibraryDependencyTag(30, true, true)
|
||||
ctx.AddVariationDependencies(nil, compat30OptTag, dexpreopt.OptionalCompatUsesLibs30...)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,7 +1304,7 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext
|
||||
replaceInList(u.usesLibraryProperties.Uses_libs, dep, libName)
|
||||
replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName)
|
||||
}
|
||||
clcMap.AddContext(ctx, tag.sdkVersion, libName, tag.optional,
|
||||
clcMap.AddContext(ctx, tag.sdkVersion, libName, tag.optional, tag.implicit,
|
||||
lib.DexJarBuildPath(), lib.DexJarInstallPath(), lib.ClassLoaderContexts())
|
||||
} else if ctx.Config().AllowMissingDependencies() {
|
||||
ctx.AddMissingDependencies([]string{dep})
|
||||
|
@@ -2398,14 +2398,7 @@ func TestUsesLibraries(t *testing.T) {
|
||||
expectManifestFixerArgs := `--extract-native-libs=true ` +
|
||||
`--uses-library qux ` +
|
||||
`--uses-library quuz ` +
|
||||
`--uses-library foo ` + // TODO(b/132357300): "foo" should not be passed to manifest_fixer
|
||||
`--uses-library com.non.sdk.lib ` + // TODO(b/132357300): "com.non.sdk.lib" should not be passed to manifest_fixer
|
||||
`--uses-library runtime-library ` +
|
||||
`--uses-library runtime-required-x ` + // TODO(b/132357300): "runtime-required-x" should not be passed to manifest_fixer
|
||||
`--uses-library runtime-required-y ` + // TODO(b/132357300): "runtime-required-y" should not be passed to manifest_fixer
|
||||
`--optional-uses-library bar ` + // TODO(b/132357300): "bar" should not be passed to manifest_fixer
|
||||
`--optional-uses-library runtime-optional-x ` + // TODO(b/132357300): "runtime-optional-x" should not be passed to manifest_fixer
|
||||
`--optional-uses-library runtime-optional-y` // TODO(b/132357300): "runtime-optional-y" should not be passed to manifest_fixer
|
||||
`--uses-library runtime-library`
|
||||
android.AssertStringEquals(t, "manifest_fixer args", expectManifestFixerArgs, actualManifestFixerArgs)
|
||||
|
||||
// Test that all libraries are verified (library order matters).
|
||||
|
@@ -606,10 +606,8 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||
if component, ok := dep.(SdkLibraryComponentDependency); ok {
|
||||
if lib := component.OptionalSdkLibraryImplementation(); lib != nil {
|
||||
// Add library as optional if it's one of the optional compatibility libs.
|
||||
tag := usesLibReqTag
|
||||
if android.InList(*lib, dexpreopt.OptionalCompatUsesLibs) {
|
||||
tag = usesLibOptTag
|
||||
}
|
||||
optional := android.InList(*lib, dexpreopt.OptionalCompatUsesLibs)
|
||||
tag := makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, optional, true)
|
||||
ctx.AddVariationDependencies(nil, tag, *lib)
|
||||
}
|
||||
}
|
||||
|
28
java/java.go
28
java/java.go
@@ -248,15 +248,24 @@ type installDependencyTag struct {
|
||||
|
||||
type usesLibraryDependencyTag struct {
|
||||
dependencyTag
|
||||
sdkVersion int // SDK version in which the library appared as a standalone library.
|
||||
optional bool // If the dependency is optional or required.
|
||||
|
||||
// SDK version in which the library appared as a standalone library.
|
||||
sdkVersion int
|
||||
|
||||
// If the dependency is optional or required.
|
||||
optional bool
|
||||
|
||||
// Whether this is an implicit dependency inferred by Soong, or an explicit one added via
|
||||
// `uses_libs`/`optional_uses_libs` properties.
|
||||
implicit bool
|
||||
}
|
||||
|
||||
func makeUsesLibraryDependencyTag(sdkVersion int, optional bool) usesLibraryDependencyTag {
|
||||
func makeUsesLibraryDependencyTag(sdkVersion int, optional bool, implicit bool) usesLibraryDependencyTag {
|
||||
return usesLibraryDependencyTag{
|
||||
dependencyTag: dependencyTag{name: fmt.Sprintf("uses-library-%d", sdkVersion)},
|
||||
sdkVersion: sdkVersion,
|
||||
optional: optional,
|
||||
implicit: implicit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,11 +294,6 @@ var (
|
||||
syspropPublicStubDepTag = dependencyTag{name: "sysprop public stub"}
|
||||
jniInstallTag = installDependencyTag{name: "jni install"}
|
||||
binaryInstallTag = installDependencyTag{name: "binary install"}
|
||||
usesLibReqTag = makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, false)
|
||||
usesLibOptTag = makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, true)
|
||||
usesLibCompat28OptTag = makeUsesLibraryDependencyTag(28, true)
|
||||
usesLibCompat29ReqTag = makeUsesLibraryDependencyTag(29, false)
|
||||
usesLibCompat30OptTag = makeUsesLibraryDependencyTag(30, true)
|
||||
)
|
||||
|
||||
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
|
||||
@@ -1813,8 +1817,10 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
|
||||
depTag := ctx.OtherModuleDependencyTag(depModule)
|
||||
if depTag == libTag {
|
||||
// Ok, propagate <uses-library> through non-static library dependencies.
|
||||
} else if tag, ok := depTag.(usesLibraryDependencyTag); ok && tag.sdkVersion == dexpreopt.AnySdkVersion {
|
||||
// Ok, propagate <uses-library> through non-compatibility <uses-library> dependencies.
|
||||
} else if tag, ok := depTag.(usesLibraryDependencyTag); ok &&
|
||||
tag.sdkVersion == dexpreopt.AnySdkVersion && tag.implicit {
|
||||
// Ok, propagate <uses-library> through non-compatibility implicit <uses-library>
|
||||
// dependencies.
|
||||
} else if depTag == staticLibTag {
|
||||
// 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,
|
||||
@@ -1832,7 +1838,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
|
||||
// <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, false,
|
||||
clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, false, true,
|
||||
dep.DexJarBuildPath(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
|
||||
} else {
|
||||
clcMap.AddContextMap(dep.ClassLoaderContexts(), depName)
|
||||
|
Reference in New Issue
Block a user