about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-10-02 08:12:19 +0000
committerbors <bors@rust-lang.org>2014-10-02 08:12:19 +0000
commitdd7f00de801e4ca24c9c1235227ace4f998d4b1c (patch)
tree66d6d9c96b87da58eb72517cb921a3645cf14bfa
parent07b2c1be9dad53272575844efedfb7314fc4fb84 (diff)
parent2883b7682a06e19dcf8b669db1e34d0f4a83dc02 (diff)
downloadrust-dd7f00de801e4ca24c9c1235227ace4f998d4b1c.tar.gz
rust-dd7f00de801e4ca24c9c1235227ace4f998d4b1c.zip
auto merge of #17681 : jgallagher/rust/dep-info-escape-spaces, r=alexcrichton
cc #17627 
-rw-r--r--mk/tests.mk13
-rw-r--r--src/librustc/driver/driver.rs8
-rw-r--r--src/test/run-make/dep-info-spaces/Makefile25
-rw-r--r--src/test/run-make/dep-info-spaces/Makefile.foo7
-rw-r--r--src/test/run-make/dep-info-spaces/bar.rs11
-rw-r--r--src/test/run-make/dep-info-spaces/foo foo.rs11
-rw-r--r--src/test/run-make/dep-info-spaces/lib.rs14
7 files changed, 82 insertions, 7 deletions
diff --git a/mk/tests.mk b/mk/tests.mk
index a872395855b..fe2c4cb4151 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -261,12 +261,13 @@ ALL_HS := $(filter-out $(S)src/rt/valgrind/valgrind.h \
 tidy:
 		@$(call E, check: formatting)
 		$(Q)find $(S)src -name '*.r[sc]' \
-		| grep '^$(S)src/jemalloc' -v \
-		| grep '^$(S)src/libuv' -v \
-		| grep '^$(S)src/llvm' -v \
-		| grep '^$(S)src/gyp' -v \
-		| grep '^$(S)src/libbacktrace' -v \
-		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
+		    -and -not -regex '^$(S)src/jemalloc.*' \
+		    -and -not -regex '^$(S)src/libuv.*' \
+		    -and -not -regex '^$(S)src/llvm.*' \
+		    -and -not -regex '^$(S)src/gyp.*' \
+		    -and -not -regex '^$(S)src/libbacktrace.*' \
+		    -print0 \
+		| xargs -0 -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
 		$(Q)find $(S)src/etc -name '*.py' \
 		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
 		$(Q)find $(S)src/doc -name '*.js' \
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs
index e81df63a67e..ed808611698 100644
--- a/src/librustc/driver/driver.rs
+++ b/src/librustc/driver/driver.rs
@@ -616,6 +616,12 @@ pub fn stop_after_phase_5(sess: &Session) -> bool {
     return false;
 }
 
+fn escape_dep_filename(filename: &str) -> String {
+    // Apparently clang and gcc *only* escape spaces:
+    // http://llvm.org/klaus/clang/commit/9d50634cfc268ecc9a7250226dd5ca0e945240d4
+    filename.replace(" ", "\\ ")
+}
+
 fn write_out_deps(sess: &Session,
                   input: &Input,
                   outputs: &OutputFilenames,
@@ -659,7 +665,7 @@ fn write_out_deps(sess: &Session,
         // write Makefile-compatible dependency rules
         let files: Vec<String> = sess.codemap().files.borrow()
                                    .iter().filter(|fmap| fmap.is_real_file())
-                                   .map(|fmap| fmap.name.to_string())
+                                   .map(|fmap| escape_dep_filename(fmap.name.as_slice()))
                                    .collect();
         let mut file = try!(io::File::create(&deps_filename));
         for path in out_filenames.iter() {
diff --git a/src/test/run-make/dep-info-spaces/Makefile b/src/test/run-make/dep-info-spaces/Makefile
new file mode 100644
index 00000000000..72dca3d3c90
--- /dev/null
+++ b/src/test/run-make/dep-info-spaces/Makefile
@@ -0,0 +1,25 @@
+-include ../tools.mk
+
+# FIXME: ignore freebsd/windows
+# (windows: see `../dep-info/Makefile`)
+ifneq ($(shell uname),FreeBSD)
+ifndef IS_WINDOWS
+all:
+	$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
+	sleep 1
+	touch 'foo foo.rs'
+	-rm -f $(TMPDIR)/done
+	$(MAKE) -drf Makefile.foo
+	rm $(TMPDIR)/done
+	pwd
+	$(MAKE) -drf Makefile.foo
+	rm $(TMPDIR)/done && exit 1 || exit 0
+else
+all:
+
+endif
+
+else
+all:
+
+endif
diff --git a/src/test/run-make/dep-info-spaces/Makefile.foo b/src/test/run-make/dep-info-spaces/Makefile.foo
new file mode 100644
index 00000000000..0e187565d6d
--- /dev/null
+++ b/src/test/run-make/dep-info-spaces/Makefile.foo
@@ -0,0 +1,7 @@
+LIB := $(shell $(RUSTC) --print-file-name --crate-type=lib lib.rs)
+
+$(TMPDIR)/$(LIB):
+	$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
+	touch $(TMPDIR)/done
+
+-include $(TMPDIR)/custom-deps-file.d
diff --git a/src/test/run-make/dep-info-spaces/bar.rs b/src/test/run-make/dep-info-spaces/bar.rs
new file mode 100644
index 00000000000..4c79f7e2855
--- /dev/null
+++ b/src/test/run-make/dep-info-spaces/bar.rs
@@ -0,0 +1,11 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub fn bar() {}
diff --git a/src/test/run-make/dep-info-spaces/foo foo.rs b/src/test/run-make/dep-info-spaces/foo foo.rs
new file mode 100644
index 00000000000..2661b1f4eb4
--- /dev/null
+++ b/src/test/run-make/dep-info-spaces/foo foo.rs
@@ -0,0 +1,11 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub fn foo() {}
diff --git a/src/test/run-make/dep-info-spaces/lib.rs b/src/test/run-make/dep-info-spaces/lib.rs
new file mode 100644
index 00000000000..bfbe41baeac
--- /dev/null
+++ b/src/test/run-make/dep-info-spaces/lib.rs
@@ -0,0 +1,14 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[path="foo foo.rs"]
+pub mod foo;
+
+pub mod bar;