diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-10-03 12:46:22 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-10-04 21:35:06 -0700 |
| commit | d91b7b61eff9a9fdf8506f7d1b41fde47071503c (patch) | |
| tree | 8ef6286c1070ebf6edbef1368ff24cafdcb7d1b4 /src/comp/driver | |
| parent | a8ce543dc937043f2988a856c0c43339eadf8d69 (diff) | |
| download | rust-d91b7b61eff9a9fdf8506f7d1b41fde47071503c.tar.gz rust-d91b7b61eff9a9fdf8506f7d1b41fde47071503c.zip | |
Encapsulate current sysroot and lib path handling into util::filesearch
Diffstat (limited to 'src/comp/driver')
| -rw-r--r-- | src/comp/driver/rustc.rs | 39 | ||||
| -rw-r--r-- | src/comp/driver/session.rs | 9 |
2 files changed, 21 insertions, 27 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index de9862f9e5e..70007240b63 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -8,7 +8,7 @@ import front::attr; import middle::{trans, resolve, freevars, kind, ty, typeck}; import middle::tstate::ck; import syntax::print::{pp, pprust}; -import util::{ppaux, common}; +import util::{ppaux, common, filesearch}; import back::link; import lib::llvm; import std::{fs, option, str, vec, int, io, run, getopts}; @@ -293,12 +293,6 @@ fn get_arch(triple: str) -> session::arch { } else { log_err "Unknown architecture! " + triple; fail }; } -fn get_default_sysroot(binary: str) -> str { - let dirname = fs::dirname(binary); - if str::eq(dirname, binary) { ret "../"; } - ret fs::connect(dirname, "../"); -} - fn build_target_config(sopts: @session::options) -> @session::config { let target_cfg: @session::config = @{os: get_os(sopts.target_triple), @@ -321,7 +315,7 @@ fn host_triple() -> str { ret ht != "" ? ht : fail "rustc built without CFG_HOST_TRIPLE"; } -fn build_session_options(binary: str, match: getopts::match) +fn build_session_options(match: getopts::match) -> @session::options { let library = opt_present(match, "lib"); let static = opt_present(match, "static"); @@ -368,22 +362,13 @@ fn build_session_options(binary: str, match: getopts::match) } } } else { 0u }; - let sysroot = - alt sysroot_opt { - none. { get_default_sysroot(binary) } - some(s) { s } - }; let target = alt target_opt { none. { host_triple() } some(s) { s } }; - let library_search_paths = [link::make_target_lib_path(sysroot, target)]; - let lsp_vec = getopts::opt_strs(match, "L"); - // FIXME: These should probably go in front of the defaults - for lsp: str in lsp_vec { library_search_paths += [lsp]; } - + let addl_lib_search_paths = getopts::opt_strs(match, "L"); let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg")); let test = opt_present(match, "test"); let do_gc = opt_present(match, "gc"); @@ -400,8 +385,8 @@ fn build_session_options(binary: str, match: getopts::match) time_passes: time_passes, time_llvm_passes: time_llvm_passes, output_type: output_type, - library_search_paths: library_search_paths, - sysroot: sysroot, + addl_lib_search_paths: addl_lib_search_paths, + maybe_sysroot: sysroot_opt, target_triple: target, cfg: cfg, test: test, @@ -412,12 +397,18 @@ fn build_session_options(binary: str, match: getopts::match) ret sopts; } -fn build_session(sopts: @session::options) -> session::session { +fn build_session(binary: str, + sopts: @session::options) -> session::session { let target_cfg = build_target_config(sopts); let cstore = cstore::mk_cstore(); + let filesearch = filesearch::mk_filesearch( + binary, + sopts.maybe_sysroot, + sopts.target_triple, + sopts.addl_lib_search_paths); ret session::session(target_cfg, sopts, cstore, @{cm: codemap::new_codemap(), mutable next_id: 0}, - none, 0u); + none, 0u, filesearch); } fn parse_pretty(sess: session::session, name: str) -> pp_mode { @@ -464,8 +455,8 @@ fn main(args: [str]) { version(binary); ret; } - let sopts = build_session_options(binary, match); - let sess = build_session(sopts); + let sopts = build_session_options(match); + let sess = build_session(binary, sopts); let n_inputs = vec::len::<str>(match.free); let output_file = getopts::opt_maybe_str(match, "o"); if n_inputs == 0u { diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs index 001bc9ce2fb..1f3f9baab8a 100644 --- a/src/comp/driver/session.rs +++ b/src/comp/driver/session.rs @@ -6,6 +6,7 @@ import syntax::ast::ty_mach; import std::{uint, map, option, str}; import std::option::{some, none}; import syntax::parse::parser::parse_sess; +import util::filesearch; tag os { os_win32; os_macos; os_linux; } @@ -32,8 +33,8 @@ type options = time_passes: bool, time_llvm_passes: bool, output_type: back::link::output_type, - library_search_paths: [str], - sysroot: str, + addl_lib_search_paths: [str], + maybe_sysroot: option::t<str>, target_triple: str, cfg: ast::crate_cfg, test: bool, @@ -51,7 +52,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) { + mutable err_count: uint, + filesearch: filesearch::filesearch) { fn get_targ_cfg() -> @config { ret targ_cfg; } fn get_opts() -> @options { ret opts; } fn get_cstore() -> metadata::cstore::cstore { cstore } @@ -108,6 +110,7 @@ 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 } } // Local Variables: // fill-column: 78; |
