Skip to content

rustc: have run_compiler bubble up compilation results #8009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,13 @@ pub fn compile_upto(sess: Session,
}

pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
outdir: &Option<Path>, output: &Option<Path>) {
outdir: &Option<Path>, output: &Option<Path>)
-> (Option<@ast::Crate>, Option<ty::ctxt>) {
let upto = if sess.opts.parse_only { cu_parse }
else if sess.opts.no_trans { cu_no_trans }
else { cu_everything };
let outputs = build_output_filenames(input, outdir, output, [], sess); // ???
compile_upto(sess, cfg, input, upto, Some(outputs));
compile_upto(sess, cfg, input, upto, Some(outputs))
}

pub fn pretty_print_input(sess: Session, cfg: ast::CrateConfig, input: &input,
Expand Down
22 changes: 12 additions & 10 deletions src/librustc/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use std::vec;
use extra::getopts::{groups, opt_present};
use extra::getopts;
use syntax::codemap;
use syntax::ast;
use syntax::diagnostic;

pub mod middle {
Expand Down Expand Up @@ -191,14 +192,15 @@ pub fn describe_debug_flags() {
}
}

pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter)
-> (Option<@ast::Crate>, Option<middle::ty::ctxt>) {
// Don't display log spew by default. Can override with RUST_LOG.
::std::logging::console_off();

let mut args = (*args).clone();
let binary = args.shift().to_managed();

if args.is_empty() { usage(binary); return; }
if args.is_empty() { usage(binary); return (None, None); }

let matches =
&match getopts::groups::getopts(args, optgroups()) {
Expand All @@ -210,7 +212,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {

if opt_present(matches, "h") || opt_present(matches, "help") {
usage(binary);
return;
return (None, None);
}

// Display the available lint options if "-W help" or only "-W" is given.
Expand All @@ -222,23 +224,23 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {

if show_lint_options {
describe_warnings();
return;
return (None, None);
}

let r = getopts::opt_strs(matches, "Z");
if r.iter().any(|x| x == &~"help") {
describe_debug_flags();
return;
return (None, None);
}

if getopts::opt_maybe_str(matches, "passes") == Some(~"list") {
back::passes::list_passes();
return;
return (None, None);
}

if opt_present(matches, "v") || opt_present(matches, "version") {
version(binary);
return;
return (None, None);
}
let input = match matches.free.len() {
0u => early_error(demitter, ~"no input filename given"),
Expand Down Expand Up @@ -266,7 +268,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
match pretty {
Some::<pp_mode>(ppm) => {
pretty_print_input(sess, cfg, &input, ppm);
return;
return (None, None);
}
None::<pp_mode> => {/* continue */ }
}
Expand All @@ -280,10 +282,10 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
early_error(demitter, ~"can not list metadata for stdin");
}
}
return;
return (None, None);
}

compile_input(sess, cfg, &input, &odir, &ofile);
compile_input(sess, cfg, &input, &odir, &ofile)
}

#[deriving(Eq)]
Expand Down