mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-29 12:57:55 +00:00
2c05518810
Eventually we will want a build script that enables Serde impls for i128 and u128. As a first step here is a build script that does nothing to see whether we can roll this out without breaking anyone's workflow, without having a supported feature at stake in the event that it needs to be rolled back.
40 lines
836 B
Rust
40 lines
836 B
Rust
use std::env;
|
|
use std::process::Command;
|
|
use std::str::{self, FromStr};
|
|
|
|
fn main() {
|
|
let rustc = match env::var_os("RUSTC") {
|
|
Some(rustc) => rustc,
|
|
None => return,
|
|
};
|
|
|
|
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");
|
|
}
|
|
}
|