Merge "Pass the parameters to goroutine to avoid relying on a go 1.22 fix." into main am: da55eb2a45

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

Change-Id: I84d282574447f97d5d84d38f1a7744dcf40f9d68
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Yu Liu 2024-05-24 18:31:55 +00:00 committed by Automerger Merge Worker
commit 5bc84bebd3

View file

@ -4514,7 +4514,7 @@ func (c *Context) writeAllModuleActions(nw *ninjaWriter, shardNinja bool, ninjaF
shardedModules := proptools.ShardByCount(modules, len(fileNames)) shardedModules := proptools.ShardByCount(modules, len(fileNames))
ninjaShardCnt := len(shardedModules) ninjaShardCnt := len(shardedModules)
for i, batchModules := range shardedModules { for i, batchModules := range shardedModules {
go func() { go func(i int, batchModules []*moduleInfo) {
f, err := os.OpenFile(filepath.Join(c.SrcDir(), fileNames[i]), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, OutFilePermissions) f, err := os.OpenFile(filepath.Join(c.SrcDir(), fileNames[i]), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, OutFilePermissions)
if err != nil { if err != nil {
errorCh <- fmt.Errorf("error opening Ninja file: %s", err) errorCh <- fmt.Errorf("error opening Ninja file: %s", err)
@ -4525,7 +4525,7 @@ func (c *Context) writeAllModuleActions(nw *ninjaWriter, shardNinja bool, ninjaF
defer buf.Flush() defer buf.Flush()
writer := newNinjaWriter(buf) writer := newNinjaWriter(buf)
errorCh <- c.writeModuleAction(batchModules, writer, headerTemplate) errorCh <- c.writeModuleAction(batchModules, writer, headerTemplate)
}() }(i, batchModules)
nw.Subninja(fileNames[i]) nw.Subninja(fileNames[i])
} }