aboutsummaryrefslogtreecommitdiffstats
path: root/dexpreopt
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2019-05-16 12:28:22 -0700
committerColin Cross <ccross@android.com>2019-05-28 11:20:09 -0700
commitb66d7b1c20f7e54a5920780ba6643e971d216d31 (patch)
treefc7d90eefe45b4f2120132575a09dbe7e4eaa43d /dexpreopt
parent38b968555c04092302561369d0ed687ad1ccd15e (diff)
downloadbuild_soong-b66d7b1c20f7e54a5920780ba6643e971d216d31.tar.gz
build_soong-b66d7b1c20f7e54a5920780ba6643e971d216d31.tar.bz2
build_soong-b66d7b1c20f7e54a5920780ba6643e971d216d31.zip
Port uses-shared library verification and dexpreopting to Soong
Ports 09f3b97f4b488cd3a7b7d72038b173575b02c162 (Add support for preopt with uses-libraries) from Make to Soong to support verifying and preopting shared libraries. Bug: 132357300 Test: app_test.go Test: m checkbuild Change-Id: Id25f55f07a55120bebe2a9b32c094209efc85c8b
Diffstat (limited to 'dexpreopt')
-rw-r--r--dexpreopt/config.go11
-rw-r--r--dexpreopt/dexpreopt.go14
-rw-r--r--dexpreopt/dexpreopt_test.go2
3 files changed, 10 insertions, 17 deletions
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index e11e33a1..5a1bd74a 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -65,8 +65,6 @@ type GlobalConfig struct {
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
@@ -118,10 +116,10 @@ type ModuleConfig struct {
ProfileClassListing android.OptionalPath
ProfileIsTextListing bool
- EnforceUsesLibraries bool
- OptionalUsesLibraries []string
- UsesLibraries []string
- LibraryPaths map[string]android.Path
+ EnforceUsesLibraries bool
+ PresentOptionalUsesLibraries []string
+ UsesLibraries []string
+ LibraryPaths map[string]android.Path
Archs []android.ArchType
DexPreoptImages []android.Path
@@ -310,7 +308,6 @@ func GlobalConfigForTests(ctx android.PathContext) GlobalConfig {
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 2d521dab..0be37d0f 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -226,11 +226,6 @@ func dexpreoptCommand(ctx android.PathContext, global GlobalConfig, module Modul
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
@@ -248,11 +243,10 @@ func dexpreoptCommand(ctx android.PathContext, global GlobalConfig, module Modul
var classLoaderContextHostString string
if module.EnforceUsesLibraries {
- filteredOptionalUsesLibs = filterOut(global.MissingUsesLibraries, module.OptionalUsesLibraries)
- filteredUsesLibs = append(copyOf(module.UsesLibraries), filteredOptionalUsesLibs...)
+ usesLibs := append(copyOf(module.UsesLibraries), module.PresentOptionalUsesLibraries...)
// Create class loader context for dex2oat from uses libraries and filtered optional libraries
- for _, l := range filteredUsesLibs {
+ for _, l := range usesLibs {
classLoaderContextHost = append(classLoaderContextHost,
pathForLibrary(module, l))
@@ -267,7 +261,9 @@ func dexpreoptCommand(ctx android.PathContext, global GlobalConfig, module Modul
// 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.
- if !contains(module.UsesLibraries, httpLegacy) && !contains(module.OptionalUsesLibraries, httpLegacy) {
+ module.LibraryPaths[httpLegacyImpl] = module.LibraryPaths[httpLegacy]
+
+ if !contains(module.UsesLibraries, httpLegacy) && !contains(module.PresentOptionalUsesLibraries, httpLegacy) {
conditionalClassLoaderContextHost28 = append(conditionalClassLoaderContextHost28,
pathForLibrary(module, httpLegacyImpl))
conditionalClassLoaderContextTarget28 = append(conditionalClassLoaderContextTarget28,
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index 6dfa9d26..0402f875 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -33,7 +33,7 @@ func testModuleConfig(ctx android.PathContext) ModuleConfig {
ProfileClassListing: android.OptionalPath{},
ProfileIsTextListing: false,
EnforceUsesLibraries: false,
- OptionalUsesLibraries: nil,
+ PresentOptionalUsesLibraries: nil,
UsesLibraries: nil,
LibraryPaths: nil,
Archs: []android.ArchType{android.Arm},