diff --git a/src/librustpkg/api.rs b/src/librustpkg/api.rs index 0730a6fc3a210..45c37a93e3e1e 100644 --- a/src/librustpkg/api.rs +++ b/src/librustpkg/api.rs @@ -49,8 +49,8 @@ pub fn new_default_context(c: workcache::Context, p: Path) -> BuildContext { cfgs: ~[], rustc_flags: RustcFlags::default(), use_rust_path_hack: false, - sysroot: p }, + sysroot: p, workcache_context: c } } diff --git a/src/librustpkg/context.rs b/src/librustpkg/context.rs index 3fb6f9caeb82c..fddfa02032cc4 100644 --- a/src/librustpkg/context.rs +++ b/src/librustpkg/context.rs @@ -26,25 +26,35 @@ pub struct Context { // FOO/src/bar-0.1 instead of FOO). The flag doesn't affect where // rustpkg stores build artifacts. use_rust_path_hack: bool, - // The root directory containing the Rust standard libraries - sysroot: Path } #[deriving(Clone)] pub struct BuildContext { // Context for workcache workcache_context: workcache::Context, - // Everything else - context: Context + // Parsed command line options + context: Context, + // The root directory containing the Rust standard libraries + sysroot: Path } impl BuildContext { pub fn sysroot(&self) -> Path { - self.context.sysroot.clone() + self.sysroot.clone() } + // Hack so that rustpkg can run either out of a rustc target dir, + // or the host dir pub fn sysroot_to_use(&self) -> Path { - self.context.sysroot_to_use() + if !in_target(&self.sysroot) { + self.sysroot.clone() + } else { + let mut p = self.sysroot.clone(); + p.pop(); + p.pop(); + p.pop(); + p + } } /// Returns the flags to pass to rustc, as a vector of strings @@ -131,28 +141,6 @@ pub enum StopBefore { } impl Context { - pub fn sysroot(&self) -> Path { - self.sysroot.clone() - } - - /// Debugging - pub fn sysroot_str(&self) -> ~str { - self.sysroot.as_str().unwrap().to_owned() - } - - // Hack so that rustpkg can run either out of a rustc target dir, - // or the host dir - pub fn sysroot_to_use(&self) -> Path { - if !in_target(&self.sysroot) { - self.sysroot.clone() - } else { - let mut p = self.sysroot.clone(); - p.pop(); - p.pop(); - p.pop(); - p - } - } /// Returns the flags to pass to rustc, as a vector of strings pub fn flag_strs(&self) -> ~[~str] { diff --git a/src/librustpkg/lib.rs b/src/librustpkg/lib.rs index 43f190f37a23e..39bc4c7570e52 100644 --- a/src/librustpkg/lib.rs +++ b/src/librustpkg/lib.rs @@ -913,8 +913,8 @@ pub fn main_args(args: &[~str]) -> int { cfgs: cfgs.clone(), rustc_flags: rustc_flags.clone(), use_rust_path_hack: use_rust_path_hack, - sysroot: sroot.clone(), // Currently, only tests override this }, + sysroot: sroot.clone(), // Currently, only tests override this workcache_context: api::default_context(sroot.clone(), default_workspace()).workcache_context }.run(command, rm_args.clone()) diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs index 2ceed4f3df7e4..aa6dab05addd5 100644 --- a/src/librustpkg/tests.rs +++ b/src/librustpkg/tests.rs @@ -54,8 +54,8 @@ fn fake_ctxt(sysroot: Path, workspace: &Path) -> BuildContext { rustc_flags: RustcFlags::default(), use_rust_path_hack: false, - sysroot: sysroot - } + }, + sysroot: sysroot } }