Skip to content

Commit a995921

Browse files
committed
---
yaml --- r: 147413 b: refs/heads/try2 c: 66e3fbe h: refs/heads/master i: 147411: cd66a27 v: v3
1 parent f11c298 commit a995921

File tree

9 files changed

+60
-25
lines changed

9 files changed

+60
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 5d0fea144181eb8504852b664ff44543a429969e
8+
refs/heads/try2: 66e3fbebd9b2c7061c139e601e73067e4b3feb5b
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/driver/driver.rs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -393,24 +393,33 @@ pub fn phase_6_link_output(sess: Session,
393393
&outputs.out_filename,
394394
&trans.link));
395395

396-
// Write out dependency rules to the .d file if requested
397-
if sess.opts.write_dependency_info {
398-
match *input {
396+
// Write out dependency rules to the dep-info file if requested with --dep-info
397+
let deps_filename = match sess.opts.write_dependency_info {
398+
// Use filename from --dep-file argument if given
399+
(true, Some(ref filename)) => filename.clone(),
400+
// Use default filename: crate source filename with extension replaced by ".d"
401+
(true, None) => match *input {
399402
file_input(ref input_path) => {
400-
let files: ~[@str] = sess.codemap.files.iter()
401-
.filter_map(|fmap| if fmap.is_real_file() { Some(fmap.name) } else { None })
402-
.collect();
403-
let mut output_path = outputs[0].dir_path();
404403
let filestem = input_path.filestem().expect("input file must have stem");
405-
output_path.push(Path::new(filestem).with_extension("d"));
406-
let mut file = io::File::create(&output_path);
407-
for output in outputs.iter() {
408-
write!(&mut file as &mut Writer,
409-
"{}: {}\n\n", output.display(), files.connect(" "));
410-
}
411-
}
412-
str_input(_) => {}
413-
}
404+
let filename = outputs[0].dir_path().join(filestem).with_extension("d");
405+
filename
406+
},
407+
str_input(..) => {
408+
sess.warn("can not write --dep-info without a filename when compiling stdin.");
409+
return;
410+
},
411+
},
412+
_ => return,
413+
};
414+
// Build a list of files used to compile the output and
415+
// write Makefile-compatible dependency rules
416+
let files: ~[@str] = sess.codemap.files.iter()
417+
.filter_map(|fmap| if fmap.is_real_file() { Some(fmap.name) } else { None })
418+
.collect();
419+
let mut file = io::File::create(&deps_filename);
420+
for output in outputs.iter() {
421+
write!(&mut file as &mut Writer,
422+
"{}: {}\n\n", output.display(), files.connect(" "));
414423
}
415424
}
416425

@@ -771,7 +780,8 @@ pub fn build_session_options(binary: @str,
771780
let cfg = parse_cfgspecs(matches.opt_strs("cfg"), demitter);
772781
let test = matches.opt_present("test");
773782
let android_cross_path = matches.opt_str("android-cross-path");
774-
let write_dependency_info = matches.opt_present("dep-info");
783+
let write_dependency_info = (matches.opt_present("dep-info"),
784+
matches.opt_str("dep-info").map(|p| Path::new(p)));
775785

776786
let custom_passes = match matches.opt_str("passes") {
777787
None => ~[],
@@ -933,8 +943,8 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
933943
or identified (fully parenthesized,
934944
AST nodes and blocks with IDs)", "TYPE"),
935945
optflag("S", "", "Compile only; do not assemble or link"),
936-
optflag("", "dep-info",
937-
"Output dependency info to .d file after compiling"),
946+
optflagopt("", "dep-info",
947+
"Output dependency info to <filename> after compiling", "FILENAME"),
938948
optflag("", "save-temps",
939949
"Write intermediate files (.bc, .opt.bc, .o)
940950
in addition to normal output"),

branches/try2/src/librustc/driver/session.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ pub struct options {
168168
no_trans: bool,
169169
debugging_opts: uint,
170170
android_cross_path: Option<~str>,
171-
/// Whether to write .d dependency files
172-
write_dependency_info: bool,
171+
/// Whether to write dependency files. It's (enabled, optional filename).
172+
write_dependency_info: (bool, Option<Path>),
173173
/// Crate id-related things to maybe print. It's (crate_id, crate_name, crate_file_name).
174174
print_metas: (bool, bool, bool),
175175
}
@@ -397,7 +397,7 @@ pub fn basic_options() -> @options {
397397
no_trans: false,
398398
debugging_opts: 0u,
399399
android_cross_path: None,
400-
write_dependency_info: false,
400+
write_dependency_info: (false, None),
401401
print_metas: (false, false, false),
402402
}
403403
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --lib lib.rs
5+
sleep 1
6+
touch foo.rs
7+
-rm -f $(TMPDIR)/done
8+
$(MAKE) -drf Makefile.foo
9+
rm $(TMPDIR)/done
10+
pwd
11+
$(MAKE) -drf Makefile.foo
12+
rm $(TMPDIR)/done && exit 1 || exit 0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
LIB := $(shell $(RUSTC) --crate-file-name --lib lib.rs)
2+
3+
$(TMPDIR)/$(LIB):
4+
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --lib lib.rs
5+
touch $(TMPDIR)/done
6+
7+
-include $(TMPDIR)/custom-deps-file.d
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn bar() {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn foo() {}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[crate_id="foo#0.1"];
2+
3+
pub mod foo;
4+
pub mod bar;

branches/try2/src/test/run-make/dep-info/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ all:
55
sleep 1
66
touch foo.rs
77
-rm -f $(TMPDIR)/done
8-
$(MAKE) -f Makefile.foo
8+
$(MAKE) -drf Makefile.foo
99
rm $(TMPDIR)/done
1010
pwd
11-
$(MAKE) -df Makefile.foo
11+
$(MAKE) -drf Makefile.foo
1212
rm $(TMPDIR)/done && exit 1 || exit 0

0 commit comments

Comments
 (0)