Merge "Extract default image specific logic from buildBootImage" am: 6d4de43833
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1686149 Change-Id: I1cd64a036c7c00d7937e9801b309e2aefb459e04
This commit is contained in:
@@ -434,10 +434,21 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC
|
||||
return
|
||||
}
|
||||
|
||||
// Always create the default boot image first, to get a unique profile rule for all images.
|
||||
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
|
||||
// Generate the profile rule from the default boot image.
|
||||
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).
|
||||
d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx)))
|
||||
d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx), profile))
|
||||
|
||||
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.
|
||||
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) {
|
||||
return getBootImageJar(ctx, image, module)
|
||||
}
|
||||
findAndCopyBootJars(ctx, image.modules, image.dexPaths, getBootJarFunc)
|
||||
|
||||
profile := bootImageProfileRule(ctx, image)
|
||||
bootFrameworkProfileRule(ctx, image)
|
||||
updatableBcpPackagesRule(ctx, image)
|
||||
|
||||
var zipFiles android.Paths
|
||||
for _, variant := range image.variants {
|
||||
files := buildBootImageVariant(ctx, variant, profile)
|
||||
@@ -805,7 +812,7 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig)
|
||||
if global.DisableGenerateProfile {
|
||||
return nil
|
||||
}
|
||||
profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
|
||||
|
||||
defaultProfile := "frameworks/base/config/boot-image-profile.txt"
|
||||
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
@@ -844,15 +851,8 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig)
|
||||
image.profileInstalls = rule.Installs()
|
||||
|
||||
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 {
|
||||
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
@@ -860,7 +860,6 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
|
||||
if global.DisableGenerateProfile || ctx.Config().UnbundledBuild() {
|
||||
return nil
|
||||
}
|
||||
return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} {
|
||||
|
||||
// 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,
|
||||
@@ -894,17 +893,13 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
|
||||
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
||||
|
||||
return profile
|
||||
}).(android.WritablePath)
|
||||
}
|
||||
|
||||
var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule")
|
||||
|
||||
func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig) android.WritablePath {
|
||||
if ctx.Config().UnbundledBuild() {
|
||||
return nil
|
||||
}
|
||||
|
||||
return ctx.Config().Once(updatableBcpPackagesRuleKey, func() interface{} {
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
updatableModules := global.UpdatableBootJars.CopyOfJars()
|
||||
|
||||
@@ -945,11 +940,8 @@ func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConf
|
||||
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
||||
|
||||
return updatableBcpPackages
|
||||
}).(android.WritablePath)
|
||||
}
|
||||
|
||||
var updatableBcpPackagesRuleKey = android.NewOnceKey("updatableBcpPackagesRule")
|
||||
|
||||
func dumpOatRules(ctx android.SingletonContext, image *bootImageConfig) {
|
||||
var allPhonies android.Paths
|
||||
for _, image := range image.variants {
|
||||
|
Reference in New Issue
Block a user