about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/front/std_inject.rs11
-rw-r--r--src/librustc/front/test.rs6
-rw-r--r--src/librustpkg/path_util.rs25
3 files changed, 35 insertions, 7 deletions
diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs
index f25bd14e1da..51b65bcce41 100644
--- a/src/librustc/front/std_inject.rs
+++ b/src/librustc/front/std_inject.rs
@@ -21,6 +21,8 @@ use syntax::fold;
 use syntax::opt_vec;
 use syntax::util::small_vector::SmallVector;
 
+pub static VERSION: &'static str = "0.9-pre";
+
 pub fn maybe_inject_libstd_ref(sess: Session, crate: ast::Crate)
                                -> ast::Crate {
     if use_std(&crate) {
@@ -57,7 +59,8 @@ impl fold::ast_fold for StandardLibraryInjector {
     fn fold_crate(&mut self, crate: ast::Crate) -> ast::Crate {
         let mut vis = ~[ast::view_item {
             node: ast::view_item_extern_mod(self.sess.ident_of("std"),
-                                            None,
+                                            Some((format!("std\\#{}", VERSION).to_managed(),
+                                                  ast::CookedStr)),
                                             ast::DUMMY_NODE_ID),
             attrs: ~[],
             vis: ast::private,
@@ -67,7 +70,8 @@ impl fold::ast_fold for StandardLibraryInjector {
         if use_uv(&crate) && !self.sess.building_library.get() {
             vis.push(ast::view_item {
                 node: ast::view_item_extern_mod(self.sess.ident_of("green"),
-                                                None,
+                                                Some((format!("green\\#{}", VERSION).to_managed(),
+                                                      ast::CookedStr)),
                                                 ast::DUMMY_NODE_ID),
                 attrs: ~[],
                 vis: ast::private,
@@ -75,7 +79,8 @@ impl fold::ast_fold for StandardLibraryInjector {
             });
             vis.push(ast::view_item {
                 node: ast::view_item_extern_mod(self.sess.ident_of("rustuv"),
-                                                None,
+                                                Some((format!("rustuv\\#{}", VERSION).to_managed(),
+                                                      ast::CookedStr)),
                                                 ast::DUMMY_NODE_ID),
                 attrs: ~[],
                 vis: ast::private,
diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs
index 6a072221008..fb19f20d129 100644
--- a/src/librustc/front/test.rs
+++ b/src/librustc/front/test.rs
@@ -13,6 +13,7 @@
 
 use driver::session;
 use front::config;
+use front::std_inject::VERSION;
 
 use std::cell::RefCell;
 use std::vec;
@@ -291,7 +292,10 @@ fn mk_std(cx: &TestCtxt) -> ast::view_item {
                                             path_node(~[id_extra]),
                                             ast::DUMMY_NODE_ID))])
     } else {
-        ast::view_item_extern_mod(id_extra, None, ast::DUMMY_NODE_ID)
+        ast::view_item_extern_mod(id_extra,
+                                  Some((format!("extra\\#{}", VERSION).to_managed(),
+                                        ast::CookedStr)),
+                                  ast::DUMMY_NODE_ID)
     };
     ast::view_item {
         node: vi,
diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs
index 1b8a988ab2c..aaaf56af436 100644
--- a/src/librustpkg/path_util.rs
+++ b/src/librustpkg/path_util.rs
@@ -14,7 +14,8 @@
 
 pub use crate_id::CrateId;
 pub use target::{OutputType, Main, Lib, Test, Bench, Target, Build, Install};
-pub use version::{Version, NoVersion, split_version_general, try_parsing_version};
+pub use version::{Version, ExactRevision, NoVersion, split_version, split_version_general,
+    try_parsing_version};
 pub use rustc::metadata::filesearch::rust_path;
 use rustc::metadata::filesearch::libdir;
 use rustc::driver::driver::host_triple;
@@ -213,8 +214,9 @@ pub fn library_in_workspace(path: &Path, short_name: &str, where: Target,
 }
 
 // rustc doesn't use target-specific subdirectories
-pub fn system_library(sysroot: &Path, lib_name: &str) -> Option<Path> {
-    library_in(lib_name, &NoVersion, &sysroot.join(libdir()))
+pub fn system_library(sysroot: &Path, crate_id: &str) -> Option<Path> {
+    let (lib_name, version) = split_crate_id(crate_id);
+    library_in(lib_name, &version, &sysroot.join(libdir()))
 }
 
 fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Option<Path> {
@@ -268,6 +270,7 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
                                }
                                None => break
                            }
+
                        }
                        _ => { f_name = f_name.slice(0, i); }
                  }
@@ -293,6 +296,22 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
     abs_path
 }
 
+fn split_crate_id<'a>(crate_id: &'a str) -> (&'a str, Version) {
+    match split_version(crate_id) {
+        Some((name, vers)) =>
+            match vers {
+                ExactRevision(ref v) => match v.find('-') {
+                    Some(pos) => (name, ExactRevision(v.slice(0, pos).to_owned())),
+                    None => (name, ExactRevision(v.to_owned()))
+                },
+                _ => (name, vers)
+            },
+        None => (crate_id, NoVersion)
+    }
+}
+
+
+
 /// Returns the executable that would be installed for <crateid>
 /// in <workspace>
 /// As a side effect, creates the bin-dir if it doesn't exist