Merge "Support for install multiple boot images."
This commit is contained in:
commit
d79df83b28
3 changed files with 114 additions and 54 deletions
|
@ -31,6 +31,8 @@ type GlobalConfig struct {
|
|||
|
||||
OnlyPreoptBootImageAndSystemServer bool // only preopt jars in the boot image or system server
|
||||
|
||||
GenerateApexImage bool // generate an extra boot image only containing jars from the runtime apex
|
||||
|
||||
HasSystemOther bool // store odex files that match PatternsOnSystemOther on the system_other partition
|
||||
PatternsOnSystemOther []string // patterns (using '%' to denote a prefix match) to put odex on the system_other partition
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ type bootImage struct {
|
|||
|
||||
func newBootImage(ctx android.PathContext, config bootImageConfig) *bootImage {
|
||||
image := &bootImage{
|
||||
bootImageConfig: defaultBootImageConfig(ctx),
|
||||
bootImageConfig: config,
|
||||
|
||||
installs: make(map[android.ArchType]android.RuleBuilderInstalls),
|
||||
vdexInstalls: make(map[android.ArchType]android.RuleBuilderInstalls),
|
||||
|
@ -111,6 +111,7 @@ func skipDexpreoptBootJars(ctx android.PathContext) bool {
|
|||
|
||||
type dexpreoptBootJars struct {
|
||||
defaultBootImage *bootImage
|
||||
otherImages []*bootImage
|
||||
}
|
||||
|
||||
// dexpreoptBoot singleton rules
|
||||
|
@ -131,7 +132,11 @@ func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
|
|||
return
|
||||
}
|
||||
|
||||
// Always create the default boot image first, to get a unique profile rule for all images.
|
||||
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
|
||||
if global.GenerateApexImage {
|
||||
d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx)))
|
||||
}
|
||||
}
|
||||
|
||||
// buildBootImage takes a bootImageConfig, creates rules to build it, and returns a *bootImage.
|
||||
|
@ -199,7 +204,7 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
|
|||
global := dexpreoptGlobalConfig(ctx)
|
||||
|
||||
symbolsDir := image.symbolsDir.Join(ctx, "system/framework", arch.String())
|
||||
symbolsFile := symbolsDir.Join(ctx, "boot.oat")
|
||||
symbolsFile := symbolsDir.Join(ctx, image.name+".oat")
|
||||
outputDir := image.dir.Join(ctx, "system/framework", arch.String())
|
||||
outputPath := image.images[arch]
|
||||
oatLocation := pathtools.ReplaceExtension(dexpreopt.PathToLocation(outputPath, arch), "oat")
|
||||
|
@ -283,8 +288,8 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
|
|||
var unstrippedInstalls android.RuleBuilderInstalls
|
||||
|
||||
// dex preopt on the bootclasspath produces multiple files. The first dex file
|
||||
// is converted into to boot.art (to match the legacy assumption that boot.art
|
||||
// exists), and the rest are converted to boot-<name>.art.
|
||||
// is converted into to 'name'.art (to match the legacy assumption that 'name'.art
|
||||
// exists), and the rest are converted to 'name'-<jar>.art.
|
||||
// In addition, each .art file has an associated .oat and .vdex file, and an
|
||||
// unstripped .oat file
|
||||
for i, m := range image.modules {
|
||||
|
@ -330,6 +335,7 @@ It is likely that the boot classpath is inconsistent.
|
|||
Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.`
|
||||
|
||||
func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
|
||||
return ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
|
||||
global := dexpreoptGlobalConfig(ctx)
|
||||
|
||||
if !global.UseProfileForBootImage || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
|
||||
|
@ -379,23 +385,29 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin
|
|||
image.profileInstalls = rule.Installs()
|
||||
|
||||
return profile
|
||||
}).(android.WritablePath)
|
||||
}
|
||||
|
||||
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
|
||||
|
||||
// Export paths for default boot image to Make
|
||||
func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
|
||||
image := d.defaultBootImage
|
||||
if image != nil {
|
||||
for arch, _ := range image.images {
|
||||
ctx.Strict("DEXPREOPT_IMAGE_"+arch.String(), image.images[arch].String())
|
||||
|
||||
ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+arch.String(), image.installs[arch].String())
|
||||
ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+arch.String(), image.unstrippedInstalls[arch].String())
|
||||
ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+arch.String(), image.vdexInstalls[arch].String())
|
||||
}
|
||||
|
||||
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, " "))
|
||||
|
||||
var imageNames []string
|
||||
for _, current := range append(d.otherImages, image) {
|
||||
imageNames = append(imageNames, current.name)
|
||||
for arch, _ := range current.images {
|
||||
ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.vdexInstalls[arch].String())
|
||||
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())
|
||||
}
|
||||
}
|
||||
ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " "))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,6 +131,52 @@ func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
|
|||
|
||||
var defaultBootImageConfigKey = android.NewOnceKey("defaultBootImageConfig")
|
||||
|
||||
func apexBootImageConfig(ctx android.PathContext) bootImageConfig {
|
||||
return ctx.Config().Once(apexBootImageConfigKey, func() interface{} {
|
||||
global := dexpreoptGlobalConfig(ctx)
|
||||
|
||||
runtimeModules := global.RuntimeApexJars
|
||||
|
||||
var runtimeBootLocations []string
|
||||
|
||||
for _, m := range runtimeModules {
|
||||
runtimeBootLocations = append(runtimeBootLocations,
|
||||
filepath.Join("/apex/com.android.runtime/javalib", m+".jar"))
|
||||
}
|
||||
|
||||
// The path to bootclasspath dex files needs to be known at module GenerateAndroidBuildAction time, before
|
||||
// the bootclasspath modules have been compiled. Set up known paths for them, the singleton rules will copy
|
||||
// them there.
|
||||
// TODO: use module dependencies instead
|
||||
var runtimeBootDexPaths android.WritablePaths
|
||||
for _, m := range runtimeModules {
|
||||
runtimeBootDexPaths = append(runtimeBootDexPaths,
|
||||
android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_apexjars_input", m+".jar"))
|
||||
}
|
||||
|
||||
dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_apexjars")
|
||||
symbolsDir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_apexjars_unstripped")
|
||||
images := make(map[android.ArchType]android.OutputPath)
|
||||
|
||||
for _, target := range ctx.Config().Targets[android.Android] {
|
||||
images[target.Arch.ArchType] = dir.Join(ctx,
|
||||
"system/framework", target.Arch.ArchType.String(), "apex.art")
|
||||
}
|
||||
|
||||
return bootImageConfig{
|
||||
name: "apex",
|
||||
modules: runtimeModules,
|
||||
dexLocations: runtimeBootLocations,
|
||||
dexPaths: runtimeBootDexPaths,
|
||||
dir: dir,
|
||||
symbolsDir: symbolsDir,
|
||||
images: images,
|
||||
}
|
||||
}).(bootImageConfig)
|
||||
}
|
||||
|
||||
var apexBootImageConfigKey = android.NewOnceKey("apexBootImageConfig")
|
||||
|
||||
func defaultBootclasspath(ctx android.PathContext) []string {
|
||||
return ctx.Config().OnceStringSlice(defaultBootclasspathKey, func() []string {
|
||||
global := dexpreoptGlobalConfig(ctx)
|
||||
|
|
Loading…
Reference in a new issue