Extract duplicate code to common helper functions.
Also, fall back to using a default name for the dexpreopt directory if we are not building for Android. Bug: 290583827 Test: m nothing Change-Id: I3fc6ff9142a2dcdf995796f75891b242fe2848d0
This commit is contained in:
@@ -311,4 +311,9 @@ func EmptyConfiguredJarList() ConfiguredJarList {
|
|||||||
return ConfiguredJarList{}
|
return ConfiguredJarList{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsConfiguredJarForPlatform returns true if the given apex name is a special name for the platform.
|
||||||
|
func IsConfiguredJarForPlatform(apex string) bool {
|
||||||
|
return apex == "platform" || apex == "system_ext"
|
||||||
|
}
|
||||||
|
|
||||||
var earlyBootJarsKey = NewOnceKey("earlyBootJars")
|
var earlyBootJarsKey = NewOnceKey("earlyBootJars")
|
||||||
|
@@ -77,7 +77,7 @@ func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyN
|
|||||||
// Use gatherApexModulePairDepsWithTag to retrieve the dependencies.
|
// Use gatherApexModulePairDepsWithTag to retrieve the dependencies.
|
||||||
func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex string, name string, tag blueprint.DependencyTag) {
|
func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex string, name string, tag blueprint.DependencyTag) {
|
||||||
var variations []blueprint.Variation
|
var variations []blueprint.Variation
|
||||||
if apex != "platform" && apex != "system_ext" {
|
if !android.IsConfiguredJarForPlatform(apex) {
|
||||||
// Pick the correct apex variant.
|
// Pick the correct apex variant.
|
||||||
variations = []blueprint.Variation{
|
variations = []blueprint.Variation{
|
||||||
{Mutator: "apex", Variation: apex},
|
{Mutator: "apex", Variation: apex},
|
||||||
|
@@ -505,8 +505,7 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC
|
|||||||
// No module has enabled dexpreopting, so we assume there will be no boot image to make.
|
// No module has enabled dexpreopting, so we assume there will be no boot image to make.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
archType := ctx.Config().Targets[android.Android][0].Arch.ArchType
|
d.dexpreoptConfigForMake = android.PathForOutput(ctx, getDexpreoptDirName(ctx), "dexpreopt.config")
|
||||||
d.dexpreoptConfigForMake = android.PathForOutput(ctx, toDexpreoptDirName(archType), "dexpreopt.config")
|
|
||||||
writeGlobalConfigForMake(ctx, d.dexpreoptConfigForMake)
|
writeGlobalConfigForMake(ctx, d.dexpreoptConfigForMake)
|
||||||
|
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
|
@@ -105,8 +105,7 @@ func genBootImageConfigRaw(ctx android.PathContext) map[string]*bootImageConfig
|
|||||||
func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
||||||
return ctx.Config().Once(bootImageConfigKey, func() interface{} {
|
return ctx.Config().Once(bootImageConfigKey, func() interface{} {
|
||||||
targets := dexpreoptTargets(ctx)
|
targets := dexpreoptTargets(ctx)
|
||||||
archType := ctx.Config().Targets[android.Android][0].Arch.ArchType
|
deviceDir := android.PathForOutput(ctx, getDexpreoptDirName(ctx))
|
||||||
deviceDir := android.PathForOutput(ctx, toDexpreoptDirName(archType))
|
|
||||||
|
|
||||||
configs := genBootImageConfigRaw(ctx)
|
configs := genBootImageConfigRaw(ctx)
|
||||||
|
|
||||||
@@ -218,8 +217,7 @@ var updatableBootConfigKey = android.NewOnceKey("apexBootConfig")
|
|||||||
func GetApexBootConfig(ctx android.PathContext) apexBootConfig {
|
func GetApexBootConfig(ctx android.PathContext) apexBootConfig {
|
||||||
return ctx.Config().Once(updatableBootConfigKey, func() interface{} {
|
return ctx.Config().Once(updatableBootConfigKey, func() interface{} {
|
||||||
apexBootJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars
|
apexBootJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars
|
||||||
archType := ctx.Config().Targets[android.Android][0].Arch.ArchType
|
dir := android.PathForOutput(ctx, getDexpreoptDirName(ctx), "apex_bootjars")
|
||||||
dir := android.PathForOutput(ctx, toDexpreoptDirName(archType), "apex_bootjars")
|
|
||||||
dexPaths := apexBootJars.BuildPaths(ctx, dir)
|
dexPaths := apexBootJars.BuildPaths(ctx, dir)
|
||||||
dexPathsByModuleName := apexBootJars.BuildPathsByModule(ctx, dir)
|
dexPathsByModuleName := apexBootJars.BuildPathsByModule(ctx, dir)
|
||||||
|
|
||||||
@@ -260,6 +258,11 @@ func dexpreoptConfigMakevars(ctx android.MakeVarsContext) {
|
|||||||
ctx.Strict("DEXPREOPT_BOOT_JARS_MODULES", strings.Join(defaultBootImageConfig(ctx).modules.CopyOfApexJarPairs(), ":"))
|
ctx.Strict("DEXPREOPT_BOOT_JARS_MODULES", strings.Join(defaultBootImageConfig(ctx).modules.CopyOfApexJarPairs(), ":"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func toDexpreoptDirName(arch android.ArchType) string {
|
func getDexpreoptDirName(ctx android.PathContext) string {
|
||||||
return "dexpreopt_" + arch.String()
|
prefix := "dexpreopt_"
|
||||||
|
targets := ctx.Config().Targets[android.Android]
|
||||||
|
if len(targets) > 0 {
|
||||||
|
return prefix+targets[0].Arch.ArchType.String()
|
||||||
|
}
|
||||||
|
return prefix+"unknown_target"
|
||||||
}
|
}
|
||||||
|
@@ -166,7 +166,7 @@ func isModuleInConfiguredList(ctx android.BaseModuleContext, module android.Modu
|
|||||||
|
|
||||||
// Now match the apex part of the boot image configuration.
|
// Now match the apex part of the boot image configuration.
|
||||||
requiredApex := configuredBootJars.Apex(index)
|
requiredApex := configuredBootJars.Apex(index)
|
||||||
if requiredApex == "platform" || requiredApex == "system_ext" {
|
if android.IsConfiguredJarForPlatform(requiredApex) {
|
||||||
if len(apexInfo.InApexVariants) != 0 {
|
if len(apexInfo.InApexVariants) != 0 {
|
||||||
// A platform variant is required but this is for an apex so ignore it.
|
// A platform variant is required but this is for an apex so ignore it.
|
||||||
return false
|
return false
|
||||||
|
Reference in New Issue
Block a user