about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-13 17:29:50 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-01-15 08:22:16 -0800
commit7a37294accc0f5b4e8259de1fe385fbbcdcf1845 (patch)
treece9604c8d9cae277974bbf3e76f1389ea5430ceb /src
parent7bebdbd96826cc70c8e39d025a64b76cd64a2ee7 (diff)
downloadrust-7a37294accc0f5b4e8259de1fe385fbbcdcf1845.tar.gz
rust-7a37294accc0f5b4e8259de1fe385fbbcdcf1845.zip
Add a configure to disable libstd version injection
We'll use this when building snapshots so we can upgrade freely, but all
compilers will inject a version by default.
Diffstat (limited to 'src')
-rw-r--r--src/libextra/lib.rs3
-rw-r--r--src/librustc/front/std_inject.rs19
-rw-r--r--src/librustc/front/test.rs3
3 files changed, 20 insertions, 5 deletions
diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs
index fc0cc045175..b3dda5cbc21 100644
--- a/src/libextra/lib.rs
+++ b/src/libextra/lib.rs
@@ -20,7 +20,8 @@ Rust extras are part of the standard Rust distribution.
 
 */
 
-#[crate_id = "extra#0.10-pre"];
+// NOTE: upgrade to 0.10-pre after the next snapshot
+#[crate_id = "extra#0.9"];
 #[comment = "Rust extras"];
 #[license = "MIT/ASL2"];
 #[crate_type = "rlib"];
diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs
index c301318047c..f2bc03b21ba 100644
--- a/src/librustc/front/std_inject.rs
+++ b/src/librustc/front/std_inject.rs
@@ -21,6 +21,9 @@ use syntax::fold;
 use syntax::opt_vec;
 use syntax::util::small_vector::SmallVector;
 
+// NOTE: upgrade to 0.10-pre after the next snapshot
+pub static VERSION: &'static str = "0.9";
+
 pub fn maybe_inject_libstd_ref(sess: Session, crate: ast::Crate)
                                -> ast::Crate {
     if use_std(&crate) {
@@ -53,11 +56,21 @@ struct StandardLibraryInjector {
     sess: Session,
 }
 
+pub fn with_version(crate: &str) -> Option<(@str, ast::StrStyle)> {
+    match option_env!("CFG_DISABLE_INJECT_STD_VERSION") {
+        Some("1") => None,
+        _ => {
+            Some((format!("{}\\#{}", crate, VERSION).to_managed(),
+                  ast::CookedStr))
+        }
+    }
+}
+
 impl fold::Folder for StandardLibraryInjector {
     fn fold_crate(&mut self, crate: ast::Crate) -> ast::Crate {
         let mut vis = ~[ast::ViewItem {
             node: ast::ViewItemExternMod(self.sess.ident_of("std"),
-                                         None,
+                                         with_version("std"),
                                          ast::DUMMY_NODE_ID),
             attrs: ~[],
             vis: ast::Private,
@@ -67,7 +80,7 @@ impl fold::Folder for StandardLibraryInjector {
         if use_uv(&crate) && !self.sess.building_library.get() {
             vis.push(ast::ViewItem {
                 node: ast::ViewItemExternMod(self.sess.ident_of("green"),
-                                             None,
+                                             with_version("green"),
                                              ast::DUMMY_NODE_ID),
                 attrs: ~[],
                 vis: ast::Private,
@@ -75,7 +88,7 @@ impl fold::Folder for StandardLibraryInjector {
             });
             vis.push(ast::ViewItem {
                 node: ast::ViewItemExternMod(self.sess.ident_of("rustuv"),
-                                             None,
+                                             with_version("rustuv"),
                                              ast::DUMMY_NODE_ID),
                 attrs: ~[],
                 vis: ast::Private,
diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs
index 26d6c5cf9e7..b9a98e7b15a 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::with_version;
 
 use std::cell::RefCell;
 use std::vec;
@@ -292,7 +293,7 @@ fn mk_std(cx: &TestCtxt) -> ast::ViewItem {
                                           ast::DUMMY_NODE_ID))])
     } else {
         ast::ViewItemExternMod(id_extra,
-                               None,
+                               with_version("extra"),
                                ast::DUMMY_NODE_ID)
     };
     ast::ViewItem {