summaryrefslogtreecommitdiff
path: root/java/platform_bootclasspath.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2021-04-12 17:24:18 +0100
committerPaul Duffin <paulduffin@google.com>2021-04-13 19:15:27 +0100
commit8f146b99e6a37cce6bedb664ab12bd992ff688ce (patch)
tree8ce3b5c1d29f4fab79a16dbdcee90d00df97052f /java/platform_bootclasspath.go
parent21fb92d7f6f033f556c5270c702bbcab80c861c1 (diff)
prebuilt_apex created ApexInfo must not include prebuilt_ prefix
As part of the work to modularize the hiddenAPI processing the generation of the monolithic hidden API index file needs to be moved to the platform_bootclasspath module type. Doing that broke the TestBootDexJarsFromSourcesAndPrebuilts tests which checks the inputs to the rule that creates that file. Fixing that required added a platform_bootclasspath module to the test fixture for those tests which highlighted an issue with the prebuilt_apex module. Previously, when the prebuilt_apex created apex variants it would use its own name as the apex variant name, even when that name included the prebuilt_ prefix. That broke the platform_bootclasspath logic as it was looking for apex variants for "myapex" but the only ones available were "prebuilt_myapex". This change ensures that it always uses the unprefixed name and fixes the TestNoUpdatableJarsInBootImage to match. This also adds some improved error reporting in platform_bootclasspath which helped debug this problem. Bug: 177892522 Test: m nothing Change-Id: I3e88b5cec767f77dcc0e94b3ae38b499d07eadf0
Diffstat (limited to 'java/platform_bootclasspath.go')
-rw-r--r--java/platform_bootclasspath.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index d98ce6719..d70098080 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -208,7 +208,30 @@ func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex st
// error, unless missing dependencies are allowed. The simplest way to handle that is to add a
// dependency that will not be satisfied and the default behavior will handle it.
if !addedDep {
- ctx.AddFarVariationDependencies(variations, tag, name)
+ // Add dependency on the unprefixed (i.e. source or renamed prebuilt) module which we know does
+ // not exist. The resulting error message will contain useful information about the available
+ // variants.
+ reportMissingVariationDependency(ctx, variations, name)
+
+ // Add dependency on the missing prefixed prebuilt variant too if a module with that name exists
+ // so that information about its available variants will be reported too.
+ if ctx.OtherModuleExists(prebuiltName) {
+ reportMissingVariationDependency(ctx, variations, prebuiltName)
+ }
+ }
+}
+
+// reportMissingVariationDependency intentionally adds a dependency on a missing variation in order
+// to generate an appropriate error message with information about the available variations.
+func reportMissingVariationDependency(ctx android.BottomUpMutatorContext, variations []blueprint.Variation, name string) {
+ modules := ctx.AddFarVariationDependencies(variations, nil, name)
+ if len(modules) != 1 {
+ panic(fmt.Errorf("Internal Error: expected one module, found %d", len(modules)))
+ return
+ }
+ if modules[0] != nil {
+ panic(fmt.Errorf("Internal Error: expected module to be missing but was found: %q", modules[0]))
+ return
}
}