Use std::os::get_exe_path to determine sysroot
This commit is contained in:
parent
1391154b14
commit
1f2e999262
src/comp
@ -397,12 +397,10 @@ fn build_session_options(match: getopts::match)
|
||||
ret sopts;
|
||||
}
|
||||
|
||||
fn build_session(binary: str,
|
||||
sopts: @session::options) -> session::session {
|
||||
fn build_session(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);
|
||||
@ -456,7 +454,7 @@ fn main(args: [str]) {
|
||||
ret;
|
||||
}
|
||||
let sopts = build_session_options(match);
|
||||
let sess = build_session(binary, sopts);
|
||||
let sess = build_session(sopts);
|
||||
let n_inputs = vec::len::<str>(match.free);
|
||||
let output_file = getopts::opt_maybe_str(match, "o");
|
||||
if n_inputs == 0u {
|
||||
@ -537,7 +535,7 @@ mod test {
|
||||
getopts::success(m) { m }
|
||||
};
|
||||
let sessopts = build_session_options(match);
|
||||
let sess = build_session("whatever", sessopts);
|
||||
let sess = build_session(sessopts);
|
||||
let cfg = build_configuration(sess, "whatever", "whatever");
|
||||
assert (attr::contains_name(cfg, "test"));
|
||||
}
|
||||
@ -551,7 +549,7 @@ mod test {
|
||||
getopts::success(m) { m }
|
||||
};
|
||||
let sessopts = build_session_options(match);
|
||||
let sess = build_session("whatever", sessopts);
|
||||
let sess = build_session(sessopts);
|
||||
let cfg = build_configuration(sess, "whatever", "whatever");
|
||||
let test_items = attr::find_meta_items_by_name(cfg, "test");
|
||||
assert (vec::len(test_items) == 1u);
|
||||
|
@ -4,6 +4,7 @@ import std::option;
|
||||
import std::fs;
|
||||
import std::vec;
|
||||
import std::str;
|
||||
import std::os;
|
||||
import back::link;
|
||||
|
||||
export filesearch;
|
||||
@ -26,8 +27,7 @@ type filesearch = obj {
|
||||
fn get_target_lib_file_path(file: fs::path) -> fs::path;
|
||||
};
|
||||
|
||||
fn mk_filesearch(binary_name: fs::path,
|
||||
maybe_sysroot: option::t<fs::path>,
|
||||
fn mk_filesearch(maybe_sysroot: option::t<fs::path>,
|
||||
target_triple: str,
|
||||
addl_lib_search_paths: [fs::path]) -> filesearch {
|
||||
obj filesearch_impl(sysroot: fs::path,
|
||||
@ -48,7 +48,7 @@ fn mk_filesearch(binary_name: fs::path,
|
||||
}
|
||||
}
|
||||
|
||||
let sysroot = get_sysroot(maybe_sysroot, binary_name);
|
||||
let sysroot = get_sysroot(maybe_sysroot);
|
||||
log #fmt("using sysroot = %s", sysroot);
|
||||
ret filesearch_impl(sysroot, addl_lib_search_paths, target_triple);
|
||||
}
|
||||
@ -79,16 +79,18 @@ fn make_target_lib_path(sysroot: fs::path,
|
||||
ret path;
|
||||
}
|
||||
|
||||
fn get_default_sysroot(binary: fs::path) -> fs::path {
|
||||
let dirname = fs::dirname(binary);
|
||||
if str::eq(dirname, binary) { ret "../"; }
|
||||
ret fs::connect(dirname, "../");
|
||||
fn get_default_sysroot() -> fs::path {
|
||||
alt os::get_exe_path() {
|
||||
option::some(p) { fs::connect(p, "../") }
|
||||
option::none. {
|
||||
fail "can't determine value for sysroot";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_sysroot(maybe_sysroot: option::t<fs::path>,
|
||||
binary: fs::path) -> fs::path {
|
||||
fn get_sysroot(maybe_sysroot: option::t<fs::path>) -> fs::path {
|
||||
alt maybe_sysroot {
|
||||
option::some(sr) { sr }
|
||||
option::none. { get_default_sysroot(binary) }
|
||||
option::none. { get_default_sysroot() }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user