Merge "Support building boot images with disabled dexpreopt." am: 0caabb6e27
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1555134 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I3af267485a201e15e1ab8abba5f6ed3ed707dc80
This commit is contained in:
committed by
Automerger Merge Worker
commit
5602cf202b
27
apex/apex.go
27
apex/apex.go
@@ -29,6 +29,7 @@ import (
|
|||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/bpf"
|
"android/soong/bpf"
|
||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
|
"android/soong/dexpreopt"
|
||||||
prebuilt_etc "android/soong/etc"
|
prebuilt_etc "android/soong/etc"
|
||||||
"android/soong/filesystem"
|
"android/soong/filesystem"
|
||||||
"android/soong/java"
|
"android/soong/java"
|
||||||
@@ -720,9 +721,15 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.properties.Bpfs...)
|
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.properties.Bpfs...)
|
||||||
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
|
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
|
||||||
|
|
||||||
// With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
|
if a.artApex {
|
||||||
if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
|
// With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
|
||||||
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, "jacocoagent")
|
if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
|
||||||
|
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, "jacocoagent")
|
||||||
|
}
|
||||||
|
// The ART boot image depends on dex2oat to compile it.
|
||||||
|
if !java.SkipDexpreoptBootJars(ctx) {
|
||||||
|
dexpreopt.RegisterToolDeps(ctx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dependencies for signing
|
// Dependencies for signing
|
||||||
@@ -1521,6 +1528,9 @@ func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.Paylo
|
|||||||
if dt, ok := depTag.(dependencyTag); ok && !dt.payload {
|
if dt, ok := depTag.(dependencyTag); ok && !dt.payload {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if depTag == dexpreopt.Dex2oatDepTag {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
|
ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
|
||||||
externalDep := !android.InList(ctx.ModuleName(), ai.InApexes)
|
externalDep := !android.InList(ctx.ModuleName(), ai.InApexes)
|
||||||
@@ -1842,10 +1852,10 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specific to the ART apex: dexpreopt artifacts for libcore Java libraries. Build rules are
|
|
||||||
// generated by the dexpreopt singleton, and here we access build artifacts via the global
|
|
||||||
// boot image config.
|
|
||||||
if a.artApex {
|
if a.artApex {
|
||||||
|
// Specific to the ART apex: dexpreopt artifacts for libcore Java libraries. Build rules are
|
||||||
|
// generated by the dexpreopt singleton, and here we access build artifacts via the global
|
||||||
|
// boot image config.
|
||||||
for arch, files := range java.DexpreoptedArtApexJars(ctx) {
|
for arch, files := range java.DexpreoptedArtApexJars(ctx) {
|
||||||
dirInApex := filepath.Join("javalib", arch.String())
|
dirInApex := filepath.Join("javalib", arch.String())
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
@@ -1854,6 +1864,11 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
filesInfo = append(filesInfo, af)
|
filesInfo = append(filesInfo, af)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Call GetGlobalSoongConfig to initialize it, which may be necessary if dexpreopt is
|
||||||
|
// disabled for libraries/apps, but boot images are still needed.
|
||||||
|
if !java.SkipDexpreoptBootJars(ctx) {
|
||||||
|
dexpreopt.GetGlobalSoongConfig(ctx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicates in filesInfo
|
// Remove duplicates in filesInfo
|
||||||
|
@@ -27,8 +27,9 @@ import (
|
|||||||
// GlobalConfig stores the configuration for dex preopting. The fields are set
|
// GlobalConfig stores the configuration for dex preopting. The fields are set
|
||||||
// from product variables via dex_preopt_config.mk.
|
// from product variables via dex_preopt_config.mk.
|
||||||
type GlobalConfig struct {
|
type GlobalConfig struct {
|
||||||
DisablePreopt bool // disable preopt for all modules
|
DisablePreopt bool // disable preopt for all modules (excluding boot images)
|
||||||
DisablePreoptModules []string // modules with preopt disabled by product-specific config
|
DisablePreoptBootImages bool // disable prepot for boot images
|
||||||
|
DisablePreoptModules []string // modules with preopt disabled by product-specific config
|
||||||
|
|
||||||
OnlyPreoptBootImageAndSystemServer bool // only preopt jars in the boot image or system server
|
OnlyPreoptBootImageAndSystemServer bool // only preopt jars in the boot image or system server
|
||||||
|
|
||||||
@@ -234,8 +235,9 @@ func getGlobalConfigRaw(ctx android.PathContext) globalConfigAndRaw {
|
|||||||
return ctx.Config().Once(testGlobalConfigOnceKey, func() interface{} {
|
return ctx.Config().Once(testGlobalConfigOnceKey, func() interface{} {
|
||||||
// Nope, return a config with preopting disabled
|
// Nope, return a config with preopting disabled
|
||||||
return globalConfigAndRaw{&GlobalConfig{
|
return globalConfigAndRaw{&GlobalConfig{
|
||||||
DisablePreopt: true,
|
DisablePreopt: true,
|
||||||
DisableGenerateProfile: true,
|
DisablePreoptBootImages: true,
|
||||||
|
DisableGenerateProfile: true,
|
||||||
}, nil}
|
}, nil}
|
||||||
})
|
})
|
||||||
}).(globalConfigAndRaw)
|
}).(globalConfigAndRaw)
|
||||||
@@ -305,7 +307,7 @@ func dex2oatModuleName(config android.Config) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dex2oatDepTag = struct {
|
var Dex2oatDepTag = struct {
|
||||||
blueprint.BaseDependencyTag
|
blueprint.BaseDependencyTag
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
@@ -316,7 +318,7 @@ var dex2oatDepTag = struct {
|
|||||||
func RegisterToolDeps(ctx android.BottomUpMutatorContext) {
|
func RegisterToolDeps(ctx android.BottomUpMutatorContext) {
|
||||||
dex2oatBin := dex2oatModuleName(ctx.Config())
|
dex2oatBin := dex2oatModuleName(ctx.Config())
|
||||||
v := ctx.Config().BuildOSTarget.Variations()
|
v := ctx.Config().BuildOSTarget.Variations()
|
||||||
ctx.AddFarVariationDependencies(v, dex2oatDepTag, dex2oatBin)
|
ctx.AddFarVariationDependencies(v, Dex2oatDepTag, dex2oatBin)
|
||||||
}
|
}
|
||||||
|
|
||||||
func dex2oatPathFromDep(ctx android.ModuleContext) android.Path {
|
func dex2oatPathFromDep(ctx android.ModuleContext) android.Path {
|
||||||
@@ -332,7 +334,7 @@ func dex2oatPathFromDep(ctx android.ModuleContext) android.Path {
|
|||||||
// prebuilt explicitly here instead.
|
// prebuilt explicitly here instead.
|
||||||
var dex2oatModule android.Module
|
var dex2oatModule android.Module
|
||||||
ctx.WalkDeps(func(child, parent android.Module) bool {
|
ctx.WalkDeps(func(child, parent android.Module) bool {
|
||||||
if parent == ctx.Module() && ctx.OtherModuleDependencyTag(child) == dex2oatDepTag {
|
if parent == ctx.Module() && ctx.OtherModuleDependencyTag(child) == Dex2oatDepTag {
|
||||||
// Found the source module, or prebuilt module that has replaced the source.
|
// Found the source module, or prebuilt module that has replaced the source.
|
||||||
dex2oatModule = child
|
dex2oatModule = child
|
||||||
if p, ok := child.(android.PrebuiltInterface); ok && p.Prebuilt() != nil {
|
if p, ok := child.(android.PrebuiltInterface); ok && p.Prebuilt() != nil {
|
||||||
@@ -385,10 +387,10 @@ func createGlobalSoongConfig(ctx android.ModuleContext) *GlobalSoongConfig {
|
|||||||
|
|
||||||
// The main reason for this Once cache for GlobalSoongConfig is to make the
|
// The main reason for this Once cache for GlobalSoongConfig is to make the
|
||||||
// dex2oat path available to singletons. In ordinary modules we get it through a
|
// dex2oat path available to singletons. In ordinary modules we get it through a
|
||||||
// dex2oatDepTag dependency, but in singletons there's no simple way to do the
|
// Dex2oatDepTag dependency, but in singletons there's no simple way to do the
|
||||||
// same thing and ensure the right variant is selected, hence this cache to make
|
// same thing and ensure the right variant is selected, hence this cache to make
|
||||||
// the resolved path available to singletons. This means we depend on there
|
// the resolved path available to singletons. This means we depend on there
|
||||||
// being at least one ordinary module with a dex2oatDepTag dependency.
|
// being at least one ordinary module with a Dex2oatDepTag dependency.
|
||||||
//
|
//
|
||||||
// TODO(b/147613152): Implement a way to deal with dependencies from singletons,
|
// TODO(b/147613152): Implement a way to deal with dependencies from singletons,
|
||||||
// and then possibly remove this cache altogether (but the use in
|
// and then possibly remove this cache altogether (but the use in
|
||||||
|
@@ -347,8 +347,8 @@ func RegisterDexpreoptBootJarsComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterSingletonType("dex_bootjars", dexpreoptBootJarsFactory)
|
ctx.RegisterSingletonType("dex_bootjars", dexpreoptBootJarsFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
func skipDexpreoptBootJars(ctx android.PathContext) bool {
|
func SkipDexpreoptBootJars(ctx android.PathContext) bool {
|
||||||
return dexpreopt.GetGlobalConfig(ctx).DisablePreopt
|
return dexpreopt.GetGlobalConfig(ctx).DisablePreoptBootImages
|
||||||
}
|
}
|
||||||
|
|
||||||
// Singleton for generating boot image build rules.
|
// Singleton for generating boot image build rules.
|
||||||
@@ -371,7 +371,7 @@ type dexpreoptBootJars struct {
|
|||||||
|
|
||||||
// Accessor function for the apex package. Returns nil if dexpreopt is disabled.
|
// Accessor function for the apex package. Returns nil if dexpreopt is disabled.
|
||||||
func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]android.OutputPaths {
|
func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]android.OutputPaths {
|
||||||
if skipDexpreoptBootJars(ctx) {
|
if SkipDexpreoptBootJars(ctx) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Include dexpreopt files for the primary boot image.
|
// Include dexpreopt files for the primary boot image.
|
||||||
@@ -387,7 +387,7 @@ func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]and
|
|||||||
|
|
||||||
// Generate build rules for boot images.
|
// Generate build rules for boot images.
|
||||||
func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
|
func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
|
||||||
if skipDexpreoptBootJars(ctx) {
|
if SkipDexpreoptBootJars(ctx) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if dexpreopt.GetCachedGlobalSoongConfig(ctx) == nil {
|
if dexpreopt.GetCachedGlobalSoongConfig(ctx) == nil {
|
||||||
@@ -727,7 +727,7 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig,
|
|||||||
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
|
|
||||||
if global.DisableGenerateProfile || ctx.Config().UnbundledBuild() {
|
if global.DisableGenerateProfile {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
|
profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
|
||||||
|
Reference in New Issue
Block a user