Move bootFrameworkProfileRule to platform_bootclasspath
Changes bootFrameworkProfileRule to use ModuleContext instead of SingletonContext and moves the call from dexpreoptBootJar's GenerateSingletonBuildActions method to platform_bootclasspath's GenerateAndroidBuildActions. Changing the context also allows the code to switch from bootFrameworkProfileRule to GetGlobalSoongConfig. Also extracts the shouldBuildBootImages function so it can be used by platform_bootclasspath to preserve the existing behavior. Bug: 177892522 Test: m droid Change-Id: I30d3ca10be7f84348ad3aa9cc984dd15b8f6f4e9
This commit is contained in:
@@ -423,14 +423,7 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC
|
|||||||
writeGlobalConfigForMake(ctx, d.dexpreoptConfigForMake)
|
writeGlobalConfigForMake(ctx, d.dexpreoptConfigForMake)
|
||||||
|
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
|
if !shouldBuildBootImages(ctx.Config(), global) {
|
||||||
// Skip recompiling the boot image for the second sanitization phase. We'll get separate paths
|
|
||||||
// and invalidate first-stage artifacts which are crucial to SANITIZE_LITE builds.
|
|
||||||
// Note: this is technically incorrect. Compiled code contains stack checks which may depend
|
|
||||||
// on ASAN settings.
|
|
||||||
if len(ctx.Config().SanitizeDevice()) == 1 &&
|
|
||||||
ctx.Config().SanitizeDevice()[0] == "address" &&
|
|
||||||
global.SanitizeLite {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,9 +431,6 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC
|
|||||||
defaultImageConfig := defaultBootImageConfig(ctx)
|
defaultImageConfig := defaultBootImageConfig(ctx)
|
||||||
profile := bootImageProfileRule(ctx, defaultImageConfig)
|
profile := bootImageProfileRule(ctx, defaultImageConfig)
|
||||||
|
|
||||||
// Generate the framework profile rule
|
|
||||||
bootFrameworkProfileRule(ctx, defaultImageConfig)
|
|
||||||
|
|
||||||
// Generate the updatable bootclasspath packages rule.
|
// Generate the updatable bootclasspath packages rule.
|
||||||
updatableBcpPackagesRule(ctx, defaultImageConfig)
|
updatableBcpPackagesRule(ctx, defaultImageConfig)
|
||||||
|
|
||||||
@@ -455,6 +445,18 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC
|
|||||||
dumpOatRules(ctx, d.defaultBootImage)
|
dumpOatRules(ctx, d.defaultBootImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shouldBuildBootImages determines whether boot images should be built.
|
||||||
|
func shouldBuildBootImages(config android.Config, global *dexpreopt.GlobalConfig) bool {
|
||||||
|
// Skip recompiling the boot image for the second sanitization phase. We'll get separate paths
|
||||||
|
// and invalidate first-stage artifacts which are crucial to SANITIZE_LITE builds.
|
||||||
|
// Note: this is technically incorrect. Compiled code contains stack checks which may depend
|
||||||
|
// on ASAN settings.
|
||||||
|
if len(config.SanitizeDevice()) == 1 && config.SanitizeDevice()[0] == "address" && global.SanitizeLite {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Inspect this module to see if it contains a bootclasspath dex jar.
|
// Inspect this module to see if it contains a bootclasspath dex jar.
|
||||||
// Note that the same jar may occur in multiple modules.
|
// Note that the same jar may occur in multiple modules.
|
||||||
// This logic is tested in the apex package to avoid import cycle apex <-> java.
|
// This logic is tested in the apex package to avoid import cycle apex <-> java.
|
||||||
@@ -853,8 +855,10 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig)
|
|||||||
return profile
|
return profile
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConfig) android.WritablePath {
|
// bootFrameworkProfileRule generates the rule to create the boot framework profile and
|
||||||
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
// returns a path to the generated file.
|
||||||
|
func bootFrameworkProfileRule(ctx android.ModuleContext, image *bootImageConfig) android.WritablePath {
|
||||||
|
globalSoong := dexpreopt.GetGlobalSoongConfig(ctx)
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
|
|
||||||
if global.DisableGenerateProfile || ctx.Config().UnbundledBuild() {
|
if global.DisableGenerateProfile || ctx.Config().UnbundledBuild() {
|
||||||
|
@@ -168,9 +168,7 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars
|
b.generateBootImageBuildActions(ctx)
|
||||||
// GenerateSingletonBuildActions method as it cannot create it for itself.
|
|
||||||
dexpreopt.GetGlobalSoongConfig(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig {
|
func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig {
|
||||||
@@ -297,3 +295,23 @@ func (b *platformBootclasspathModule) generatedHiddenAPIMetadataRules(ctx androi
|
|||||||
|
|
||||||
rule.Build("platform-bootclasspath-monolithic-hiddenapi-metadata", "monolithic hidden API metadata")
|
rule.Build("platform-bootclasspath-monolithic-hiddenapi-metadata", "monolithic hidden API metadata")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generateBootImageBuildActions generates ninja rules related to the boot image creation.
|
||||||
|
func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext) {
|
||||||
|
// Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars
|
||||||
|
// GenerateSingletonBuildActions method as it cannot create it for itself.
|
||||||
|
dexpreopt.GetGlobalSoongConfig(ctx)
|
||||||
|
|
||||||
|
imageConfig := b.getImageConfig(ctx)
|
||||||
|
if imageConfig == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
|
if !shouldBuildBootImages(ctx.Config(), global) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the framework profile rule
|
||||||
|
bootFrameworkProfileRule(ctx, imageConfig)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user