Create APEX variant for prebuilt_apex/apex_set
Previously, the prebuilt_apex/apex_set did not have an apex specific
variant created which meant that they depended upon the platform
variant of the modules it depended upon. This change creates an
apex variant for them just as is done for the apex module type which
causes it to depend upon the apex specific variant of the modules it
depends upon.
Test: m droid
Bug: 179354495
Merged-In: I7d6f3609c267b3e90b90b9befe7d76f351a0c2bd
Change-Id: I7d6f3609c267b3e90b90b9befe7d76f351a0c2bd
(cherry picked from commit 6717d88f465a96537cf0c3e74c1d060d6a739752)
diff --git a/apex/apex.go b/apex/apex.go
index 0c127b2..4fdc3df 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1044,8 +1044,9 @@
// apexBundle itself is mutated so that it and its dependencies have the same apex variant.
// TODO(jiyong): document the reason why the VNDK APEX is an exception here.
- if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
- apexBundleName := mctx.ModuleName()
+ unprefixedModuleName := android.RemoveOptionalPrebuiltPrefix(mctx.ModuleName())
+ if apexModuleTypeRequiresVariant(mctx.Module()) {
+ apexBundleName := unprefixedModuleName
mctx.CreateVariations(apexBundleName)
if strings.HasPrefix(apexBundleName, "com.android.art") {
// Create an alias from the platform variant. This is done to make
@@ -1063,6 +1064,12 @@
mctx.ModuleErrorf("base property is not set")
return
}
+ // Workaround the issue reported in b/191269918 by using the unprefixed module name of this
+ // module as the default variation to use if dependencies of this module do not have the correct
+ // apex variant name. This name matches the name used to create the variations of modules for
+ // which apexModuleTypeRequiresVariant return true.
+ // TODO(b/191269918): Remove this workaround.
+ mctx.SetDefaultDependencyVariation(&unprefixedModuleName)
mctx.CreateVariations(apexBundleName)
if strings.HasPrefix(apexBundleName, "com.android.art") {
// TODO(b/183882457): See note for CreateAliasVariation above.
@@ -1071,6 +1078,22 @@
}
}
+// apexModuleTypeRequiresVariant determines whether the module supplied requires an apex specific
+// variant.
+func apexModuleTypeRequiresVariant(module android.Module) bool {
+ if a, ok := module.(*apexBundle); ok {
+ return !a.vndkApex
+ }
+
+ // Match apex_set and prebuilt_apex. Would also match apexBundle but that is handled specially
+ // above.
+ if _, ok := module.(ApexInfoMutator); ok {
+ return true
+ }
+
+ return false
+}
+
// See android.UpdateDirectlyInAnyApex
// TODO(jiyong): move this to android/apex.go?
func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) {