Start sketching --depend support in rustc.

This commit is contained in:
Graydon Hoare 2011-05-03 15:50:56 -07:00
parent 6871c245a6
commit b453c3c728
3 changed files with 19 additions and 1 deletions

View File

@ -142,6 +142,7 @@ options:
--ls list the symbols defined by a crate file
-L <path> add a directory to the library search path
--noverify suppress LLVM verification step (slight speedup)
--depend print dependencies, in makefile-rule form
--parse-only parse only; do not compile, assemble, or link
-O optimize
-S compile only; do not assemble or link

View File

@ -24,8 +24,15 @@ tag val {
val_str(str);
}
tag eval_mode {
mode_depend;
mode_parse;
}
type env = vec[tup(ident, val)];
type ctx = @rec(parser p,
eval_mode mode,
mutable vec[str] deps,
session.session sess,
mutable uint chpos);
@ -383,6 +390,11 @@ fn eval_crate_directive(ctx cx,
auto full_path = prefix + std.fs.path_sep() + file_path;
if (cx.mode == mode_depend) {
cx.deps += vec(full_path);
ret;
}
auto start_id = cx.p.next_def_id();
auto p0 = new_parser(cx.sess, e, start_id, full_path, cx.chpos);
auto m0 = parse_mod_items(p0, token.EOF);

View File

@ -2497,7 +2497,12 @@ fn parse_crate_from_crate_file(parser p) -> @ast.crate {
auto lo = p.get_lo_pos();
auto prefix = std.fs.dirname(p.get_filemap().name);
auto cdirs = parse_crate_directives(p, token.EOF);
auto cx = @rec(p=p, sess=p.get_session(), mutable chpos=p.get_chpos());
let vec[str] deps = vec();
auto cx = @rec(p=p,
mode=eval.mode_parse,
mutable deps = deps,
sess=p.get_session(),
mutable chpos=p.get_chpos());
auto m = eval.eval_crate_directives_to_mod(cx, p.get_env(),
cdirs, prefix);
auto hi = p.get_hi_pos();