commit
482e8cf331
2 changed files with 22 additions and 14 deletions
|
@ -124,6 +124,11 @@ func removeFileAndEmptyDirs(path string) error {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
pathErr := err.(*os.PathError)
|
||||||
|
switch pathErr.Err {
|
||||||
|
case syscall.ENOTEMPTY, syscall.EEXIST:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
context.go
31
context.go
|
@ -955,9 +955,10 @@ func (c *Context) addDependency(module *moduleInfo, depName string) []error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) parallelVisitAllBottomUp(visit func(group *moduleGroup)) {
|
func (c *Context) parallelVisitAllBottomUp(visit func(group *moduleGroup) bool) {
|
||||||
doneCh := make(chan *moduleGroup)
|
doneCh := make(chan *moduleGroup)
|
||||||
count := 0
|
count := 0
|
||||||
|
cancel := false
|
||||||
|
|
||||||
for _, group := range c.moduleGroupsSorted {
|
for _, group := range c.moduleGroupsSorted {
|
||||||
group.waitingCount = group.depsCount
|
group.waitingCount = group.depsCount
|
||||||
|
@ -966,7 +967,10 @@ func (c *Context) parallelVisitAllBottomUp(visit func(group *moduleGroup)) {
|
||||||
visitOne := func(group *moduleGroup) {
|
visitOne := func(group *moduleGroup) {
|
||||||
count++
|
count++
|
||||||
go func() {
|
go func() {
|
||||||
visit(group)
|
ret := visit(group)
|
||||||
|
if ret {
|
||||||
|
cancel = true
|
||||||
|
}
|
||||||
doneCh <- group
|
doneCh <- group
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -977,20 +981,18 @@ func (c *Context) parallelVisitAllBottomUp(visit func(group *moduleGroup)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loop:
|
for count > 0 {
|
||||||
for {
|
|
||||||
select {
|
select {
|
||||||
case doneGroup := <-doneCh:
|
case doneGroup := <-doneCh:
|
||||||
for _, parent := range doneGroup.reverseDeps {
|
if !cancel {
|
||||||
parent.waitingCount--
|
for _, parent := range doneGroup.reverseDeps {
|
||||||
if parent.waitingCount == 0 {
|
parent.waitingCount--
|
||||||
visitOne(parent)
|
if parent.waitingCount == 0 {
|
||||||
|
visitOne(parent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count--
|
count--
|
||||||
if count == 0 {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1290,7 +1292,7 @@ func (c *Context) generateModuleBuildActions(config interface{},
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
c.parallelVisitAllBottomUp(func(group *moduleGroup) {
|
c.parallelVisitAllBottomUp(func(group *moduleGroup) bool {
|
||||||
// The parent scope of the moduleContext's local scope gets overridden to be that of the
|
// The parent scope of the moduleContext's local scope gets overridden to be that of the
|
||||||
// calling Go package on a per-call basis. Since the initial parent scope doesn't matter we
|
// calling Go package on a per-call basis. Since the initial parent scope doesn't matter we
|
||||||
// just set it to nil.
|
// just set it to nil.
|
||||||
|
@ -1311,7 +1313,7 @@ func (c *Context) generateModuleBuildActions(config interface{},
|
||||||
|
|
||||||
if len(mctx.errs) > 0 {
|
if len(mctx.errs) > 0 {
|
||||||
errsCh <- mctx.errs
|
errsCh <- mctx.errs
|
||||||
break
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
depsCh <- mctx.ninjaFileDeps
|
depsCh <- mctx.ninjaFileDeps
|
||||||
|
@ -1320,9 +1322,10 @@ func (c *Context) generateModuleBuildActions(config interface{},
|
||||||
&mctx.actionDefs, liveGlobals)
|
&mctx.actionDefs, liveGlobals)
|
||||||
if len(newErrs) > 0 {
|
if len(newErrs) > 0 {
|
||||||
errsCh <- newErrs
|
errsCh <- newErrs
|
||||||
break
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
cancelCh <- struct{}{}
|
cancelCh <- struct{}{}
|
||||||
|
|
Loading…
Reference in a new issue