Refactor platform_bootclasspath to support multiple boot images.

Bug: 269230245
Test: m
Change-Id: I223756d5481607a82732f70c51057609ec4ee43f
This commit is contained in:
Jiakai Zhang
2023-02-24 17:05:02 +00:00
parent 8fe3a415b5
commit d49324dadb

View File

@@ -129,7 +129,7 @@ func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.Botto
// Add dependencies on all the non-updatable module configured in the "boot" boot image. That does // Add dependencies on all the non-updatable module configured in the "boot" boot image. That does
// not include modules configured in the "art" boot image. // not include modules configured in the "art" boot image.
bootImageConfig := b.getImageConfig(ctx) bootImageConfig := defaultBootImageConfig(ctx)
addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules, platformBootclasspathBootJarDepTag) addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules, platformBootclasspathBootJarDepTag)
// Add dependencies on all the apex jars. // Add dependencies on all the apex jars.
@@ -205,7 +205,7 @@ func (b *platformBootclasspathModule) generateClasspathProtoBuildActions(ctx and
func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList {
// Include all non APEX jars // Include all non APEX jars
jars := b.getImageConfig(ctx).modules jars := defaultBootImageConfig(ctx).modules
// Include jars from APEXes that don't populate their classpath proto config. // Include jars from APEXes that don't populate their classpath proto config.
remainingJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars remainingJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars
@@ -266,10 +266,6 @@ func (b *platformBootclasspathModule) checkApexModules(ctx android.ModuleContext
} }
} }
func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleContext) *bootImageConfig {
return defaultBootImageConfig(ctx)
}
// generateHiddenAPIBuildActions generates all the hidden API related build rules. // generateHiddenAPIBuildActions generates all the hidden API related build rules.
func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, modules []android.Module, fragments []android.Module) bootDexJarByModule { func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, modules []android.Module, fragments []android.Module) bootDexJarByModule {
@@ -410,27 +406,24 @@ func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.
// GenerateSingletonBuildActions method as it cannot create it for itself. // GenerateSingletonBuildActions method as it cannot create it for itself.
dexpreopt.GetGlobalSoongConfig(ctx) dexpreopt.GetGlobalSoongConfig(ctx)
imageConfig := b.getImageConfig(ctx)
if imageConfig == nil {
return
}
global := dexpreopt.GetGlobalConfig(ctx) global := dexpreopt.GetGlobalConfig(ctx)
if !shouldBuildBootImages(ctx.Config(), global) { if !shouldBuildBootImages(ctx.Config(), global) {
return return
} }
// Generate the framework profile rule frameworkBootImageConfig := defaultBootImageConfig(ctx)
bootFrameworkProfileRule(ctx, imageConfig) bootFrameworkProfileRule(ctx, frameworkBootImageConfig)
b.generateBootImage(ctx, frameworkBootImageName, platformModules)
b.copyApexBootJarsForAppsDexpreopt(ctx, apexModules)
dumpOatRules(ctx, frameworkBootImageConfig)
}
// Copy platform module dex jars to their predefined locations. func (b *platformBootclasspathModule) generateBootImage(ctx android.ModuleContext, imageName string, modules []android.Module) {
platformBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, platformModules) imageConfig := genBootImageConfigs(ctx)[imageName]
copyBootJarsToPredefinedLocations(ctx, platformBootDexJarsByModule, imageConfig.dexPathsByModule)
// Copy apex module dex jars to their predefined locations. // Copy module dex jars to their predefined locations.
config := GetApexBootConfig(ctx) bootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, modules)
apexBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, apexModules) copyBootJarsToPredefinedLocations(ctx, bootDexJarsByModule, imageConfig.dexPathsByModule)
copyBootJarsToPredefinedLocations(ctx, apexBootDexJarsByModule, config.dexPathsByModule)
// Build a profile for the image config and then use that to build the boot image. // Build a profile for the image config and then use that to build the boot image.
profile := bootImageProfileRule(ctx, imageConfig) profile := bootImageProfileRule(ctx, imageConfig)
@@ -443,6 +436,11 @@ func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.
// Build boot image files for the host variants. There are use directly by ART host side tests. // Build boot image files for the host variants. There are use directly by ART host side tests.
buildBootImageVariantsForBuildOs(ctx, imageConfig, profile) buildBootImageVariantsForBuildOs(ctx, imageConfig, profile)
}
dumpOatRules(ctx, imageConfig)
// Copy apex module dex jars to their predefined locations. They will be used for dexpreopt for apps.
func (b *platformBootclasspathModule) copyApexBootJarsForAppsDexpreopt(ctx android.ModuleContext, apexModules []android.Module) {
config := GetApexBootConfig(ctx)
apexBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, apexModules)
copyBootJarsToPredefinedLocations(ctx, apexBootDexJarsByModule, config.dexPathsByModule)
} }