Merge "Deduplicate config generation for boot images."
This commit is contained in:
@@ -96,80 +96,9 @@ func dexpreoptTargets(ctx android.PathContext) []android.Target {
|
|||||||
return targets
|
return targets
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultBootImageConfig returns the bootImageConfig that will be used to dexpreopt modules. It is computed once the
|
func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name string,
|
||||||
// first time it is called for any ctx.Config(), and returns the same slice for all future calls with the same
|
needZip bool) bootImageConfig {
|
||||||
// ctx.Config().
|
return ctx.Config().Once(key, func() interface{} {
|
||||||
func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
|
|
||||||
return ctx.Config().Once(defaultBootImageConfigKey, func() interface{} {
|
|
||||||
global := dexpreoptGlobalConfig(ctx)
|
|
||||||
|
|
||||||
artModules := global.ArtApexJars
|
|
||||||
nonFrameworkModules := concat(artModules, global.ProductUpdatableBootModules)
|
|
||||||
frameworkModules := android.RemoveListFromList(global.BootJars, nonFrameworkModules)
|
|
||||||
|
|
||||||
var nonUpdatableBootModules []string
|
|
||||||
var nonUpdatableBootLocations []string
|
|
||||||
|
|
||||||
for _, m := range artModules {
|
|
||||||
nonUpdatableBootModules = append(nonUpdatableBootModules, m)
|
|
||||||
nonUpdatableBootLocations = append(nonUpdatableBootLocations,
|
|
||||||
filepath.Join("/apex/com.android.art/javalib", m+".jar"))
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, m := range frameworkModules {
|
|
||||||
nonUpdatableBootModules = append(nonUpdatableBootModules, m)
|
|
||||||
nonUpdatableBootLocations = append(nonUpdatableBootLocations,
|
|
||||||
filepath.Join("/system/framework", 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 nonUpdatableBootDexPaths android.WritablePaths
|
|
||||||
for _, m := range nonUpdatableBootModules {
|
|
||||||
nonUpdatableBootDexPaths = append(nonUpdatableBootDexPaths,
|
|
||||||
android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_bootjars_input", m+".jar"))
|
|
||||||
}
|
|
||||||
|
|
||||||
dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_bootjars")
|
|
||||||
symbolsDir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_bootjars_unstripped")
|
|
||||||
zip := dir.Join(ctx, "boot.zip")
|
|
||||||
|
|
||||||
targets := dexpreoptTargets(ctx)
|
|
||||||
|
|
||||||
imageConfig := bootImageConfig{
|
|
||||||
name: "boot",
|
|
||||||
modules: nonUpdatableBootModules,
|
|
||||||
dexLocations: nonUpdatableBootLocations,
|
|
||||||
dexPaths: nonUpdatableBootDexPaths,
|
|
||||||
dir: dir,
|
|
||||||
symbolsDir: symbolsDir,
|
|
||||||
images: make(map[android.ArchType]android.OutputPath),
|
|
||||||
imagesDeps: make(map[android.ArchType]android.Paths),
|
|
||||||
targets: targets,
|
|
||||||
zip: zip,
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, target := range targets {
|
|
||||||
imageDir := dir.Join(ctx, "system/framework", target.Arch.ArchType.String())
|
|
||||||
imageConfig.images[target.Arch.ArchType] = imageDir.Join(ctx, "boot.art")
|
|
||||||
|
|
||||||
imagesDeps := make([]android.Path, 0, len(imageConfig.modules)*3)
|
|
||||||
for _, dep := range imageConfig.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex") {
|
|
||||||
imagesDeps = append(imagesDeps, dep)
|
|
||||||
}
|
|
||||||
imageConfig.imagesDeps[target.Arch.ArchType] = imagesDeps
|
|
||||||
}
|
|
||||||
|
|
||||||
return imageConfig
|
|
||||||
}).(bootImageConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
var defaultBootImageConfigKey = android.NewOnceKey("defaultBootImageConfig")
|
|
||||||
|
|
||||||
func apexBootImageConfig(ctx android.PathContext) bootImageConfig {
|
|
||||||
return ctx.Config().Once(apexBootImageConfigKey, func() interface{} {
|
|
||||||
global := dexpreoptGlobalConfig(ctx)
|
global := dexpreoptGlobalConfig(ctx)
|
||||||
|
|
||||||
artModules := global.ArtApexJars
|
artModules := global.ArtApexJars
|
||||||
@@ -196,16 +125,21 @@ func apexBootImageConfig(ctx android.PathContext) bootImageConfig {
|
|||||||
var bootDexPaths android.WritablePaths
|
var bootDexPaths android.WritablePaths
|
||||||
for _, m := range imageModules {
|
for _, m := range imageModules {
|
||||||
bootDexPaths = append(bootDexPaths,
|
bootDexPaths = append(bootDexPaths,
|
||||||
android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_apexjars_input", m+".jar"))
|
android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_"+name+"jars_input", m+".jar"))
|
||||||
}
|
}
|
||||||
|
|
||||||
dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_apexjars")
|
dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_"+name+"jars")
|
||||||
symbolsDir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_apexjars_unstripped")
|
symbolsDir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_"+name+"jars_unstripped")
|
||||||
|
|
||||||
|
var zip android.WritablePath
|
||||||
|
if needZip {
|
||||||
|
zip = dir.Join(ctx, name+".zip")
|
||||||
|
}
|
||||||
|
|
||||||
targets := dexpreoptTargets(ctx)
|
targets := dexpreoptTargets(ctx)
|
||||||
|
|
||||||
imageConfig := bootImageConfig{
|
imageConfig := bootImageConfig{
|
||||||
name: "apex",
|
name: name,
|
||||||
modules: imageModules,
|
modules: imageModules,
|
||||||
dexLocations: bootLocations,
|
dexLocations: bootLocations,
|
||||||
dexPaths: bootDexPaths,
|
dexPaths: bootDexPaths,
|
||||||
@@ -214,11 +148,12 @@ func apexBootImageConfig(ctx android.PathContext) bootImageConfig {
|
|||||||
targets: targets,
|
targets: targets,
|
||||||
images: make(map[android.ArchType]android.OutputPath),
|
images: make(map[android.ArchType]android.OutputPath),
|
||||||
imagesDeps: make(map[android.ArchType]android.Paths),
|
imagesDeps: make(map[android.ArchType]android.Paths),
|
||||||
|
zip: zip,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
imageDir := dir.Join(ctx, "system/framework", target.Arch.ArchType.String())
|
imageDir := dir.Join(ctx, "system/framework", target.Arch.ArchType.String())
|
||||||
imageConfig.images[target.Arch.ArchType] = imageDir.Join(ctx, "apex.art")
|
imageConfig.images[target.Arch.ArchType] = imageDir.Join(ctx, name+".art")
|
||||||
|
|
||||||
imagesDeps := make([]android.Path, 0, len(imageConfig.modules)*3)
|
imagesDeps := make([]android.Path, 0, len(imageConfig.modules)*3)
|
||||||
for _, dep := range imageConfig.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex") {
|
for _, dep := range imageConfig.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex") {
|
||||||
@@ -231,8 +166,17 @@ func apexBootImageConfig(ctx android.PathContext) bootImageConfig {
|
|||||||
}).(bootImageConfig)
|
}).(bootImageConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var defaultBootImageConfigKey = android.NewOnceKey("defaultBootImageConfig")
|
||||||
var apexBootImageConfigKey = android.NewOnceKey("apexBootImageConfig")
|
var apexBootImageConfigKey = android.NewOnceKey("apexBootImageConfig")
|
||||||
|
|
||||||
|
func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
|
||||||
|
return getBootImageConfig(ctx, defaultBootImageConfigKey, "boot", true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func apexBootImageConfig(ctx android.PathContext) bootImageConfig {
|
||||||
|
return getBootImageConfig(ctx, apexBootImageConfigKey, "apex", false)
|
||||||
|
}
|
||||||
|
|
||||||
func defaultBootclasspath(ctx android.PathContext) []string {
|
func defaultBootclasspath(ctx android.PathContext) []string {
|
||||||
return ctx.Config().OnceStringSlice(defaultBootclasspathKey, func() []string {
|
return ctx.Config().OnceStringSlice(defaultBootclasspathKey, func() []string {
|
||||||
global := dexpreoptGlobalConfig(ctx)
|
global := dexpreoptGlobalConfig(ctx)
|
||||||
|
Reference in New Issue
Block a user