Merge "Be more strict about unknown install <uses-library> paths." am: 117a5ef307
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1418529 Change-Id: Ib28e902e7f8ec57a15ef50692024cd37a96696bc
This commit is contained in:
committed by
Automerger Merge Worker
commit
0f13eff149
@@ -130,14 +130,20 @@ func (libPaths LibraryPaths) addLibraryPath(ctx android.PathContext, lib string,
|
|||||||
|
|
||||||
// Add a new library path to the map. Ensure that the build path to the library exists.
|
// Add a new library path to the map. Ensure that the build path to the library exists.
|
||||||
func (libPaths LibraryPaths) AddLibraryPath(ctx android.PathContext, lib string, hostPath, installPath android.Path) {
|
func (libPaths LibraryPaths) AddLibraryPath(ctx android.PathContext, lib string, hostPath, installPath android.Path) {
|
||||||
if hostPath != nil {
|
if hostPath != nil && installPath != nil {
|
||||||
// Add a library only if the build path to it is known.
|
// Add a library only if the build and install path to it is known.
|
||||||
libPaths.addLibraryPath(ctx, lib, hostPath, installPath)
|
libPaths.addLibraryPath(ctx, lib, hostPath, installPath)
|
||||||
} else if !ctx.Config().AllowMissingDependencies() {
|
} else if ctx.Config().AllowMissingDependencies() {
|
||||||
// Error on libraries with unknown build paths, unless missing dependencies are allowed.
|
// If missing dependencies are allowed, the build shouldn't fail when a <uses-library> is
|
||||||
|
// not found. However, this is likely to result is disabling dexpreopt, as it won't be
|
||||||
|
// possible to construct class loader context without on-host and on-device library paths.
|
||||||
|
} else {
|
||||||
|
// Error on libraries with unknown paths.
|
||||||
|
if hostPath == nil {
|
||||||
android.ReportPathErrorf(ctx, "unknown build path to <uses-library> '%s'", lib)
|
android.ReportPathErrorf(ctx, "unknown build path to <uses-library> '%s'", lib)
|
||||||
} else {
|
} else {
|
||||||
// Not adding a library to the map will likely result in disabling dexpreopt.
|
android.ReportPathErrorf(ctx, "unknown install path to <uses-library> '%s'", lib)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
java/app.go
27
java/app.go
@@ -1945,11 +1945,11 @@ func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs
|
|||||||
if hasFrameworkLibs {
|
if hasFrameworkLibs {
|
||||||
// Dexpreopt needs paths to the dex jars of these libraries in order to construct
|
// 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.
|
// class loader context for dex2oat. Add them as a dependency with a special tag.
|
||||||
ctx.AddVariationDependencies(nil, usesLibTag,
|
ctx.AddVariationDependencies(nil, usesLibCompatTag,
|
||||||
"org.apache.http.legacy",
|
"org.apache.http.legacy",
|
||||||
"android.hidl.base-V1.0-java",
|
"android.hidl.base-V1.0-java",
|
||||||
"android.hidl.manager-V1.0-java")
|
"android.hidl.manager-V1.0-java")
|
||||||
ctx.AddVariationDependencies(nil, usesLibTag, optionalUsesLibs...)
|
ctx.AddVariationDependencies(nil, usesLibCompatTag, optionalUsesLibs...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1967,31 +1967,28 @@ func (u *usesLibrary) usesLibraryPaths(ctx android.ModuleContext) dexpreopt.Libr
|
|||||||
usesLibPaths := make(dexpreopt.LibraryPaths)
|
usesLibPaths := make(dexpreopt.LibraryPaths)
|
||||||
|
|
||||||
if !ctx.Config().UnbundledBuild() {
|
if !ctx.Config().UnbundledBuild() {
|
||||||
ctx.VisitDirectDepsWithTag(usesLibTag, func(m android.Module) {
|
ctx.VisitDirectDeps(func(m android.Module) {
|
||||||
|
tag := ctx.OtherModuleDependencyTag(m)
|
||||||
|
if tag == usesLibTag || tag == usesLibCompatTag {
|
||||||
dep := ctx.OtherModuleName(m)
|
dep := ctx.OtherModuleName(m)
|
||||||
|
|
||||||
if lib, ok := m.(Dependency); ok {
|
if lib, ok := m.(Dependency); ok {
|
||||||
buildPath := lib.DexJarBuildPath()
|
buildPath := lib.DexJarBuildPath()
|
||||||
if buildPath == nil {
|
|
||||||
ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must"+
|
|
||||||
" produce a dex jar, does it have installable: true?", dep)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var devicePath string
|
|
||||||
installPath := lib.DexJarInstallPath()
|
installPath := lib.DexJarInstallPath()
|
||||||
if installPath == nil {
|
if installPath == nil && tag == usesLibCompatTag {
|
||||||
devicePath = filepath.Join("/system/framework", dep+".jar")
|
// assume that compatibility libraries are in /system/framework
|
||||||
} else {
|
installPath = android.PathForModuleInstall(ctx, "framework", dep+".jar")
|
||||||
devicePath = android.InstallPathToOnDevicePath(ctx, installPath.(android.InstallPath))
|
|
||||||
}
|
}
|
||||||
|
usesLibPaths.AddLibraryPath(ctx, dep, buildPath, installPath)
|
||||||
|
|
||||||
usesLibPaths[dep] = &dexpreopt.LibraryPath{buildPath, devicePath}
|
|
||||||
} else if ctx.Config().AllowMissingDependencies() {
|
} else if ctx.Config().AllowMissingDependencies() {
|
||||||
ctx.AddMissingDependencies([]string{dep})
|
ctx.AddMissingDependencies([]string{dep})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+
|
ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+
|
||||||
"a java library", dep)
|
"a java library", dep)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -570,6 +570,7 @@ var (
|
|||||||
certificateTag = dependencyTag{name: "certificate"}
|
certificateTag = dependencyTag{name: "certificate"}
|
||||||
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
|
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
|
||||||
usesLibTag = dependencyTag{name: "uses-library"}
|
usesLibTag = dependencyTag{name: "uses-library"}
|
||||||
|
usesLibCompatTag = dependencyTag{name: "uses-library-compat"}
|
||||||
extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
|
extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user