| 1 | use std::process::Command; |
| 2 | use std::{env, str}; |
| 3 | |
| 4 | fn main() { |
| 5 | if let Some(v) = rustc_version() { |
| 6 | if v >= 26 { |
| 7 | println!("cargo:rustc-cfg=feature=\"u128\""); |
| 8 | } |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | fn rustc_version() -> Option<u32> { |
| 13 | if let Some(rustc) = env::var_os("RUSTC") { |
| 14 | if let Some(output) = Command::new(rustc).arg("--version").output().ok() { |
| 15 | if let Some(version) = str::from_utf8(&output.stdout).ok() { |
| 16 | let mut pieces = version.split('.'); |
| 17 | if pieces.next() != Some("rustc 1") { |
| 18 | return None; |
| 19 | } |
| 20 | if let Some(piece) = pieces.next() { |
| 21 | return piece.parse().ok(); |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | return None; |
| 27 | } |