rustc: Actually hook the crate_type attribute into session

This commit is contained in:
Brian Anderson 2011-12-08 21:31:50 -08:00
parent 4f17131855
commit 54f72fbc10
2 changed files with 9 additions and 3 deletions

View file

@ -138,6 +138,8 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
time(time_passes, "parsing", bind parse_input(sess, cfg, input));
if sess.get_opts().parse_only { ret; }
sess.set_building_library(crate);
crate =
time(time_passes, "configuration",
bind front::config::strip_unconfigured_items(crate));
@ -492,7 +494,7 @@ fn build_session(sopts: @session::options) -> session::session {
sopts.addl_lib_search_paths);
ret session::session(target_cfg, sopts, cstore,
@{cm: codemap::new_codemap(), mutable next_id: 0},
none, 0u, filesearch);
none, 0u, filesearch, false);
}
fn parse_pretty(sess: session::session, &&name: str) -> pp_mode {

View file

@ -59,7 +59,8 @@ obj session(targ_cfg: @config,
// For a library crate, this is always none
mutable main_fn: option::t<node_id>,
mutable err_count: uint,
filesearch: filesearch::filesearch) {
filesearch: filesearch::filesearch,
mutable building_library: bool) {
fn get_targ_cfg() -> @config { ret targ_cfg; }
fn get_opts() -> @options { ret opts; }
fn get_cstore() -> metadata::cstore::cstore { cstore }
@ -118,7 +119,10 @@ obj session(targ_cfg: @config,
fn set_main_id(d: node_id) { main_fn = some(d); }
fn get_main_id() -> option::t<node_id> { main_fn }
fn filesearch() -> filesearch::filesearch { filesearch }
fn building_library() -> bool { opts.crate_type == lib_crate }
fn building_library() -> bool { building_library }
fn set_building_library(crate: @ast::crate) {
building_library = session::building_library(opts.crate_type, crate);
}
}
fn building_library(req_crate_type: crate_type, crate: @ast::crate) -> bool {