aboutsummaryrefslogtreecommitdiff
path: root/exec.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-25 00:10:52 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-25 11:37:49 +0900
commit744bb2b8d146eaba4d073cf58e35a60903e06de8 (patch)
tree15d5c79f4e62428b3c427d0ce15e0076a92139de /exec.go
parent44ae8cfdc153dd1a209b16453d5dbaa8b4f199d7 (diff)
downloadkati-744bb2b8d146eaba4d073cf58e35a60903e06de8.tar.gz
go gettable for github.com/google/kati
Diffstat (limited to 'exec.go')
-rw-r--r--exec.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/exec.go b/exec.go
index 2cacc93..8c1ac1e 100644
--- a/exec.go
+++ b/exec.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package main
+package kati
import (
"bytes"
@@ -207,7 +207,7 @@ func (ex *Executor) makeJobs(n *DepNode, neededBy *Job) error {
}
func (ex *Executor) reportStats() {
- if !katiLogFlag && !katiPeriodicStatsFlag {
+ if !LogFlag && !PeriodicStatsFlag {
return
}
@@ -218,17 +218,28 @@ func (ex *Executor) reportStats() {
}
}
-func NewExecutor(vars Vars) *Executor {
+type ExecutorOpt struct {
+ NumJobs int
+ ParaPath string
+}
+
+func NewExecutor(vars Vars, opt *ExecutorOpt) *Executor {
+ if opt == nil {
+ opt = &ExecutorOpt{NumJobs: 1}
+ }
+ if opt.NumJobs < 1 {
+ opt.NumJobs = 1
+ }
ex := &Executor{
rules: make(map[string]*Rule),
suffixRules: make(map[string][]*Rule),
done: make(map[string]*Job),
vars: vars,
- wm: NewWorkerManager(),
+ wm: NewWorkerManager(opt.NumJobs, opt.ParaPath),
}
// TODO: We should move this to somewhere around evalCmd so that
// we can handle SHELL in target specific variables.
- ev := newEvaluator(ex.vars)
+ ev := NewEvaluator(ex.vars)
ex.shell = ev.EvaluateVar("SHELL")
for k, v := range map[string]Var{
"@": AutoAtVar{AutoVar: AutoVar{ex: ex}},
@@ -275,7 +286,7 @@ func (ex *Executor) createRunners(n *DepNode, avoidIO bool) ([]runner, bool) {
ex.vars[k] = v
}
- ev := newEvaluator(ex.vars)
+ ev := NewEvaluator(ex.vars)
ev.avoidIO = avoidIO
ev.filename = n.Filename
ev.lineno = n.Lineno
@@ -297,7 +308,7 @@ func (ex *Executor) createRunners(n *DepNode, avoidIO bool) ([]runner, bool) {
func EvalCommands(nodes []*DepNode, vars Vars) {
ioCnt := 0
- ex := NewExecutor(vars)
+ ex := NewExecutor(vars, nil)
for i, n := range nodes {
runners, hasIO := ex.createRunners(n, true)
if hasIO {