aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dep.go6
-rw-r--r--exec.go2
-rw-r--r--strutil.go10
-rw-r--r--testcase/preserve_single_dot.mk7
4 files changed, 21 insertions, 4 deletions
diff --git a/dep.go b/dep.go
index a6bcba3..7d35d38 100644
--- a/dep.go
+++ b/dep.go
@@ -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)
diff --git a/exec.go b/exec.go
index 3c0afba..02dc239 100644
--- a/exec.go
+++ b/exec.go
@@ -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()
diff --git a/strutil.go b/strutil.go
index 03d29d0..4be8f66 100644
--- a/strutil.go
+++ b/strutil.go
@@ -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 $@