summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dexpreopt/config.go18
-rwxr-xr-xjava/app.go43
-rw-r--r--java/java.go1
3 files changed, 33 insertions, 29 deletions
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index f22ee4735..3ef8b8dd8 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -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.
func (libPaths LibraryPaths) AddLibraryPath(ctx android.PathContext, lib string, hostPath, installPath android.Path) {
- if hostPath != nil {
- // Add a library only if the build path to it is known.
+ if hostPath != nil && installPath != nil {
+ // Add a library only if the build and install path to it is known.
libPaths.addLibraryPath(ctx, lib, hostPath, installPath)
- } else if !ctx.Config().AllowMissingDependencies() {
- // Error on libraries with unknown build paths, unless missing dependencies are allowed.
- android.ReportPathErrorf(ctx, "unknown build path to <uses-library> '%s'", lib)
+ } else if ctx.Config().AllowMissingDependencies() {
+ // 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 {
- // Not adding a library to the map will likely result in disabling dexpreopt.
+ // Error on libraries with unknown paths.
+ if hostPath == nil {
+ android.ReportPathErrorf(ctx, "unknown build path to <uses-library> '%s'", lib)
+ } else {
+ android.ReportPathErrorf(ctx, "unknown install path to <uses-library> '%s'", lib)
+ }
}
}
diff --git a/java/app.go b/java/app.go
index 3dfdfdc07..406894dca 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1915,11 +1915,11 @@ func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs
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, usesLibTag,
+ ctx.AddVariationDependencies(nil, usesLibCompatTag,
"org.apache.http.legacy",
"android.hidl.base-V1.0-java",
"android.hidl.manager-V1.0-java")
- ctx.AddVariationDependencies(nil, usesLibTag, optionalUsesLibs...)
+ ctx.AddVariationDependencies(nil, usesLibCompatTag, optionalUsesLibs...)
}
}
}
@@ -1937,30 +1937,27 @@ func (u *usesLibrary) usesLibraryPaths(ctx android.ModuleContext) dexpreopt.Libr
usesLibPaths := make(dexpreopt.LibraryPaths)
if !ctx.Config().UnbundledBuild() {
- ctx.VisitDirectDepsWithTag(usesLibTag, func(m android.Module) {
- dep := ctx.OtherModuleName(m)
- if lib, ok := m.(Dependency); ok {
- 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
- }
+ ctx.VisitDirectDeps(func(m android.Module) {
+ tag := ctx.OtherModuleDependencyTag(m)
+ if tag == usesLibTag || tag == usesLibCompatTag {
+ dep := ctx.OtherModuleName(m)
+
+ if lib, ok := m.(Dependency); ok {
+ buildPath := lib.DexJarBuildPath()
+ installPath := lib.DexJarInstallPath()
+ if installPath == nil && tag == usesLibCompatTag {
+ // assume that compatibility libraries are in /system/framework
+ installPath = android.PathForModuleInstall(ctx, "framework", dep+".jar")
+ }
+ usesLibPaths.AddLibraryPath(ctx, dep, buildPath, installPath)
+
+ } else if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{dep})
- var devicePath string
- installPath := lib.DexJarInstallPath()
- if installPath == nil {
- devicePath = filepath.Join("/system/framework", dep+".jar")
} else {
- devicePath = android.InstallPathToOnDevicePath(ctx, installPath.(android.InstallPath))
+ ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+
+ "a java library", dep)
}
-
- usesLibPaths[dep] = &dexpreopt.LibraryPath{buildPath, devicePath}
- } else if ctx.Config().AllowMissingDependencies() {
- ctx.AddMissingDependencies([]string{dep})
- } else {
- ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+
- "a java library", dep)
}
})
}
diff --git a/java/java.go b/java/java.go
index 06904182c..c568ec43d 100644
--- a/java/java.go
+++ b/java/java.go
@@ -566,6 +566,7 @@ var (
certificateTag = dependencyTag{name: "certificate"}
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
usesLibTag = dependencyTag{name: "uses-library"}
+ usesLibCompatTag = dependencyTag{name: "uses-library-compat"}
extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
)