Skip to content

Commit 01b86d5

Browse files
authored
Merge pull request #1259 from serde-rs/build
Build script that does nothing
2 parents 62850bf + c80f923 commit 01b86d5

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

serde/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ documentation = "https://docs.serde.rs/serde/"
1010
keywords = ["serde", "serialization", "no_std"]
1111
categories = ["encoding"]
1212
readme = "README.md"
13-
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
13+
include = ["Cargo.toml", "build.rs", "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

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
// 128-bit integers stabilized in Rust 1.26:
37+
// https://blog.rust-lang.org/2018/05/10/Rust-1.26.html
38+
if minor >= 26 {
39+
println!("cargo:rustc-cfg=integer128");
40+
}
41+
}

0 commit comments

Comments
 (0)