Skip to content

Commit

Permalink
Move syslog to BuildContext
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsle committed Jan 5, 2014
1 parent 177f740 commit e1c5982
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/librustpkg/api.rs
Expand Up @@ -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
}
}
Expand Down
44 changes: 16 additions & 28 deletions src/librustpkg/context.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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] {
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/lib.rs
Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions src/librustpkg/tests.rs
Expand Up @@ -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
}
}

Expand Down

0 comments on commit e1c5982

Please sign in to comment.