diff options
-rw-r--r-- | exec.go | 24 | ||||
-rw-r--r-- | rule_parser.go | 5 | ||||
-rw-r--r-- | test/multi_outputs.mk | 4 |
3 files changed, 19 insertions, 14 deletions
@@ -99,22 +99,24 @@ func (ex *Executor) exec(er *EvalResult, targets []string) error { } for _, rule := range er.rules { - if oldRule, present := ex.rules[rule.output]; present { - if len(oldRule.cmds) > 0 && len(rule.cmds) > 0 { - Warn(rule.filename, rule.cmdLineno, "overriding commands for target %q", rule.output) - Warn(oldRule.filename, oldRule.cmdLineno, "ignoring old commands for target %q", oldRule.output) + for _, output := range rule.outputs { + if oldRule, present := ex.rules[output]; present { + if len(oldRule.cmds) > 0 && len(rule.cmds) > 0 { + Warn(rule.filename, rule.cmdLineno, "overriding commands for target %q", output) + Warn(oldRule.filename, oldRule.cmdLineno, "ignoring old commands for target %q", output) + } + r := &Rule{} + *r = *rule + r.inputs = append(r.inputs, oldRule.inputs...) + ex.rules[output] = r + } else { + ex.rules[output] = rule } - r := &Rule{} - *r = *rule - r.inputs = append(r.inputs, oldRule.inputs...) - ex.rules[rule.output] = r - } else { - ex.rules[rule.output] = rule } } if len(targets) == 0 { - targets = append(targets, er.rules[0].output) + targets = append(targets, er.rules[0].outputs[0]) } for _, target := range targets { diff --git a/rule_parser.go b/rule_parser.go index 9c83fd8..ce74878 100644 --- a/rule_parser.go +++ b/rule_parser.go @@ -5,7 +5,7 @@ import ( ) type Rule struct { - output string + outputs []string inputs []string cmds []string filename string @@ -19,7 +19,6 @@ func (r *Rule) parse(line string) { Error(r.filename, r.lineno, "*** missing separator.") } - lhs := line[:colonIndex] - r.output = lhs + r.outputs = splitSpaces(line[:colonIndex]) r.inputs = splitSpaces(line[colonIndex+1:]) } diff --git a/test/multi_outputs.mk b/test/multi_outputs.mk new file mode 100644 index 0000000..394e585 --- /dev/null +++ b/test/multi_outputs.mk @@ -0,0 +1,4 @@ +test: foo bar + +foo bar baz: + echo PASS_$@ |