Support building boot images with disabled dexpreopt.

Bug: 176171716
Test: build_mainline_modules.sh and ensure that the ART boot image is
    built: `find out -type f -name '*.art'` is nonempty for every arch.
Change-Id: Ibc45581eef2b205c750a30709780cf659ba7cfa1
This commit is contained in:
Ulya Trafimovich
2021-01-15 18:40:04 +00:00
parent 04f8d379e6
commit a4a1c4ee98
3 changed files with 37 additions and 20 deletions

View File

@@ -29,6 +29,7 @@ import (
"android/soong/android"
"android/soong/bpf"
"android/soong/cc"
"android/soong/dexpreopt"
prebuilt_etc "android/soong/etc"
"android/soong/filesystem"
"android/soong/java"
@@ -720,9 +721,15 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.properties.Bpfs...)
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
// With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, "jacocoagent")
if a.artApex {
// With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
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
@@ -1520,6 +1527,9 @@ func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.Paylo
if dt, ok := depTag.(dependencyTag); ok && !dt.payload {
return false
}
if depTag == dexpreopt.Dex2oatDepTag {
return false
}
ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
externalDep := !android.InList(ctx.ModuleName(), ai.InApexes)
@@ -1841,10 +1851,10 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
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 {
// 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) {
dirInApex := filepath.Join("javalib", arch.String())
for _, f := range files {
@@ -1853,6 +1863,11 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
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