aboutsummaryrefslogtreecommitdiffstats
path: root/exec.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-07-16 16:55:51 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-07-16 16:55:51 +0900
commite4574695494bfca030d74309bf149d965dbe093f (patch)
tree3db49fb14d190f28b4605cb8eb1cfdb89762b604 /exec.go
parentb79b29005ce03ac1d93f8bd3f3d248ee32b49093 (diff)
downloadandroid_build_kati-e4574695494bfca030d74309bf149d965dbe093f.tar.gz
android_build_kati-e4574695494bfca030d74309bf149d965dbe093f.tar.bz2
android_build_kati-e4574695494bfca030d74309bf149d965dbe093f.zip
[go] build specified targets or first target if not given.
Diffstat (limited to 'exec.go')
-rw-r--r--exec.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/exec.go b/exec.go
index 8aa7a0e..adf1c10 100644
--- a/exec.go
+++ b/exec.go
@@ -151,8 +151,8 @@ func NewExecutor(opt *ExecutorOpt) (*Executor, error) {
return ex, nil
}
-// Exec executes to build roots.
-func (ex *Executor) Exec(g *DepGraph) error {
+// Exec executes to build targets, or first target in DepGraph.
+func (ex *Executor) Exec(g *DepGraph, targets []string) error {
ex.ctx = newExecContext(g.vars, g.vpaths, false)
// TODO: Handle target specific variables.
@@ -169,7 +169,24 @@ func (ex *Executor) Exec(g *DepGraph) error {
}
startTime := time.Now()
- for _, root := range g.nodes {
+ var nodes []*DepNode
+ if len(targets) == 0 {
+ if len(g.nodes) > 0 {
+ nodes = append(nodes, g.nodes[0])
+ }
+ } else {
+ m := make(map[string]*DepNode)
+ for _, n := range g.nodes {
+ m[n.Output] = n
+ }
+ for _, t := range targets {
+ n := m[t]
+ if n != nil {
+ nodes = append(nodes, n)
+ }
+ }
+ }
+ for _, root := range nodes {
err := ex.makeJobs(root, nil)
if err != nil {
break