about summary refs log tree commit diff
path: root/src/librustpkg/context.rs
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2013-07-31 13:47:32 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2013-08-09 14:11:50 -0700
commit96fd606dddba6bd4773c41be66c44fc076a96ff8 (patch)
tree51a9be1731ec2607021333e3c8ad0ebfa5848998 /src/librustpkg/context.rs
parente751c90513b3b7948ffab7b449f0758e4225125e (diff)
downloadrust-96fd606dddba6bd4773c41be66c44fc076a96ff8.tar.gz
rust-96fd606dddba6bd4773c41be66c44fc076a96ff8.zip
std/rustc/rustpkg/syntax: Support the `extern mod = ...` form
This commit allows you to write:

 extern mod x = "a/b/c";

which means rustc will search in the RUST_PATH for a package with
ID a/b/c, and bind it to the name `x` if it's found.

Incidentally, move get_relative_to from back::rpath into std::path
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"))
+        }
+    }
+}