Revert "Port uses-shared library verification and dexpreopting to Soong"
This reverts commit b66d7b1c20f7e54a5920780ba6643e971d216d31.
Reason for revert: broke unbundled builds
Change-Id: I96ae287885107079de4a26e6b100ad8ed66961c0
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 5a1bd74..e11e33a 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -65,6 +65,8 @@
AlwaysOtherDebugInfo bool // always generate mini debug info for non-system server modules (overrides NoDebugInfo=true)
NeverOtherDebugInfo bool // never generate mini debug info for non-system server modules (overrides NoDebugInfo=true)
+ MissingUsesLibraries []string // libraries that may be listed in OptionalUsesLibraries but will not be installed by the product
+
IsEng bool // build is a eng variant
SanitizeLite bool // build is the second phase of a SANITIZE_LITE build
@@ -116,10 +118,10 @@
ProfileClassListing android.OptionalPath
ProfileIsTextListing bool
- EnforceUsesLibraries bool
- PresentOptionalUsesLibraries []string
- UsesLibraries []string
- LibraryPaths map[string]android.Path
+ EnforceUsesLibraries bool
+ OptionalUsesLibraries []string
+ UsesLibraries []string
+ LibraryPaths map[string]android.Path
Archs []android.ArchType
DexPreoptImages []android.Path
@@ -308,6 +310,7 @@
NeverSystemServerDebugInfo: false,
AlwaysOtherDebugInfo: false,
NeverOtherDebugInfo: false,
+ MissingUsesLibraries: nil,
IsEng: false,
SanitizeLite: false,
DefaultAppImages: false,
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 0be37d0..2d521da 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -226,6 +226,11 @@
bootImageLocation = PathToLocation(bootImage, arch)
}
+ // Lists of used and optional libraries from the build config, with optional libraries that are known to not
+ // be present in the current product removed.
+ var filteredUsesLibs []string
+ var filteredOptionalUsesLibs []string
+
// The class loader context using paths in the build
var classLoaderContextHost android.Paths
@@ -243,10 +248,11 @@
var classLoaderContextHostString string
if module.EnforceUsesLibraries {
- usesLibs := append(copyOf(module.UsesLibraries), module.PresentOptionalUsesLibraries...)
+ filteredOptionalUsesLibs = filterOut(global.MissingUsesLibraries, module.OptionalUsesLibraries)
+ filteredUsesLibs = append(copyOf(module.UsesLibraries), filteredOptionalUsesLibs...)
// Create class loader context for dex2oat from uses libraries and filtered optional libraries
- for _, l := range usesLibs {
+ for _, l := range filteredUsesLibs {
classLoaderContextHost = append(classLoaderContextHost,
pathForLibrary(module, l))
@@ -261,9 +267,7 @@
// targetSdkVersion in the manifest or APK is < 28, and the module does not explicitly depend on
// org.apache.http.legacy, then implicitly add the classes to the classpath for dexpreopt. One the
// device the classes will be in a file called org.apache.http.legacy.impl.jar.
- module.LibraryPaths[httpLegacyImpl] = module.LibraryPaths[httpLegacy]
-
- if !contains(module.UsesLibraries, httpLegacy) && !contains(module.PresentOptionalUsesLibraries, httpLegacy) {
+ if !contains(module.UsesLibraries, httpLegacy) && !contains(module.OptionalUsesLibraries, httpLegacy) {
conditionalClassLoaderContextHost28 = append(conditionalClassLoaderContextHost28,
pathForLibrary(module, httpLegacyImpl))
conditionalClassLoaderContextTarget28 = append(conditionalClassLoaderContextTarget28,
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index 0402f87..6dfa9d2 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -33,7 +33,7 @@
ProfileClassListing: android.OptionalPath{},
ProfileIsTextListing: false,
EnforceUsesLibraries: false,
- PresentOptionalUsesLibraries: nil,
+ OptionalUsesLibraries: nil,
UsesLibraries: nil,
LibraryPaths: nil,
Archs: []android.ArchType{android.Arm},