]> git.proxmox.com Git - rustc.git/blob - src/vendor/failure_derive/build.rs
New upstream version 1.31.0+dfsg1
[rustc.git] / src / vendor / failure_derive / build.rs
1 use std::env;
2 use std::process::Command;
3 use std::str;
4 use std::str::FromStr;
5
6 fn main() {
7 if rustc_has_dyn_trait() {
8 println!("cargo:rustc-cfg=has_dyn_trait");
9 }
10 }
11
12 fn rustc_has_dyn_trait() -> bool {
13 let rustc = match env::var_os("RUSTC") {
14 Some(rustc) => rustc,
15 None => return false,
16 };
17
18 let output = match Command::new(rustc).arg("--version").output() {
19 Ok(output) => output,
20 Err(_) => return false,
21 };
22
23 let version = match str::from_utf8(&output.stdout) {
24 Ok(version) => version,
25 Err(_) => return false,
26 };
27
28 let mut pieces = version.split('.');
29 if pieces.next() != Some("rustc 1") {
30 return true;
31 }
32
33 let next = match pieces.next() {
34 Some(next) => next,
35 None => return false,
36 };
37
38 u32::from_str(next).unwrap_or(0) >= 27
39 }