aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2024-03-28 13:40:53 -0700
committerColin Cross <ccross@android.com>2024-04-01 15:55:15 -0700
commit7b5888a4f64ac157e22679b0e258aa5f659dbf88 (patch)
treeee864223356ba9462d451045cf2573866031340d
parentfab4866a685334a2450dc92183dcfc113f72743e (diff)
downloadblueprint-7b5888a4f64ac157e22679b0e258aa5f659dbf88.tar.gz
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
-rw-r--r--context.go13
1 files 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