Use version_check
crate instead of handcrafted version parsing
This commit is contained in:
parent
2c05518810
commit
8890061f82
@ -23,6 +23,9 @@ serde_derive = { version = "1.0", optional = true, path = "../serde_derive" }
|
||||
[dev-dependencies]
|
||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||
|
||||
[build-dependencies]
|
||||
version_check = "0.1.3"
|
||||
|
||||
|
||||
### FEATURES #################################################################
|
||||
|
||||
|
@ -1,39 +1,13 @@
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
use std::str::{self, FromStr};
|
||||
extern crate version_check;
|
||||
|
||||
fn main() {
|
||||
let rustc = match env::var_os("RUSTC") {
|
||||
Some(rustc) => rustc,
|
||||
None => return,
|
||||
match version_check::is_min_version("1.26.0") {
|
||||
Some((true, _)) => {
|
||||
println!("cargo:rustc-cfg=integer128");
|
||||
},
|
||||
Some((false, _)) => {}
|
||||
None => {
|
||||
println!("could not figure out the rustc version");
|
||||
},
|
||||
};
|
||||
|
||||
let output = match Command::new(rustc).arg("--version").output() {
|
||||
Ok(output) => output,
|
||||
Err(_) => return,
|
||||
};
|
||||
|
||||
let version = match str::from_utf8(&output.stdout) {
|
||||
Ok(version) => version,
|
||||
Err(_) => return,
|
||||
};
|
||||
|
||||
let mut pieces = version.split('.');
|
||||
if pieces.next() != Some("rustc 1") {
|
||||
return;
|
||||
}
|
||||
|
||||
let next = match pieces.next() {
|
||||
Some(next) => next,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let minor = match u32::from_str(next) {
|
||||
Ok(minor) => minor,
|
||||
Err(_) => return,
|
||||
};
|
||||
|
||||
if minor >= 26 {
|
||||
println!("cargo:rustc-cfg=integer128");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user