diff options
author | Daniel Mueller <deso@posteo.net> | 2018-12-10 21:00:27 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2018-12-10 21:00:27 -0800 |
commit | e2604a756aaddcd5919ee2f1b9cc0055d200f846 (patch) | |
tree | 1ea1b9900db20d3aadbddbce18882d0c957247d7 /libc/build.rs | |
parent | 5875df6c958743cf86c75b2cb5fc2efe5ca0de43 (diff) | |
download | nitrocli-e2604a756aaddcd5919ee2f1b9cc0055d200f846.tar.gz nitrocli-e2604a756aaddcd5919ee2f1b9cc0055d200f846.tar.bz2 |
Update libc crate to 0.2.45
This change updates the libc crate to version 0.2.45.
Import subrepo libc/:libc at f5636fc618f8e16968b3178196d73c94ad9f7b05
Diffstat (limited to 'libc/build.rs')
-rw-r--r-- | libc/build.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libc/build.rs b/libc/build.rs new file mode 100644 index 0000000..1852ed2 --- /dev/null +++ b/libc/build.rs @@ -0,0 +1,35 @@ +use std::env; +use std::process::Command; +use std::str; + +fn main() { + /* + * If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it + * must define an incompatible type to retain backwards-compatibility. + */ + if rustc_minor_version().expect("Failed to get rustc version") >= 30 { + println!("cargo:rustc-cfg=core_cvoid"); + } +} + +fn rustc_minor_version() -> Option<u32> { + macro_rules! otry { + ($e:expr) => { + match $e { + Some(e) => e, + None => return None, + } + }; + } + + let rustc = otry!(env::var_os("RUSTC")); + let output = otry!(Command::new(rustc).arg("--version").output().ok()); + let version = otry!(str::from_utf8(&output.stdout).ok()); + let mut pieces = version.split('.'); + + if pieces.next() != Some("rustc 1") { + return None; + } + + otry!(pieces.next()).parse().ok() +} |