Remove global state from apex modules

A global variant was used to store the global mapping between
modules and APEXes.  Replace it with storing pointers to APEX
contents inside each module so that they can query the contents
of any APEXes they belong to.

Bug: 146393795
Test: all Soong tests
Test: single line change to build.ninja host install dependency ordering
Test: no Android-${TARGET_PRODUCT}.mk, make_vars-${TARGET_PRODUCT}.mk or late-${TARGET_PRODUCT}.mk
Change-Id: Id2d7b73ea27f8c3b41d30820bdd86b65c539bfa4
This commit is contained in:
Colin Cross
2020-09-15 18:30:11 -07:00
parent a8baa88424
commit 56a8321c21
23 changed files with 528 additions and 337 deletions

View File

@@ -266,12 +266,13 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul
}
// Check that this module satisfies constraints for a particular boot image.
apex, isApexModule := module.(android.ApexModule)
fromUpdatableApex := isApexModule && apex.Updatable()
_, isApexModule := module.(android.ApexModule)
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
fromUpdatableApex := isApexModule && apexInfo.Updatable
if image.name == artBootImageName {
if isApexModule && len(apex.InApexes()) > 0 && allHavePrefix(apex.InApexes(), "com.android.art.") {
if isApexModule && len(apexInfo.InApexes) > 0 && allHavePrefix(apexInfo.InApexes, "com.android.art.") {
// ok: found the jar in the ART apex
} else if isApexModule && apex.IsForPlatform() && isHostdex(module) {
} else if isApexModule && apexInfo.IsForPlatform() && isHostdex(module) {
// exception (skip and continue): special "hostdex" platform variant
return -1, nil
} else if name == "jacocoagent" && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
@@ -279,7 +280,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul
return -1, nil
} else if fromUpdatableApex {
// error: this jar is part of an updatable apex other than ART
ctx.Errorf("module %q from updatable apexes %q is not allowed in the ART boot image", name, apex.InApexes())
ctx.Errorf("module %q from updatable apexes %q is not allowed in the ART boot image", name, apexInfo.InApexes)
} else {
// error: this jar is part of the platform or a non-updatable apex
ctx.Errorf("module %q is not allowed in the ART boot image", name)
@@ -289,7 +290,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul
// ok: this jar is part of the platform or a non-updatable apex
} else {
// error: this jar is part of an updatable apex
ctx.Errorf("module %q from updatable apexes %q is not allowed in the framework boot image", name, apex.InApexes())
ctx.Errorf("module %q from updatable apexes %q is not allowed in the framework boot image", name, apexInfo.InApexes)
}
} else {
panic("unknown boot image: " + image.name)