about summary refs log tree commit diff
path: root/src/librustpkg/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustpkg/context.rs')
-rw-r--r--src/librustpkg/context.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/librustpkg/context.rs b/src/librustpkg/context.rs
index 230a0f915ac..f051be25f26 100644
--- a/src/librustpkg/context.rs
+++ b/src/librustpkg/context.rs
@@ -12,6 +12,7 @@
 
 
 use std::hashmap::HashMap;
+use std::os;
 
 pub struct Ctx {
     // Sysroot -- if this is None, uses rustc filesearch's
@@ -23,3 +24,26 @@ pub struct Ctx {
     // though I'm not sure why the value is a bool
     dep_cache: @mut HashMap<~str, bool>,
 }
+
+impl Ctx {
+    /// Debugging
+    pub fn sysroot_opt_str(&self) -> ~str {
+        match self.sysroot_opt {
+            None => ~"[none]",
+            Some(p) => p.to_str()
+        }
+    }
+}
+
+/// We assume that if ../../rustc exists, then we're running
+/// rustpkg from a Rust target directory. This is part of a
+/// kludgy hack used to adjust the sysroot.
+pub fn in_target(sysroot_opt: Option<@Path>) -> bool {
+    match sysroot_opt {
+        None => false,
+        Some(p) => {
+            debug!("Checking whether %s is in target", p.to_str());
+            os::path_is_dir(&p.pop().pop().push("rustc"))
+        }
+    }
+}