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
This commit is contained in:
parent
b10243dc4e
commit
df8eebecaa
|
@ -57,6 +57,7 @@ type bootImageConfig struct {
|
|||
dir android.OutputPath
|
||||
symbolsDir android.OutputPath
|
||||
images map[android.ArchType]android.OutputPath
|
||||
zip android.WritablePath
|
||||
}
|
||||
|
||||
type bootImage struct {
|
||||
|
@ -187,6 +188,8 @@ func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootI
|
|||
|
||||
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 @@ func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootI
|
|||
}
|
||||
|
||||
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 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
|
|||
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 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
|
|||
|
||||
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 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
|
|||
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 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
|
|||
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 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
|
|||
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, " "))
|
||||
|
|
|
@ -111,6 +111,7 @@ func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
|
|||
dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_bootjars")
|
||||
symbolsDir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_bootjars_unstripped")
|
||||
images := make(map[android.ArchType]android.OutputPath)
|
||||
zip := dir.Join(ctx, "boot.zip")
|
||||
|
||||
for _, target := range ctx.Config().Targets[android.Android] {
|
||||
images[target.Arch.ArchType] = dir.Join(ctx,
|
||||
|
@ -125,6 +126,7 @@ func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
|
|||
dir: dir,
|
||||
symbolsDir: symbolsDir,
|
||||
images: images,
|
||||
zip: zip,
|
||||
}
|
||||
}).(bootImageConfig)
|
||||
}
|
||||
|
|
|
@ -27,11 +27,12 @@ import (
|
|||
|
||||
var kotlinc = pctx.AndroidGomaStaticRule("kotlinc",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf "$classesDir" "$srcJarDir" "$kotlinBuildFile" && mkdir -p "$classesDir" "$srcJarDir" && ` +
|
||||
Command: `rm -rf "$classesDir" "$srcJarDir" "$kotlinBuildFile" "$emptyDir" && ` +
|
||||
`mkdir -p "$classesDir" "$srcJarDir" "$emptyDir" && ` +
|
||||
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
||||
`${config.GenKotlinBuildFileCmd} $classpath $classesDir $out.rsp $srcJarDir/list > $kotlinBuildFile &&` +
|
||||
`${config.KotlincCmd} ${config.JavacHeapFlags} $kotlincFlags ` +
|
||||
`-jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile && ` +
|
||||
`-jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile -kotlin-home $emptyDir && ` +
|
||||
`${config.SoongZipCmd} -jar -o $out -C $classesDir -D $classesDir && ` +
|
||||
`rm -rf "$srcJarDir"`,
|
||||
CommandDeps: []string{
|
||||
|
@ -49,7 +50,7 @@ var kotlinc = pctx.AndroidGomaStaticRule("kotlinc",
|
|||
Rspfile: "$out.rsp",
|
||||
RspfileContent: `$in`,
|
||||
},
|
||||
"kotlincFlags", "classpath", "srcJars", "srcJarDir", "classesDir", "kotlinJvmTarget", "kotlinBuildFile")
|
||||
"kotlincFlags", "classpath", "srcJars", "srcJarDir", "classesDir", "kotlinJvmTarget", "kotlinBuildFile", "emptyDir")
|
||||
|
||||
// kotlinCompile takes .java and .kt sources and srcJars, and compiles the .kt sources into a classes jar in outputFile.
|
||||
func kotlinCompile(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
|
@ -73,6 +74,7 @@ func kotlinCompile(ctx android.ModuleContext, outputFile android.WritablePath,
|
|||
"classesDir": android.PathForModuleOut(ctx, "kotlinc", "classes").String(),
|
||||
"srcJarDir": android.PathForModuleOut(ctx, "kotlinc", "srcJars").String(),
|
||||
"kotlinBuildFile": android.PathForModuleOut(ctx, "kotlinc-build.xml").String(),
|
||||
"emptyDir": android.PathForModuleOut(ctx, "kotlinc", "empty").String(),
|
||||
// http://b/69160377 kotlinc only supports -jvm-target 1.6 and 1.8
|
||||
"kotlinJvmTarget": "1.8",
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue