diff options
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -16,6 +16,12 @@ fn main() { ); } + 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"); @@ -70,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, + } +} |