fix target_specific_var
diff --git a/exec.go b/exec.go
index 15c1e5f..4fed885 100644
--- a/exec.go
+++ b/exec.go
@@ -152,6 +152,12 @@
}
return outputTs, fmt.Errorf("no rule to make target %q", output)
}
+ if rule.vars != nil {
+ vars = NewVarTab(vars)
+ for k, v := range rule.vars.m {
+ vars.Assign(k, v)
+ }
+ }
latest := int64(-1)
var actualInputs []string
@@ -260,6 +266,20 @@
isSuffixRule := ex.populateSuffixRule(rule, output)
if oldRule, present := ex.rules[output]; present {
+ if oldRule.vars != nil || rule.vars != nil {
+ oldRule.isDoubleColon = rule.isDoubleColon
+ switch {
+ case rule.vars == nil && oldRule.vars != nil:
+ rule.vars = oldRule.vars
+ case rule.vars != nil && oldRule.vars == nil:
+ case rule.vars != nil && oldRule.vars != nil:
+ // parent would be the same vars?
+ for k, v := range rule.vars.m {
+ oldRule.vars.m[k] = v
+ }
+ rule.vars = oldRule.vars
+ }
+ }
if oldRule.isDoubleColon != rule.isDoubleColon {
Error(rule.filename, rule.lineno, "*** target file %q has both : and :: entries.", output)
}