aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2024-03-29 16:00:42 -0700
committerColin Cross <ccross@android.com>2024-04-01 15:55:16 -0700
commit1d5e1a56febc27a5f204864b27464b4027d891d9 (patch)
tree16b634d0a5cf737616e91f7ae79b3ea54364d7f9
parent7b5888a4f64ac157e22679b0e258aa5f659dbf88 (diff)
downloadblueprint-1d5e1a56febc27a5f204864b27464b4027d891d9.tar.gz
Explicitly delete old logicModule entries from Context.moduleInfo
Creating variants has an optimization to reuse the logicModule of the original variant as the logicModule of the first new variant. Using the same logicModule meant that updating the Context.moduleInfo map from logicModules to *moduleInfo would overwrite the old entry for the original variant with the new entry for the first variant. TransitionMutators will need to keep the original logicModule for later use, which will require disabling the optimization that reuses it. When the first variant is added to the map it no longer overwrites the original variant. Excplicitly track the original logicModule and remove it from the map if necessary. Bug: 319288033 Test: go test ./... Change-Id: I05ffdf6d7ce60508f6d9e9657c21032f2c4f5d9c
-rw-r--r--context.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/context.go b/context.go
index c748545..92a6962 100644
--- a/context.go
+++ b/context.go
@@ -3086,6 +3086,11 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo,
deps []string
}
+ type newVariationPair struct {
+ newVariations modulesOrAliases
+ origLogicModule Module
+ }
+
reverseDeps := make(map[*moduleInfo][]depInfo)
var rename []rename
var replace []replace
@@ -3093,7 +3098,7 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo,
errsCh := make(chan []error)
globalStateCh := make(chan globalStateChange)
- newVariationsCh := make(chan modulesOrAliases)
+ newVariationsCh := make(chan newVariationPair)
done := make(chan bool)
c.depsModified = 0
@@ -3113,6 +3118,8 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo,
pauseCh: pause,
}
+ origLogicModule := module.logicModule
+
module.startedMutator = mutator
func() {
@@ -3138,7 +3145,7 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo,
}
if len(mctx.newVariations) > 0 {
- newVariationsCh <- mctx.newVariations
+ newVariationsCh <- newVariationPair{mctx.newVariations, origLogicModule}
}
if len(mctx.reverseDeps) > 0 || len(mctx.replace) > 0 || len(mctx.rename) > 0 || len(mctx.newModules) > 0 || len(mctx.ninjaFileDeps) > 0 {
@@ -3154,6 +3161,8 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo,
return false
}
+ var obsoleteLogicModules []Module
+
// Process errs and reverseDeps in a single goroutine
go func() {
for {
@@ -3169,7 +3178,10 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo,
newModules = append(newModules, globalStateChange.newModules...)
deps = append(deps, globalStateChange.deps...)
case newVariations := <-newVariationsCh:
- for _, moduleOrAlias := range newVariations {
+ if newVariations.origLogicModule != newVariations.newVariations[0].module().logicModule {
+ obsoleteLogicModules = append(obsoleteLogicModules, newVariations.origLogicModule)
+ }
+ for _, moduleOrAlias := range newVariations.newVariations {
if m := moduleOrAlias.module(); m != nil {
newModuleInfo[m.logicModule] = m
}
@@ -3201,6 +3213,10 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo,
return nil, errs
}
+ for _, obsoleteLogicModule := range obsoleteLogicModules {
+ delete(newModuleInfo, obsoleteLogicModule)
+ }
+
c.moduleInfo = newModuleInfo
for _, group := range c.moduleGroups {