Revert "Remove option to create boot image based on preloaded classes"
This reverts commit 4a0473175e51b0441a0adf3854326e21a9d67e75.
Reason for revert: NDK build broken
Change-Id: Id98bf9d5f82ed72d8c489264cf9d754e8ea1d27e
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 3e32958..a2f1af4 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -79,11 +79,13 @@
InstructionSetFeatures map[android.ArchType]string // instruction set for each architecture
// Only used for boot image
- DirtyImageObjects android.OptionalPath // path to a dirty-image-objects file
- BootImageProfiles android.Paths // path to a boot-image-profile.txt file
- BootFlags string // extra flags to pass to dex2oat for the boot image
- Dex2oatImageXmx string // max heap size for dex2oat for the boot image
- Dex2oatImageXms string // initial heap size for dex2oat for the boot image
+ DirtyImageObjects android.OptionalPath // path to a dirty-image-objects file
+ PreloadedClasses android.OptionalPath // path to a preloaded-classes file
+ BootImageProfiles android.Paths // path to a boot-image-profile.txt file
+ UseProfileForBootImage bool // whether a profile should be used to compile the boot image
+ BootFlags string // extra flags to pass to dex2oat for the boot image
+ Dex2oatImageXmx string // max heap size for dex2oat for the boot image
+ Dex2oatImageXms string // initial heap size for dex2oat for the boot image
Tools Tools // paths to tools possibly used by the generated commands
}
@@ -181,6 +183,7 @@
// Copies of entries in GlobalConfig that are not constructable without extra parameters. They will be
// used to construct the real value manually below.
DirtyImageObjects string
+ PreloadedClasses string
BootImageProfiles []string
Tools struct {
@@ -203,6 +206,7 @@
// Construct paths that require a PathContext.
config.GlobalConfig.DirtyImageObjects = android.OptionalPathForPath(constructPath(ctx, config.DirtyImageObjects))
+ config.GlobalConfig.PreloadedClasses = android.OptionalPathForPath(constructPath(ctx, config.PreloadedClasses))
config.GlobalConfig.BootImageProfiles = constructPaths(ctx, config.BootImageProfiles)
config.GlobalConfig.Tools.Profman = constructPath(ctx, config.Tools.Profman)
@@ -317,7 +321,9 @@
CpuVariant: nil,
InstructionSetFeatures: nil,
DirtyImageObjects: android.OptionalPath{},
+ PreloadedClasses: android.OptionalPath{},
BootImageProfiles: nil,
+ UseProfileForBootImage: false,
BootFlags: "",
Dex2oatImageXmx: "",
Dex2oatImageXms: "",
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 4758c7e..eb735c1 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -286,6 +286,8 @@
if profile != nil {
cmd.FlagWithArg("--compiler-filter=", "speed-profile")
cmd.FlagWithInput("--profile-file=", profile)
+ } else if global.PreloadedClasses.Valid() {
+ cmd.FlagWithInput("--image-classes=", global.PreloadedClasses.Path())
}
if global.DirtyImageObjects.Valid() {
@@ -372,7 +374,7 @@
func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
global := dexpreoptGlobalConfig(ctx)
- if ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
+ if !global.UseProfileForBootImage || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
return nil
}
return ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go
index f91ff69..cbb52f1 100644
--- a/java/dexpreopt_bootjars_test.go
+++ b/java/dexpreopt_bootjars_test.go
@@ -62,7 +62,6 @@
bootArt := dexpreoptBootJars.Output("boot.art")
expectedInputs := []string{
- "dex_bootjars/boot.prof",
"dex_bootjars_input/foo.jar",
"dex_bootjars_input/bar.jar",
"dex_bootjars_input/baz.jar",