summaryrefslogtreecommitdiff
path: root/java/dexpreopt_config.go
diff options
context:
space:
mode:
author Ulya Trafimovich <skvadrik@google.com> 2021-03-22 16:02:28 +0000
committer Ulya Trafimovich <skvadrik@google.com> 2021-03-24 11:16:11 +0000
commit9023b02c007d7a6b579c552aaafabbf630e93274 (patch)
treeae5beac0730dfd2d05840bb99283fe4b9484c0aa /java/dexpreopt_config.go
parent8ef5b4f95fae49a7c5d61f0fa40f9cf86b1d0a48 (diff)
Allow using updatable boot jars in dexpreopt (but don't use them yet).
This CL handles updatable boot jars in the same hacky way as we handle non-updatable boot jars: it creates a set of predefined paths to the dex jars in a global config, then traverses all modules in a singleton context, finds updatable boot jars and adds copy rules from these jars to the predefined paths. A proper way would be to register dependencies of the dexpreopted modules on the boot jars and extracting paths to dex files by walking these dependencies. Bug: 178467404 Test: lunch aosp_cf_x86_64_phone-userdebug && m Test: added new Soong test Change-Id: I87f764109315f79315d73bf43799b70eb010fc0b
Diffstat (limited to 'java/dexpreopt_config.go')
-rw-r--r--java/dexpreopt_config.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 282e9364e..64b265640 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -176,6 +176,57 @@ func defaultBootclasspath(ctx android.PathContext) []string {
})
}
+// Updatable boot config allows to access build/install paths of updatable boot jars without going
+// through the usual trouble of registering dependencies on those modules and extracting build paths
+// from those dependencies.
+type updatableBootConfig struct {
+ // A list of updatable boot jars.
+ modules android.ConfiguredJarList
+
+ // A list of predefined build paths to updatable boot jars. They are configured very early,
+ // before the modules for these jars are processed and the actual paths are generated, and
+ // later on a singleton adds commands to copy actual jars to the predefined paths.
+ dexPaths android.WritablePaths
+
+ // A list of dex locations (a.k.a. on-device paths) to the boot jars.
+ dexLocations []string
+}
+
+var updatableBootConfigKey = android.NewOnceKey("updatableBootConfig")
+
+// Returns updatable boot config.
+func GetUpdatableBootConfig(ctx android.PathContext) updatableBootConfig {
+ return ctx.Config().Once(updatableBootConfigKey, func() interface{} {
+ updatableBootJars := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars
+
+ dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "updatable_bootjars")
+ dexPaths := updatableBootJars.BuildPaths(ctx, dir)
+
+ dexLocations := updatableBootJars.DevicePaths(ctx.Config(), android.Android)
+
+ return updatableBootConfig{updatableBootJars, dexPaths, dexLocations}
+ }).(updatableBootConfig)
+}
+
+// Returns a list of paths and a list of locations for the boot jars used in dexpreopt (to be
+// passed in -Xbootclasspath and -Xbootclasspath-locations arguments for dex2oat).
+func bcpForDexpreopt(ctx android.PathContext, withUpdatable bool) (android.WritablePaths, []string) {
+ // Non-updatable boot jars (they are used both in the boot image and in dexpreopt).
+ bootImage := defaultBootImageConfig(ctx)
+ dexPaths := bootImage.dexPathsDeps
+ // The dex locations for all Android variants are identical.
+ dexLocations := bootImage.getAnyAndroidVariant().dexLocationsDeps
+
+ if withUpdatable {
+ // Updatable boot jars (they are used only in dexpreopt, but not in the boot image).
+ updBootConfig := GetUpdatableBootConfig(ctx)
+ dexPaths = append(dexPaths, updBootConfig.dexPaths...)
+ dexLocations = append(dexLocations, updBootConfig.dexLocations...)
+ }
+
+ return dexPaths, dexLocations
+}
+
var defaultBootclasspathKey = android.NewOnceKey("defaultBootclasspath")
var copyOf = android.CopyOf