mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
rustc: Detect the system root and allow the user to override if necessary
This commit is contained in:
parent
1299e74db3
commit
bde44a03a9
@ -14,6 +14,7 @@ import middle.typestate_check;
|
|||||||
import lib.llvm;
|
import lib.llvm;
|
||||||
import util.common;
|
import util.common;
|
||||||
|
|
||||||
|
import std.fs;
|
||||||
import std.map.mk_hashmap;
|
import std.map.mk_hashmap;
|
||||||
import std.option;
|
import std.option;
|
||||||
import std.option.some;
|
import std.option.some;
|
||||||
@ -141,6 +142,7 @@ options:
|
|||||||
-c compile and assemble, but do not link
|
-c compile and assemble, but do not link
|
||||||
--save-temps write intermediate files in addition to normal output
|
--save-temps write intermediate files in addition to normal output
|
||||||
--time-passes time the individual phases of the compiler
|
--time-passes time the individual phases of the compiler
|
||||||
|
--sysroot <path> override the system root (default: rustc's directory)
|
||||||
--no-typestate don't run the typestate pass (unsafe!)
|
--no-typestate don't run the typestate pass (unsafe!)
|
||||||
-h display this message\n\n");
|
-h display this message\n\n");
|
||||||
}
|
}
|
||||||
@ -152,6 +154,12 @@ fn get_os() -> session.os {
|
|||||||
if (_str.eq(s, "linux")) { ret session.os_linux; }
|
if (_str.eq(s, "linux")) { ret session.os_linux; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_default_sysroot(str binary) -> str {
|
||||||
|
auto dirname = fs.dirname(binary);
|
||||||
|
if (_str.eq(dirname, binary)) { ret "."; }
|
||||||
|
ret dirname;
|
||||||
|
}
|
||||||
|
|
||||||
fn main(vec[str] args) {
|
fn main(vec[str] args) {
|
||||||
|
|
||||||
// FIXME: don't hard-wire this.
|
// FIXME: don't hard-wire this.
|
||||||
@ -166,8 +174,9 @@ fn main(vec[str] args) {
|
|||||||
optflag("pretty"), optflag("ls"), optflag("parse-only"),
|
optflag("pretty"), optflag("ls"), optflag("parse-only"),
|
||||||
optflag("O"), optflag("shared"), optmulti("L"),
|
optflag("O"), optflag("shared"), optmulti("L"),
|
||||||
optflag("S"), optflag("c"), optopt("o"), optopt("g"),
|
optflag("S"), optflag("c"), optopt("o"), optopt("g"),
|
||||||
optflag("save-temps"), optflag("time-passes"),
|
optflag("save-temps"), optopt("sysroot"),
|
||||||
optflag("no-typestate"), optflag("noverify"));
|
optflag("time-passes"), optflag("no-typestate"),
|
||||||
|
optflag("noverify"));
|
||||||
auto binary = _vec.shift[str](args);
|
auto binary = _vec.shift[str](args);
|
||||||
auto match;
|
auto match;
|
||||||
alt (GetOpts.getopts(args, opts)) {
|
alt (GetOpts.getopts(args, opts)) {
|
||||||
@ -203,6 +212,13 @@ fn main(vec[str] args) {
|
|||||||
auto debuginfo = opt_present(match, "g");
|
auto debuginfo = opt_present(match, "g");
|
||||||
auto time_passes = opt_present(match, "time-passes");
|
auto time_passes = opt_present(match, "time-passes");
|
||||||
auto run_typestate = !opt_present(match, "no-typestate");
|
auto run_typestate = !opt_present(match, "no-typestate");
|
||||||
|
auto sysroot_opt = GetOpts.opt_maybe_str(match, "sysroot");
|
||||||
|
|
||||||
|
auto sysroot;
|
||||||
|
alt (sysroot_opt) {
|
||||||
|
case (none[str]) { sysroot = get_default_sysroot(binary); }
|
||||||
|
case (some[str](?s)) { sysroot = s; }
|
||||||
|
}
|
||||||
|
|
||||||
let @session.options sopts =
|
let @session.options sopts =
|
||||||
@rec(shared = shared,
|
@rec(shared = shared,
|
||||||
@ -213,7 +229,8 @@ fn main(vec[str] args) {
|
|||||||
save_temps = save_temps,
|
save_temps = save_temps,
|
||||||
time_passes = time_passes,
|
time_passes = time_passes,
|
||||||
output_type = output_type,
|
output_type = output_type,
|
||||||
library_search_paths = library_search_paths);
|
library_search_paths = library_search_paths,
|
||||||
|
sysroot = sysroot);
|
||||||
|
|
||||||
auto crate_cache = common.new_int_hash[session.crate_metadata]();
|
auto crate_cache = common.new_int_hash[session.crate_metadata]();
|
||||||
auto target_crate_num = 0;
|
auto target_crate_num = 0;
|
||||||
|
@ -33,7 +33,8 @@ type options = rec(bool shared,
|
|||||||
bool save_temps,
|
bool save_temps,
|
||||||
bool time_passes,
|
bool time_passes,
|
||||||
middle.trans.output_type output_type,
|
middle.trans.output_type output_type,
|
||||||
vec[str] library_search_paths);
|
vec[str] library_search_paths,
|
||||||
|
str sysroot);
|
||||||
|
|
||||||
type crate_metadata = rec(str name,
|
type crate_metadata = rec(str name,
|
||||||
vec[u8] data);
|
vec[u8] data);
|
||||||
|
Loading…
Reference in New Issue
Block a user