From b9a46fb62480f6412b95086c51b0a059ceef1628 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 14 Mar 2022 15:31:47 +0000 Subject: [PATCH] Pass --preloaded-classes to boot image compilation. Test: m Bug: 162110941 Change-Id: I0df016c5d170ca101cd18cacc331499ae76677a6 --- java/dexpreopt_bootjars.go | 10 ++++++++++ java/dexpreopt_config.go | 14 ++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index cad9c332a..d2be2a9fc 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -281,6 +281,9 @@ type bootImageConfig struct { // Target-dependent fields. variants []*bootImageVariant + + // Path of the preloaded classes file. + preloadedClassesFile string } // Target-dependent description of a boot image. @@ -680,6 +683,13 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p cmd.FlagWithArg("--base=", ctx.Config().LibartImgDeviceBaseAddress()) } + // We always expect a preloaded classes file to be available. However, if we cannot find it, it's + // OK to not pass the flag to dex2oat. + preloadedClassesPath := android.ExistentPathForSource(ctx, image.preloadedClassesFile) + if preloadedClassesPath.Valid() { + cmd.FlagWithInput("--preloaded-classes=", preloadedClassesPath.Path()) + } + cmd. FlagForEachInput("--dex-file=", image.dexPaths.Paths()). FlagForEachArg("--dex-location=", image.dexLocations). diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go index 21e1d12c0..4d0bd09c6 100644 --- a/java/dexpreopt_config.go +++ b/java/dexpreopt_config.go @@ -62,18 +62,20 @@ func genBootImageConfigRaw(ctx android.PathContext) map[string]*bootImageConfig installDirOnDevice: "system/framework", profileInstallPathInApex: "etc/boot-image.prof", modules: artModules, + preloadedClassesFile: "art/build/boot/preloaded-classes", } // Framework config for the boot image extension. // It includes framework libraries and depends on the ART config. frameworkSubdir := "system/framework" frameworkCfg := bootImageConfig{ - extends: &artCfg, - name: frameworkBootImageName, - stem: "boot", - installDirOnHost: frameworkSubdir, - installDirOnDevice: frameworkSubdir, - modules: frameworkModules, + extends: &artCfg, + name: frameworkBootImageName, + stem: "boot", + installDirOnHost: frameworkSubdir, + installDirOnDevice: frameworkSubdir, + modules: frameworkModules, + preloadedClassesFile: "frameworks/base/config/preloaded-classes", } return map[string]*bootImageConfig{