forked from m4rw3r/chomp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
28 lines (21 loc) · 890 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/// This build script checks if we can use `#![feature(specialization)]`.
extern crate rustc_version;
use rustc_version::Channel;
const SPECIALIZATION_CFG: &'static str = "has_specialization";
fn main() {
// Prevent rebuilds of build.rs if other files change
println!("cargo:rerun-if-changed=build.rs");
let version = rustc_version::version_meta();
if version.channel == Channel::Nightly {
if let Some(ref date) = version.commit_date {
// year, month, day
let ndate = date.splitn(3, "-")
.map(str::parse)
.collect::<Result<Vec<i32>, _>>().unwrap();
// specialization is available from nightly 2016-3-15
if ndate >= vec![2016, 3, 15] {
println!("cargo:rustc-cfg={}", SPECIALIZATION_CFG);
}
}
}
}