aboutsummaryrefslogtreecommitdiff
path: root/dep.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-04-22 23:27:18 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-04-22 23:27:58 +0900
commitab431e2847071432953a10e463d2e2e62a34d51e (patch)
tree0c7060632aa28617c0e0ea1ffe9eab9569a9a503 /dep.go
parentf4d3ee5b3dfcb6ef7052b29e6f08c022cc2aae54 (diff)
downloadkati-ab431e2847071432953a10e463d2e2e62a34d51e.tar.gz
fix phony
Diffstat (limited to 'dep.go')
-rw-r--r--dep.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/dep.go b/dep.go
index 7d35d38..b227329 100644
--- a/dep.go
+++ b/dep.go
@@ -12,6 +12,7 @@ type DepNode struct {
Deps []*DepNode
HasRule bool
IsOrderOnly bool
+ IsPhony bool
ActualInputs []string
TargetSpecificVars Vars
Filename string
@@ -19,8 +20,8 @@ type DepNode struct {
}
func (n *DepNode) String() string {
- return fmt.Sprintf("Dep{output=%s cmds=%d deps=%d hasRule=%t orderOnly=%t, filename=%s lineno=%d}",
- n.Output, len(n.Cmds), len(n.Deps), n.HasRule, n.IsOrderOnly, n.Filename, n.Lineno)
+ return fmt.Sprintf("Dep{output=%s cmds=%d deps=%d hasRule=%t orderOnly=%t, phony=%t filename=%s lineno=%d}",
+ n.Output, len(n.Cmds), len(n.Deps), n.HasRule, n.IsOrderOnly, n.IsPhony, n.Filename, n.Lineno)
}
type DepBuilder struct {
@@ -31,6 +32,7 @@ type DepBuilder struct {
firstRule *Rule
vars Vars
done map[string]*DepNode
+ phony map[string]bool
trace []string
nodeCnt int
@@ -52,13 +54,8 @@ func (db *DepBuilder) exists(target string) bool {
if present {
return true
}
- rule, present := db.rules[".PHONY"]
- if present {
- for _, input := range rule.inputs {
- if target == input {
- return true
- }
- }
+ if db.phony[target] {
+ return true
}
return exists(target)
}
@@ -179,9 +176,11 @@ func (db *DepBuilder) buildPlan(output string, neededBy string, tsvs Vars) (*Dep
if n, present := db.done[output]; present {
return n, nil
}
- n := &DepNode{Output: output}
+
+ n := &DepNode{Output: output, IsPhony: db.phony[output]}
db.done[output] = n
+ // create depnode for phony targets?
rule, vars, present := db.pickRule(output)
if !present {
return n, nil
@@ -403,9 +402,16 @@ func NewDepBuilder(er *EvalResult, vars Vars) *DepBuilder {
suffixRules: make(map[string][]*Rule),
vars: vars,
done: make(map[string]*DepNode),
+ phony: make(map[string]bool),
}
db.populateRules(er)
+ rule, present := db.rules[".PHONY"]
+ if present {
+ for _, input := range rule.inputs {
+ db.phony[input] = true
+ }
+ }
return db
}