diff options
author | gnzlbg <gonzalobg88@gmail.com> | 2019-05-16 14:53:51 +0200 |
---|---|---|
committer | gnzlbg <gonzalobg88@gmail.com> | 2019-05-24 20:04:17 +0200 |
commit | 7437d0a6f18625b90a9d2fc40f3ecbc98a2e95fc (patch) | |
tree | c2a8655e7d01d6ff20f64325d4cdd2d7309edde0 /build.rs | |
parent | 5653a6014f18dbc2594ba756e40bb5e2f69866f7 (diff) | |
download | rust-libc-7437d0a6f18625b90a9d2fc40f3ecbc98a2e95fc.tar.gz |
Add a FreeBSD 12 build job and test FreeBSD12 APIs
This commits adds a second FreeBSD 12 build job,
and splits the implementation of the FreeBSD module
into two modules, one for FreeBSD 11, and one for FreeBSD 12.
The FreeBSD 11 module is compiled always by default, and is
mostly forward compatible with FreeBSD 12 systems.
The FreeBSD 12 module is only built for now in libc's CI,
and uses FreeBSD 12 data types and APIs, linking to symbols
that are only available in FreeBSD 12.
Basically, when LIBC_CI env variable is defined, and the host
system is a FreeBSD 12 system, then the FreeBSD 12 module is
automatically built and tested. Conditional compilation is done
using a `cfg(freebsd12)` flag.
This commit also re-enables many tests, and documents why
some remain disabled.
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, + } +} |