aboutsummaryrefslogtreecommitdiff
path: root/exec.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-07-09 12:41:32 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-07-09 12:41:32 +0900
commitba408a2a4926fbffd78f2aded988ee814ae962a1 (patch)
tree58819165415e33110406777540f5581d1582172d /exec.go
parent1394d10723c9bfbf43251efa1368417870b85948 (diff)
downloadkati-ba408a2a4926fbffd78f2aded988ee814ae962a1.tar.gz
change API
- remove isCached from DepGraph. - hide export, export handling will be done in Executor. - NewExecutor doesn't take Vars. - Executor.Exec takes *DepGraph.
Diffstat (limited to 'exec.go')
-rw-r--r--exec.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/exec.go b/exec.go
index 3ef09f4..d3f8e05 100644
--- a/exec.go
+++ b/exec.go
@@ -16,6 +16,7 @@ package kati
import (
"fmt"
+ "os"
"time"
)
@@ -129,7 +130,7 @@ type ExecutorOpt struct {
}
// NewExecutor creates new Executor.
-func NewExecutor(vars Vars, opt *ExecutorOpt) (*Executor, error) {
+func NewExecutor(opt *ExecutorOpt) (*Executor, error) {
if opt == nil {
opt = &ExecutorOpt{NumJobs: 1}
}
@@ -140,21 +141,34 @@ func NewExecutor(vars Vars, opt *ExecutorOpt) (*Executor, error) {
if err != nil {
return nil, err
}
- ctx := newExecContext(vars, false)
ex := &Executor{
rules: make(map[string]*rule),
suffixRules: make(map[string][]*rule),
done: make(map[string]*job),
wm: wm,
- ctx: ctx,
}
return ex, nil
}
// Exec executes to build roots.
-func (ex *Executor) Exec(roots []*DepNode) error {
+func (ex *Executor) Exec(g *DepGraph) error {
+ ex.ctx = newExecContext(g.vars, false)
+
+ // TODO: Handle target specific variables.
+ for name, export := range g.exports {
+ if export {
+ v, err := ex.ctx.ev.EvaluateVar(name)
+ if err != nil {
+ return err
+ }
+ os.Setenv(name, v)
+ } else {
+ os.Unsetenv(name)
+ }
+ }
+
startTime := time.Now()
- for _, root := range roots {
+ for _, root := range g.nodes {
err := ex.makeJobs(root, nil)
if err != nil {
break