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.
This commit is contained in:
parent
7bebdbd968
commit
7a37294acc
5 changed files with 23 additions and 5 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue