Extract default image specific logic from buildBootImage
Previously, buildBootImage had to be called for the default boot image config before the art boot image config as it created some rules which were specific to default boot image. The creation of these rules was encapsulated in Config().Once(..) to ensure that they were only ever created once. This change extracts that functionality out of buildBootImage to the calling method which means that they are only called once and so no longer need protecting against being called again. Bug: 177892522 Test: m droid Change-Id: I464477de1a08df15e577873a9accf7db2bc088d1
This commit is contained in:
@@ -434,10 +434,21 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always create the default boot image first, to get a unique profile rule for all images.
|
// Generate the profile rule from the default boot image.
|
||||||
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
|
defaultImageConfig := defaultBootImageConfig(ctx)
|
||||||
|
profile := bootImageProfileRule(ctx, defaultImageConfig)
|
||||||
|
|
||||||
|
// Generate the framework profile rule
|
||||||
|
bootFrameworkProfileRule(ctx, defaultImageConfig)
|
||||||
|
|
||||||
|
// Generate the updatable bootclasspath packages rule.
|
||||||
|
updatableBcpPackagesRule(ctx, defaultImageConfig)
|
||||||
|
|
||||||
|
// Create the default boot image.
|
||||||
|
d.defaultBootImage = buildBootImage(ctx, defaultImageConfig, profile)
|
||||||
|
|
||||||
// Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
|
// Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
|
||||||
d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx)))
|
d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx), profile))
|
||||||
|
|
||||||
copyUpdatableBootJars(ctx)
|
copyUpdatableBootJars(ctx)
|
||||||
|
|
||||||
@@ -605,16 +616,12 @@ func findAndCopyBootJars(ctx android.SingletonContext, bootjars android.Configur
|
|||||||
}
|
}
|
||||||
|
|
||||||
// buildBootImage takes a bootImageConfig, creates rules to build it, and returns the image.
|
// buildBootImage takes a bootImageConfig, creates rules to build it, and returns the image.
|
||||||
func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootImageConfig {
|
func buildBootImage(ctx android.SingletonContext, image *bootImageConfig, profile android.WritablePath) *bootImageConfig {
|
||||||
getBootJarFunc := func(module android.Module) (int, android.Path) {
|
getBootJarFunc := func(module android.Module) (int, android.Path) {
|
||||||
return getBootImageJar(ctx, image, module)
|
return getBootImageJar(ctx, image, module)
|
||||||
}
|
}
|
||||||
findAndCopyBootJars(ctx, image.modules, image.dexPaths, getBootJarFunc)
|
findAndCopyBootJars(ctx, image.modules, image.dexPaths, getBootJarFunc)
|
||||||
|
|
||||||
profile := bootImageProfileRule(ctx, image)
|
|
||||||
bootFrameworkProfileRule(ctx, image)
|
|
||||||
updatableBcpPackagesRule(ctx, image)
|
|
||||||
|
|
||||||
var zipFiles android.Paths
|
var zipFiles android.Paths
|
||||||
for _, variant := range image.variants {
|
for _, variant := range image.variants {
|
||||||
files := buildBootImageVariant(ctx, variant, profile)
|
files := buildBootImageVariant(ctx, variant, profile)
|
||||||
@@ -805,7 +812,7 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig)
|
|||||||
if global.DisableGenerateProfile {
|
if global.DisableGenerateProfile {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
|
|
||||||
defaultProfile := "frameworks/base/config/boot-image-profile.txt"
|
defaultProfile := "frameworks/base/config/boot-image-profile.txt"
|
||||||
|
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
rule := android.NewRuleBuilder(pctx, ctx)
|
||||||
@@ -844,15 +851,8 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig)
|
|||||||
image.profileInstalls = rule.Installs()
|
image.profileInstalls = rule.Installs()
|
||||||
|
|
||||||
return profile
|
return profile
|
||||||
})
|
|
||||||
if profile == nil {
|
|
||||||
return nil // wrap nil into a typed pointer with value nil
|
|
||||||
}
|
|
||||||
return profile.(android.WritablePath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
|
|
||||||
|
|
||||||
func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConfig) android.WritablePath {
|
func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConfig) android.WritablePath {
|
||||||
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
@@ -860,7 +860,6 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
|
|||||||
if global.DisableGenerateProfile || ctx.Config().UnbundledBuild() {
|
if global.DisableGenerateProfile || ctx.Config().UnbundledBuild() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} {
|
|
||||||
|
|
||||||
// Some branches like master-art-host don't have frameworks/base, so manually
|
// Some branches like master-art-host don't have frameworks/base, so manually
|
||||||
// handle the case that the default is missing. Those branches won't attempt to build the profile rule,
|
// handle the case that the default is missing. Those branches won't attempt to build the profile rule,
|
||||||
@@ -894,17 +893,13 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
|
|||||||
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
||||||
|
|
||||||
return profile
|
return profile
|
||||||
}).(android.WritablePath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule")
|
|
||||||
|
|
||||||
func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig) android.WritablePath {
|
func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig) android.WritablePath {
|
||||||
if ctx.Config().UnbundledBuild() {
|
if ctx.Config().UnbundledBuild() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.Config().Once(updatableBcpPackagesRuleKey, func() interface{} {
|
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
updatableModules := global.UpdatableBootJars.CopyOfJars()
|
updatableModules := global.UpdatableBootJars.CopyOfJars()
|
||||||
|
|
||||||
@@ -945,11 +940,8 @@ func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConf
|
|||||||
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
||||||
|
|
||||||
return updatableBcpPackages
|
return updatableBcpPackages
|
||||||
}).(android.WritablePath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var updatableBcpPackagesRuleKey = android.NewOnceKey("updatableBcpPackagesRule")
|
|
||||||
|
|
||||||
func dumpOatRules(ctx android.SingletonContext, image *bootImageConfig) {
|
func dumpOatRules(ctx android.SingletonContext, image *bootImageConfig) {
|
||||||
var allPhonies android.Paths
|
var allPhonies android.Paths
|
||||||
for _, image := range image.variants {
|
for _, image := range image.variants {
|
||||||
|
Reference in New Issue
Block a user