Skip to content

Commit b453c3c

Browse files
committed
Start sketching --depend support in rustc.
1 parent 6871c24 commit b453c3c

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/comp/driver/rustc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ options:
142142
--ls list the symbols defined by a crate file
143143
-L <path> add a directory to the library search path
144144
--noverify suppress LLVM verification step (slight speedup)
145+
--depend print dependencies, in makefile-rule form
145146
--parse-only parse only; do not compile, assemble, or link
146147
-O optimize
147148
-S compile only; do not assemble or link

src/comp/front/eval.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ tag val {
2424
val_str(str);
2525
}
2626

27+
tag eval_mode {
28+
mode_depend;
29+
mode_parse;
30+
}
31+
2732
type env = vec[tup(ident, val)];
2833
type ctx = @rec(parser p,
34+
eval_mode mode,
35+
mutable vec[str] deps,
2936
session.session sess,
3037
mutable uint chpos);
3138

@@ -383,6 +390,11 @@ fn eval_crate_directive(ctx cx,
383390

384391
auto full_path = prefix + std.fs.path_sep() + file_path;
385392

393+
if (cx.mode == mode_depend) {
394+
cx.deps += vec(full_path);
395+
ret;
396+
}
397+
386398
auto start_id = cx.p.next_def_id();
387399
auto p0 = new_parser(cx.sess, e, start_id, full_path, cx.chpos);
388400
auto m0 = parse_mod_items(p0, token.EOF);

src/comp/front/parser.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2497,7 +2497,12 @@ fn parse_crate_from_crate_file(parser p) -> @ast.crate {
24972497
auto lo = p.get_lo_pos();
24982498
auto prefix = std.fs.dirname(p.get_filemap().name);
24992499
auto cdirs = parse_crate_directives(p, token.EOF);
2500-
auto cx = @rec(p=p, sess=p.get_session(), mutable chpos=p.get_chpos());
2500+
let vec[str] deps = vec();
2501+
auto cx = @rec(p=p,
2502+
mode=eval.mode_parse,
2503+
mutable deps = deps,
2504+
sess=p.get_session(),
2505+
mutable chpos=p.get_chpos());
25012506
auto m = eval.eval_crate_directives_to_mod(cx, p.get_env(),
25022507
cdirs, prefix);
25032508
auto hi = p.get_hi_pos();

0 commit comments

Comments
 (0)