summaryrefslogtreecommitdiff
path: root/java/boot_jars.go
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2021-01-17 21:05:12 +0000
committer Martin Stjernholm <mast@google.com> 2021-01-28 20:09:24 +0000
commit1dc0d6d7f2f76b056864b77f9bbbfcfbb50d1eef (patch)
tree1a5e2a6b1424a6036d410a39affcd30038af5161 /java/boot_jars.go
parent57eec1007efb7911e9060584a6ef15b53cfdf85d (diff)
Fix boot jar handling when both source and prebuilt APEXes and modules
are present. 1) The boot jar to APEX mapping is maintained by the base names for both of them. When building with prebuilt modules and APEXes, that means we need to take care to compare them without regard to any "prebuilt_" prefixes. 2) VisitAllModules can visit disabled modules and both source and prebuilt modules, so they need some conditions to skip modules that aren't applicable for boot jars. Test: `m droid` Test: `m droid SOONG_CONFIG_art_module_source_build=false` with fresh ART Module prebuilts in place Bug: 171061220 Change-Id: Iced269d29127bc8b8f9b3171adb60a97d115628b
Diffstat (limited to 'java/boot_jars.go')
-rw-r--r--java/boot_jars.go34
1 files changed, 30 insertions, 4 deletions
diff --git a/java/boot_jars.go b/java/boot_jars.go
index 823275b1d..ac8107b7c 100644
--- a/java/boot_jars.go
+++ b/java/boot_jars.go
@@ -49,14 +49,36 @@ func populateMapFromConfiguredJarList(ctx android.SingletonContext, moduleToApex
return true
}
+// isActiveModule returns true if the given module should be considered for boot
+// jars, i.e. if it's enabled and the preferred one in case of source and
+// prebuilt alternatives.
+func isActiveModule(module android.Module) bool {
+ if !module.Enabled() {
+ return false
+ }
+ if module.IsReplacedByPrebuilt() {
+ // A source module that has been replaced by a prebuilt counterpart.
+ return false
+ }
+ if prebuilt, ok := module.(android.PrebuiltInterface); ok {
+ if p := prebuilt.Prebuilt(); p != nil {
+ return p.UsePrebuilt()
+ }
+ }
+ return true
+}
+
func (b *bootJarsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
config := ctx.Config()
if config.SkipBootJarsCheck() {
return
}
- // Populate a map from module name to APEX from the boot jars. If there is a problem
- // such as duplicate modules then fail and return immediately.
+ // Populate a map from module name to APEX from the boot jars. If there is a
+ // problem such as duplicate modules then fail and return immediately. Note
+ // that both module and APEX names are tracked by base names here, so we need
+ // to be careful to remove "prebuilt_" prefixes when comparing them with
+ // actual modules and APEX bundles.
moduleToApex := make(map[string]string)
if !populateMapFromConfiguredJarList(ctx, moduleToApex, config.NonUpdatableBootJars(), "BootJars") ||
!populateMapFromConfiguredJarList(ctx, moduleToApex, config.UpdatableBootJars(), "UpdatableBootJars") {
@@ -69,10 +91,14 @@ func (b *bootJarsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
// Scan all the modules looking for the module/apex variants corresponding to the
// boot jars.
ctx.VisitAllModules(func(module android.Module) {
- name := ctx.ModuleName(module)
+ if !isActiveModule(module) {
+ return
+ }
+
+ name := android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName(module))
if apex, ok := moduleToApex[name]; ok {
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
- if (apex == "platform" && apexInfo.IsForPlatform()) || apexInfo.InApex(apex) {
+ if (apex == "platform" && apexInfo.IsForPlatform()) || apexInfo.InApexByBaseName(apex) {
// The module name/apex variant should be unique in the system but double check
// just in case something has gone wrong.
if existing, ok := nameToApexVariant[name]; ok {