From 39774e88b42409c3a432a8426cfef253f67d7709 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 7 Apr 2011 20:20:57 +0200 Subject: Add a very basic crate-dump utility 'rustc -ls [cratelib]' will now dump out a list of symbols defined by the crate, as well as a short description of what they are. --- src/comp/driver/rustc.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/comp/driver/rustc.rs') diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 36827b73..928c934a 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -98,6 +98,7 @@ fn usage(session.session sess, str argv0) { log " -glue generate glue.bc file"; log " -shared compile a shared-library crate"; log " -pp pretty-print the input instead of compiling"; + log " -ls list the symbols defined by a crate file"; log " -L add a directory to the library search path"; log " -h display this message"; log ""; @@ -130,6 +131,7 @@ impure fn main(vec[str] args) { let bool do_warn = true; let bool shared = false; let bool pretty = false; + let bool ls = false; let bool glue = false; // FIXME: Maybe we should support -O0, -O1, -Os, etc @@ -152,6 +154,8 @@ impure fn main(vec[str] args) { shared = true; } else if (_str.eq(arg, "-pp")) { pretty = true; + } else if (_str.eq(arg, "-ls")) { + ls = true; } else if (_str.eq(arg, "-o")) { if (i+1u < len) { output_file = some(args.(i+1u)); @@ -214,8 +218,9 @@ impure fn main(vec[str] args) { auto env = default_environment(sess, args.(0), ifile); if (pretty) { pretty_print_input(sess, env, ifile); - } - else { + } else if (ls) { + front.creader.list_file_metadata(ifile, std.io.stdout()); + } else { alt (output_file) { case (none[str]) { let vec[str] parts = _str.split(ifile, '.' as u8); -- cgit v1.2.3