Ignore dependency variations for TransitionMutators that didn't apply am: de024f6167

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3070726

Change-Id: I255cb6d93ec98457fb3ef1ab1337cde243208eca
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Colin Cross 2024-05-02 23:16:13 +00:00 committed by Automerger Merge Worker
commit 8268cb1c6a

View file

@ -1876,8 +1876,16 @@ func (c *Context) findReverseDependency(module *moduleInfo, config any, destName
// and applies the IncomingTransition method of each completed TransitionMutator to modify the requested variation.
// It finds a variant that existed before the TransitionMutator ran that is a subset of the requested variant to
// use as the module context for IncomingTransition.
func (c *Context) applyIncomingTransitions(config any, group *moduleGroup, variant variationMap) {
func (c *Context) applyIncomingTransitions(config any, group *moduleGroup, variant variationMap, requestedVariations []Variation) {
for _, transitionMutator := range c.transitionMutators {
if len(transitionMutator.inputVariants[group]) == 0 {
// The transition mutator didn't apply anything to the target module, remove the variation unless it
// was explicitly requested when adding the dependency.
if !slices.ContainsFunc(requestedVariations, func(v Variation) bool { return v.Mutator == transitionMutator.name }) {
delete(variant, transitionMutator.name)
}
continue
}
for _, inputVariant := range transitionMutator.inputVariants[group] {
if inputVariant.variant.variations.subsetOf(variant) {
sourceVariation := variant[transitionMutator.name]
@ -1893,11 +1901,10 @@ func (c *Context) applyIncomingTransitions(config any, group *moduleGroup, varia
}
}
}
}
func (c *Context) findVariant(module *moduleInfo, config any,
possibleDeps *moduleGroup, variations []Variation, far bool, reverse bool) (*moduleInfo, variationMap) {
possibleDeps *moduleGroup, requestedVariations []Variation, far bool, reverse bool) (*moduleInfo, variationMap) {
// We can't just append variant.Variant to module.dependencyVariant.variantName and
// compare the strings because the result won't be in mutator registration order.
@ -1913,14 +1920,14 @@ func (c *Context) findVariant(module *moduleInfo, config any,
newVariant = module.variant.variations.clone()
}
}
for _, v := range variations {
for _, v := range requestedVariations {
if newVariant == nil {
newVariant = make(variationMap)
}
newVariant[v.Mutator] = v.Variation
}
c.applyIncomingTransitions(config, possibleDeps, newVariant)
c.applyIncomingTransitions(config, possibleDeps, newVariant, requestedVariations)
check := func(variant variationMap) bool {
if far {