aboutsummaryrefslogtreecommitdiff
path: root/exec.go
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-04-27 17:54:42 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-04-27 20:57:44 +0900
commit69bb7e4e120915d9b29744f5e118354f0f4335af (patch)
tree47391a4fb0f770efa8b196da3ac37f63bce1718f /exec.go
parent74a660001777308d7a47fdb4b0b3e00979dc5d0e (diff)
downloadkati-69bb7e4e120915d9b29744f5e118354f0f4335af.tar.gz
Implement -j flag
It seems to be working... -j1 for glog: 19.471 secs -j8 for glog: 4.493 secs
Diffstat (limited to 'exec.go')
-rw-r--r--exec.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/exec.go b/exec.go
index ca29c8d..989643a 100644
--- a/exec.go
+++ b/exec.go
@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"strings"
+ "sync"
)
type Executor struct {
@@ -16,6 +17,7 @@ type Executor struct {
firstRule *Rule
shell string
vars Vars
+ varsLock sync.Mutex
// target -> Job, nil means the target is currently being processed.
done map[string]*Job
@@ -143,18 +145,17 @@ func (ex *Executor) makeJobs(n *DepNode, neededBy *Job) error {
if present {
if j == nil {
if !n.IsPhony {
- fmt.Printf("Circular %s <- %s dependency dropped.\n", neededBy.n.Output, output)
+ fmt.Printf("Circular %s <- %s dependency dropped.\n", neededBy.n.Output, n.Output)
+ }
+ if neededBy != nil {
+ neededBy.numDeps--
}
} else {
- Log("Building: %s already done: %d", output, j.outputTs)
- ex.alreadyDoneCnt++
+ Log("%s already done: %d", j.n.Output, j.outputTs)
if neededBy != nil {
- j.parents = append(j.parents, neededBy)
+ ex.wm.ReportAlreadyFinished(j, neededBy)
}
}
- if neededBy != nil {
- neededBy.numDeps--
- }
return nil
}
@@ -169,12 +170,19 @@ func (ex *Executor) makeJobs(n *DepNode, neededBy *Job) error {
}
ex.done[output] = nil
+ // We iterate n.Deps twice. In the first run, we may modify
+ // numDeps. There will be a race if we do so after the first
+ // ex.makeJobs(d, j).
+ var deps []*DepNode
for _, d := range n.Deps {
if d.IsOrderOnly && exists(d.Output) {
j.numDeps--
continue
}
+ deps = append(deps, d)
+ }
+ for _, d := range deps {
ex.trace = append(ex.trace, d.Output)
err := ex.makeJobs(d, j)
ex.trace = ex.trace[0 : len(ex.trace)-1]