diff options
-rw-r--r-- | dep.go | 6 | ||||
-rw-r--r-- | exec.go | 2 | ||||
-rw-r--r-- | strutil.go | 10 | ||||
-rw-r--r-- | testcase/preserve_single_dot.mk | 7 |
4 files changed, 21 insertions, 4 deletions
@@ -333,7 +333,7 @@ func (db *DepBuilder) populateExplicitRule(rule *Rule) { return } for _, output := range rule.outputs { - output = filepath.Clean(output) + output = trimLeadingCurdir(output) isSuffixRule := db.populateSuffixRule(rule, output) @@ -361,10 +361,10 @@ func (db *DepBuilder) populateImplicitRule(rule *Rule) { func (db *DepBuilder) populateRules(er *EvalResult) { for _, rule := range er.rules { for i, input := range rule.inputs { - rule.inputs[i] = filepath.Clean(input) + rule.inputs[i] = trimLeadingCurdir(input) } for i, orderOnlyInput := range rule.orderOnlyInputs { - rule.orderOnlyInputs[i] = filepath.Clean(orderOnlyInput) + rule.orderOnlyInputs[i] = trimLeadingCurdir(orderOnlyInput) } db.populateExplicitRule(rule) @@ -224,7 +224,7 @@ func exitStatus(err error) int { func (ex *Executor) build(n *DepNode, neededBy string) (int64, error) { output := n.Output - Log("Building: %s", output) + Log("Building: %s for %s", output, neededBy) ex.buildCnt++ if ex.buildCnt%100 == 0 { ex.reportStats() @@ -162,3 +162,13 @@ func trimLeftSpaceBytes(s []byte) []byte { } return nil } + +// Strip leading sequences of './' from file names, so that ./file +// and file are considered to be the same file. +// From http://www.gnu.org/software/make/manual/make.html#Features +func trimLeadingCurdir(s string) string { + for strings.HasPrefix(s, "./") { + s = s[2:] + } + return s +} diff --git a/testcase/preserve_single_dot.mk b/testcase/preserve_single_dot.mk new file mode 100644 index 0000000..8229713 --- /dev/null +++ b/testcase/preserve_single_dot.mk @@ -0,0 +1,7 @@ +test: a/./b ./x + +a/./b: + echo $@ + +././x: + echo $@ |