Add AddReverseVariationDependency
Reverse variations currently must exactly match the variants of the
two modules, or only have 1 variant for the depending module. This
"1-variant fallback" is problematic for the new "base configuration"
feature and incremental soong, so we'd like to remove it. In order
to remove it, add AddReverseVariationDependency so that modules
can specify the correct variants to use instead of relying on the
1-variant fallback.
Bug: 369916167
Test: m nothing --no-skip-soong-tests
Change-Id: I2806021743de1f44041e7c818f7b84dba1aae9b3
diff --git a/android/mutator.go b/android/mutator.go
index 434e3ba..a8b5c7d 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -242,6 +242,16 @@
// be ordered correctly for all future mutator passes.
AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, names ...string) []blueprint.Module
+ // AddReverseVariationDependencies adds a dependency from the named module to the current
+ // module. The given variations will be added to the current module's varations, and then the
+ // result will be used to find the correct variation of the depending module, which must exist.
+ //
+ // Does not affect the ordering of the current mutator pass, but will be ordered
+ // correctly for all future mutator passes. All reverse dependencies for a destination module are
+ // collected until the end of the mutator pass, sorted by name, and then appended to the destination
+ // module's dependency list.
+ AddReverseVariationDependency([]blueprint.Variation, blueprint.DependencyTag, string)
+
// AddFarVariationDependencies adds deps as dependencies of the current module, but uses the
// variations argument to select which variant of the dependency to use. It returns a slice of
// modules for each dependency (some entries may be nil). A variant of the dependency must
@@ -703,6 +713,14 @@
}
b.bp.AddReverseDependency(module, tag, name)
}
+
+func (b *bottomUpMutatorContext) AddReverseVariationDependency(variations []blueprint.Variation, tag blueprint.DependencyTag, name string) {
+ if b.baseModuleContext.checkedMissingDeps() {
+ panic("Adding deps not allowed after checking for missing deps")
+ }
+ b.bp.AddReverseVariationDependency(variations, tag, name)
+}
+
func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
names ...string) []blueprint.Module {
if b.baseModuleContext.checkedMissingDeps() {