aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-05-04 19:27:54 -0700
committerPatrick Walton <[email protected]>2011-05-04 19:27:54 -0700
commitbde44a03a9543609fbfd89cb5f19e3b31018de30 (patch)
tree379f09cbeb4f3680b15dc0c886ec620b88904b46 /src/comp
parentbuild: Whitespace police in configure. Puts out burning tinderbox. (diff)
downloadrust-bde44a03a9543609fbfd89cb5f19e3b31018de30.tar.xz
rust-bde44a03a9543609fbfd89cb5f19e3b31018de30.zip
rustc: Detect the system root and allow the user to override if necessary
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/driver/rustc.rs23
-rw-r--r--src/comp/driver/session.rs3
2 files changed, 22 insertions, 4 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index 061b5a14..4276b558 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -14,6 +14,7 @@ import middle.typestate_check;
import lib.llvm;
import util.common;
+import std.fs;
import std.map.mk_hashmap;
import std.option;
import std.option.some;
@@ -141,6 +142,7 @@ options:
-c compile and assemble, but do not link
--save-temps write intermediate files in addition to normal output
--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!)
-h display this message\n\n");
}
@@ -152,6 +154,12 @@ fn get_os() -> session.os {
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) {
// FIXME: don't hard-wire this.
@@ -166,8 +174,9 @@ fn main(vec[str] args) {
optflag("pretty"), optflag("ls"), optflag("parse-only"),
optflag("O"), optflag("shared"), optmulti("L"),
optflag("S"), optflag("c"), optopt("o"), optopt("g"),
- optflag("save-temps"), optflag("time-passes"),
- optflag("no-typestate"), optflag("noverify"));
+ optflag("save-temps"), optopt("sysroot"),
+ optflag("time-passes"), optflag("no-typestate"),
+ optflag("noverify"));
auto binary = _vec.shift[str](args);
auto match;
alt (GetOpts.getopts(args, opts)) {
@@ -203,6 +212,13 @@ fn main(vec[str] args) {
auto debuginfo = opt_present(match, "g");
auto time_passes = opt_present(match, "time-passes");
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 =
@rec(shared = shared,
@@ -213,7 +229,8 @@ fn main(vec[str] args) {
save_temps = save_temps,
time_passes = time_passes,
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 target_crate_num = 0;
diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs
index ec924f51..6b3b55f4 100644
--- a/src/comp/driver/session.rs
+++ b/src/comp/driver/session.rs
@@ -33,7 +33,8 @@ type options = rec(bool shared,
bool save_temps,
bool time_passes,
middle.trans.output_type output_type,
- vec[str] library_search_paths);
+ vec[str] library_search_paths,
+ str sysroot);
type crate_metadata = rec(str name,
vec[u8] data);