Skip to content

Commit dd7f00d

Browse files
committed
auto merge of #17681 : jgallagher/rust/dep-info-escape-spaces, r=alexcrichton
cc #17627
2 parents 07b2c1b + 2883b76 commit dd7f00d

File tree

7 files changed

+82
-7
lines changed

7 files changed

+82
-7
lines changed

mk/tests.mk

+7-6
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,13 @@ ALL_HS := $(filter-out $(S)src/rt/valgrind/valgrind.h \
261261
tidy:
262262
@$(call E, check: formatting)
263263
$(Q)find $(S)src -name '*.r[sc]' \
264-
| grep '^$(S)src/jemalloc' -v \
265-
| grep '^$(S)src/libuv' -v \
266-
| grep '^$(S)src/llvm' -v \
267-
| grep '^$(S)src/gyp' -v \
268-
| grep '^$(S)src/libbacktrace' -v \
269-
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
264+
-and -not -regex '^$(S)src/jemalloc.*' \
265+
-and -not -regex '^$(S)src/libuv.*' \
266+
-and -not -regex '^$(S)src/llvm.*' \
267+
-and -not -regex '^$(S)src/gyp.*' \
268+
-and -not -regex '^$(S)src/libbacktrace.*' \
269+
-print0 \
270+
| xargs -0 -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
270271
$(Q)find $(S)src/etc -name '*.py' \
271272
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
272273
$(Q)find $(S)src/doc -name '*.js' \

src/librustc/driver/driver.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,12 @@ pub fn stop_after_phase_5(sess: &Session) -> bool {
616616
return false;
617617
}
618618

619+
fn escape_dep_filename(filename: &str) -> String {
620+
// Apparently clang and gcc *only* escape spaces:
621+
// http://llvm.org/klaus/clang/commit/9d50634cfc268ecc9a7250226dd5ca0e945240d4
622+
filename.replace(" ", "\\ ")
623+
}
624+
619625
fn write_out_deps(sess: &Session,
620626
input: &Input,
621627
outputs: &OutputFilenames,
@@ -659,7 +665,7 @@ fn write_out_deps(sess: &Session,
659665
// write Makefile-compatible dependency rules
660666
let files: Vec<String> = sess.codemap().files.borrow()
661667
.iter().filter(|fmap| fmap.is_real_file())
662-
.map(|fmap| fmap.name.to_string())
668+
.map(|fmap| escape_dep_filename(fmap.name.as_slice()))
663669
.collect();
664670
let mut file = try!(io::File::create(&deps_filename));
665671
for path in out_filenames.iter() {
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-include ../tools.mk
2+
3+
# FIXME: ignore freebsd/windows
4+
# (windows: see `../dep-info/Makefile`)
5+
ifneq ($(shell uname),FreeBSD)
6+
ifndef IS_WINDOWS
7+
all:
8+
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
9+
sleep 1
10+
touch 'foo foo.rs'
11+
-rm -f $(TMPDIR)/done
12+
$(MAKE) -drf Makefile.foo
13+
rm $(TMPDIR)/done
14+
pwd
15+
$(MAKE) -drf Makefile.foo
16+
rm $(TMPDIR)/done && exit 1 || exit 0
17+
else
18+
all:
19+
20+
endif
21+
22+
else
23+
all:
24+
25+
endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
LIB := $(shell $(RUSTC) --print-file-name --crate-type=lib lib.rs)
2+
3+
$(TMPDIR)/$(LIB):
4+
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
5+
touch $(TMPDIR)/done
6+
7+
-include $(TMPDIR)/custom-deps-file.d
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn bar() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn foo() {}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[path="foo foo.rs"]
12+
pub mod foo;
13+
14+
pub mod bar;

0 commit comments

Comments
 (0)