提交 6637340c 编写于 作者: J Josh Matthews

Properly calculate base working dir for compile units.

上级 1d3d28bd
......@@ -489,7 +489,7 @@ fn build_session_options(match: getopts::match)
ret sopts;
}
fn build_session(sopts: @session::options) -> session::session {
fn build_session(sopts: @session::options, input: str) -> session::session {
let target_cfg = build_target_config(sopts);
let cstore = cstore::mk_cstore();
let filesearch = filesearch::mk_filesearch(
......@@ -498,7 +498,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: 1},
none, 0u, filesearch, false);
none, 0u, filesearch, false, fs::dirname(input));
}
fn parse_pretty(sess: session::session, &&name: str) -> pp_mode {
......@@ -644,7 +644,7 @@ fn main(args: [str]) {
};
let sopts = build_session_options(match);
let sess = build_session(sopts);
let sess = build_session(sopts, ifile);
let odir = getopts::opt_maybe_str(match, "out-dir");
let ofile = getopts::opt_maybe_str(match, "o");
let cfg = build_configuration(sess, binary, ifile);
......@@ -676,7 +676,7 @@ fn test_switch_implies_cfg_test() {
ok(m) { m }
};
let sessopts = build_session_options(match);
let sess = build_session(sessopts);
let sess = build_session(sessopts, "");
let cfg = build_configuration(sess, "whatever", "whatever");
assert (attr::contains_name(cfg, "test"));
}
......@@ -690,7 +690,7 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
ok(m) { m }
};
let sessopts = build_session_options(match);
let sess = build_session(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);
......
......@@ -60,7 +60,8 @@
mutable main_fn: option::t<node_id>,
mutable err_count: uint,
filesearch: filesearch::filesearch,
mutable building_library: bool) {
mutable building_library: bool,
working_dir: str) {
fn get_targ_cfg() -> @config { ret targ_cfg; }
fn get_opts() -> @options { ret opts; }
fn get_cstore() -> metadata::cstore::cstore { cstore }
......@@ -123,6 +124,9 @@ fn building_library() -> bool { building_library }
fn set_building_library(crate: @ast::crate) {
building_library = session::building_library(opts.crate_type, crate);
}
fn get_working_dir() -> str {
ret working_dir;
}
}
fn building_library(req_crate_type: crate_type, crate: @ast::crate) -> bool {
......
......@@ -162,13 +162,18 @@ fn create_compile_unit(cx: @crate_ctxt, full_path: str)
option::none. {}
}
let fname = fs::basename(full_path);
let path = fs::dirname(full_path);
let work_dir = cx.sess.get_working_dir();
let file_path = if str::starts_with(full_path, work_dir) {
str::slice(full_path, str::byte_len(work_dir),
str::byte_len(full_path))
} else {
full_path
};
let unit_metadata = [lltag(tg),
llunused(),
lli32(DW_LANG_RUST),
llstr(fname),
llstr(path),
llstr(file_path),
llstr(work_dir),
llstr(#env["CFG_VERSION"]),
lli1(false), // main compile unit
lli1(cx.sess.get_opts().optimize != 0u),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册