From 7b5888a4f64ac157e22679b0e258aa5f659dbf88 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 28 Mar 2024 13:40:53 -0700 Subject: [PATCH] Keep logicModule for obsolete variants When splitting a module into variants the original *moduleInfo was left in place but with logicModule set to nil as a marker that the variant was obsolete and any incoming dependencies needed to be resolved onto one of the newly split variants. A change to allow TransitionMutator IncomingTransition calls when adding dependencies later will require keeping the obsolete *moduleInfo and logicModule around so that IncomingTransition can be called on it. so use an explicit boolean to mark the module as obsolete instead of clearing logicModule. Bug: 319288033 Test: go test ./... Change-Id: I5dc201f43442aa07ac1b858240c675bab3782b55 --- context.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/context.go b/context.go index 6d539f3..c748545 100644 --- a/context.go +++ b/context.go @@ -344,7 +344,8 @@ type moduleInfo struct { waitingCount int // set during each runMutator - splitModules modulesOrAliases + splitModules modulesOrAliases + obsoletedByNewVariants bool // Used by TransitionMutator implementations transitionVariations []string @@ -1796,7 +1797,7 @@ func (c *Context) createVariations(origModule *moduleInfo, mutatorName string, // Mark original variant as invalid. Modules that depend on this module will still // depend on origModule, but we'll fix it when the mutator is called on them. - origModule.logicModule = nil + origModule.obsoletedByNewVariants = true origModule.splitModules = newModules atomic.AddUint32(&c.depsModified, 1) @@ -1853,7 +1854,7 @@ func chooseDepInherit(mutatorName string, defaultVariationName *string) depChoos func (c *Context) convertDepsToVariation(module *moduleInfo, variationIndex int, depChooser depChooser) (errs []error) { for i, dep := range module.directDeps { - if dep.module.logicModule == nil { + if dep.module.obsoletedByNewVariants { newDep, missingVariation := depChooser(module, variationIndex, i, dep) if newDep == nil { errs = append(errs, &BlueprintError{ @@ -3218,12 +3219,12 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo, // Fix up any remaining dependencies on modules that were split into variants // by replacing them with the first variant for j, dep := range module.directDeps { - if dep.module.logicModule == nil { + if dep.module.obsoletedByNewVariants { module.directDeps[j].module = dep.module.splitModules.firstModule() } } - if module.createdBy != nil && module.createdBy.logicModule == nil { + if module.createdBy != nil && module.createdBy.obsoletedByNewVariants { module.createdBy = module.createdBy.splitModules.firstModule() } @@ -3248,7 +3249,7 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo, // change inside the loop for i := 0; i < len(group.modules); i++ { if alias := group.modules[i].alias(); alias != nil { - if alias.target.logicModule == nil { + if alias.target.obsoletedByNewVariants { newTarget := findAliasTarget(alias.target.variant) if newTarget != nil { alias.target = newTarget