diff options
Diffstat (limited to 'libc/build.rs')
-rw-r--r-- | libc/build.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libc/build.rs b/libc/build.rs index 9b13376..8452940 100644 --- a/libc/build.rs +++ b/libc/build.rs @@ -9,6 +9,19 @@ fn main() { std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok(); + if std::env::var("CARGO_FEATURE_USE_STD").is_ok() { + println!( + "cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \ + please consider using the `std` cargo feature instead\"" + ); + } + + if std::env::var("LIBC_CI").is_ok() { + if let Some(12) = which_freebsd() { + println!("cargo:rustc-cfg=freebsd12"); + } + } + // Rust >= 1.15 supports private module use: if rustc_minor_ver >= 15 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_priv_mod_use"); @@ -63,3 +76,26 @@ fn rustc_minor_version() -> Option<u32> { otry!(pieces.next()).parse().ok() } + +fn which_freebsd() -> Option<i32> { + let output = std::process::Command::new("freebsd-version").output().ok(); + if output.is_none() { + return None; + } + let output = output.unwrap(); + if !output.status.success() { + return None; + } + + let stdout = String::from_utf8(output.stdout).ok(); + if stdout.is_none() { + return None; + } + let stdout = stdout.unwrap(); + + match &stdout { + s if s.starts_with("11") => Some(11), + s if s.starts_with("12") => Some(12), + _ => None, + } +} |