Skip to content

Commit 7d6bddc

Browse files
committed
Build script that does nothing
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.
1 parent 4aeb0df commit 7d6bddc

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

serde/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ keywords = ["serde", "serialization", "no_std"]
1111
categories = ["encoding"]
1212
readme = "README.md"
1313
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
14+
build = "build.rs"
1415

1516
[badges]
1617
travis-ci = { repository = "serde-rs/serde" }

serde/build.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use std::env;
2+
use std::process::Command;
3+
use std::str::{self, FromStr};
4+
5+
fn main() {
6+
let rustc = match env::var_os("RUSTC") {
7+
Some(rustc) => rustc,
8+
None => return,
9+
};
10+
11+
let output = match Command::new(rustc).arg("--version").output() {
12+
Ok(output) => output,
13+
Err(_) => return,
14+
};
15+
16+
let version = match str::from_utf8(&output.stdout) {
17+
Ok(version) => version,
18+
Err(_) => return,
19+
};
20+
21+
let mut pieces = version.split('.');
22+
if pieces.next() != Some("rustc 1") {
23+
return;
24+
}
25+
26+
let next = match pieces.next() {
27+
Some(next) => next,
28+
None => return,
29+
};
30+
31+
let minor = match u32::from_str(next) {
32+
Ok(minor) => minor,
33+
Err(_) => return,
34+
};
35+
36+
if minor >= 26 {
37+
println!("cargo:rustc-cfg=integer128");
38+
}
39+
}

0 commit comments

Comments
 (0)