From 3ad99dcdae8ab96161d771f89fc1ea955c0aa86c Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Tue, 11 Oct 2016 17:48:48 -0700 Subject: [PATCH] Allow specifying a specific std version (by commit hash) in an environment variable --- build.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index a9f45b2..fb8ad75 100644 --- a/build.rs +++ b/build.rs @@ -36,10 +36,16 @@ impl Sub for Vec { } fn main() { - let mappings=include!("mapping.rs"); - - let compiler=rustc_version::version_meta().commit_hash.expect("Couldn't determine compiler version"); - let io_commit=mappings.iter().find(|&&Mapping(elem,_)|elem==compiler).expect("Unknown compiler version, upgrade core_io?").1; + let io_commit=match env::var("CORE_IO_COMMIT") { + Ok(c) => c, + Err(env::VarError::NotUnicode(_)) => panic!("Invalid commit specified in CORE_IO_COMMIT"), + Err(env::VarError::NotPresent) => { + let mappings=include!("mapping.rs"); + + let compiler=rustc_version::version_meta().commit_hash.expect("Couldn't determine compiler version"); + mappings.iter().find(|&&Mapping(elem,_)|elem==compiler).expect("Unknown compiler version, upgrade core_io?").1.to_owned() + } + }; let mut dest_path=PathBuf::from(env::var_os("OUT_DIR").unwrap()); dest_path.push("io.rs");