Skip to content
Snippets Groups Projects
Unverified Commit 476b6759 authored by Aaron Hill's avatar Aaron Hill
Browse files

Panic if const-extern-fn is not used on nightly

parent b0ba2de7
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,8 @@ use std::process::Command; ...@@ -3,8 +3,8 @@ use std::process::Command;
use std::str; use std::str;
fn main() { fn main() {
let rustc_minor_ver = let (rustc_minor_ver, is_nightly) =
rustc_minor_version().expect("Failed to get rustc version"); rustc_minor_nightly().expect("Failed to get rustc version");
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
...@@ -75,11 +75,14 @@ fn main() { ...@@ -75,11 +75,14 @@ fn main() {
} }
if const_extern_fn_cargo_feature { if const_extern_fn_cargo_feature {
if !is_nightly || rustc_minor_ver < 40 {
panic!("const-extern-fn requires a nightly compiler >= 1.40")
}
println!("cargo:rustc-cfg=libc_const_extern_fn"); println!("cargo:rustc-cfg=libc_const_extern_fn");
} }
} }
fn rustc_minor_version() -> Option<u32> { fn rustc_minor_nightly() -> Option<(u32, bool)> {
macro_rules! otry { macro_rules! otry {
($e:expr) => { ($e:expr) => {
match $e { match $e {
...@@ -98,7 +101,12 @@ fn rustc_minor_version() -> Option<u32> { ...@@ -98,7 +101,12 @@ fn rustc_minor_version() -> Option<u32> {
return None; return None;
} }
otry!(pieces.next()).parse().ok() let minor = pieces.next();
let nightly_raw = otry!(otry!(pieces.next()).split('-').nth(1));
let nightly = nightly_raw.starts_with("dev") || nightly_raw.starts_with("nightly");
let minor = otry!(otry!(minor).parse().ok());
Some((minor, nightly))
} }
fn which_freebsd() -> Option<i32> { fn which_freebsd() -> Option<i32> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment