Zip boot image
Create a zip file containing the zipped boot image files.
Test: m out/soong/sailfish/dex_bootjars/boot.zip
Change-Id: I1b08c9aca962a5999585cbe9e665693ef4558524
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index a23b477..e857fe8 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -57,6 +57,7 @@
dir android.OutputPath
symbolsDir android.OutputPath
images map[android.ArchType]android.OutputPath
+ zip android.WritablePath
}
type bootImage struct {
@@ -187,6 +188,8 @@
profile := bootImageProfileRule(ctx, image, missingDeps)
+ var allFiles android.Paths
+
if !global.DisablePreopt {
targets := ctx.Config().Targets[android.Android]
if ctx.Config().SecondArchIsTranslated() {
@@ -194,15 +197,27 @@
}
for _, target := range targets {
- buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
+ files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
+ allFiles = append(allFiles, files.Paths()...)
}
}
+ if image.zip != nil {
+ rule := android.NewRuleBuilder()
+ rule.Command().
+ Tool(ctx.Config().HostToolPath(ctx, "soong_zip")).
+ FlagWithOutput("-o ", image.zip).
+ FlagWithArg("-C ", image.dir.String()).
+ FlagWithInputList("-f ", allFiles, " -f ")
+
+ rule.Build(pctx, ctx, "zip_"+image.name, "zip "+image.name+" image")
+ }
+
return image
}
func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
- arch android.ArchType, profile android.Path, missingDeps []string) {
+ arch android.ArchType, profile android.Path, missingDeps []string) android.WritablePaths {
global := dexpreoptGlobalConfig(ctx)
@@ -290,6 +305,8 @@
var vdexInstalls android.RuleBuilderInstalls
var unstrippedInstalls android.RuleBuilderInstalls
+ var zipFiles android.WritablePaths
+
// dex preopt on the bootclasspath produces multiple files. The first dex file
// is converted into to 'name'.art (to match the legacy assumption that 'name'.art
// exists), and the rest are converted to 'name'-<jar>.art.
@@ -308,6 +325,8 @@
extraFiles = append(extraFiles, art, oat, vdex, unstrippedOat)
+ zipFiles = append(zipFiles, art, oat, vdex)
+
// Install the .oat and .art files.
rule.Install(art, filepath.Join(installDir, art.Base()))
rule.Install(oat, filepath.Join(installDir, oat.Base()))
@@ -331,6 +350,8 @@
image.installs[arch] = rule.Installs()
image.vdexInstalls[arch] = vdexInstalls
image.unstrippedInstalls[arch] = unstrippedInstalls
+
+ return zipFiles
}
const failureMessage = `ERROR: Dex2oat failed to compile a boot image.
@@ -443,6 +464,7 @@
ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPaths.Strings(), " "))
ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.dexLocations, " "))
+ ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+image.name, image.zip.String())
var imageNames []string
for _, current := range append(d.otherImages, image) {
@@ -452,6 +474,8 @@
ctx.Strict("DEXPREOPT_IMAGE_"+current.name+"_"+arch.String(), current.images[arch].String())
ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.installs[arch].String())
ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.unstrippedInstalls[arch].String())
+ if current.zip != nil {
+ }
}
}
ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " "))