Merge pull request #1 from colincross/bugfixes

Miscellaneous bugfixes
This commit is contained in:
jgennis 2015-03-05 17:19:29 -08:00
commit 482e8cf331
2 changed files with 22 additions and 14 deletions

View file

@ -124,6 +124,11 @@ func removeFileAndEmptyDirs(path string) error {
if os.IsNotExist(err) {
return nil
}
pathErr := err.(*os.PathError)
switch pathErr.Err {
case syscall.ENOTEMPTY, syscall.EEXIST:
return nil
}
return err
}

View file

@ -955,9 +955,10 @@ func (c *Context) addDependency(module *moduleInfo, depName string) []error {
return nil
}
func (c *Context) parallelVisitAllBottomUp(visit func(group *moduleGroup)) {
func (c *Context) parallelVisitAllBottomUp(visit func(group *moduleGroup) bool) {
doneCh := make(chan *moduleGroup)
count := 0
cancel := false
for _, group := range c.moduleGroupsSorted {
group.waitingCount = group.depsCount
@ -966,7 +967,10 @@ func (c *Context) parallelVisitAllBottomUp(visit func(group *moduleGroup)) {
visitOne := func(group *moduleGroup) {
count++
go func() {
visit(group)
ret := visit(group)
if ret {
cancel = true
}
doneCh <- group
}()
}
@ -977,20 +981,18 @@ func (c *Context) parallelVisitAllBottomUp(visit func(group *moduleGroup)) {
}
}
loop:
for {
for count > 0 {
select {
case doneGroup := <-doneCh:
if !cancel {
for _, parent := range doneGroup.reverseDeps {
parent.waitingCount--
if parent.waitingCount == 0 {
visitOne(parent)
}
}
count--
if count == 0 {
break loop
}
count--
}
}
}
@ -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
// calling Go package on a per-call basis. Since the initial parent scope doesn't matter we
// just set it to nil.
@ -1311,7 +1313,7 @@ func (c *Context) generateModuleBuildActions(config interface{},
if len(mctx.errs) > 0 {
errsCh <- mctx.errs
break
return true
}
depsCh <- mctx.ninjaFileDeps
@ -1320,9 +1322,10 @@ func (c *Context) generateModuleBuildActions(config interface{},
&mctx.actionDefs, liveGlobals)
if len(newErrs) > 0 {
errsCh <- newErrs
break
return true
}
}
return false
})
cancelCh <- struct{}{}