summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/build.rs b/build.rs
index be96e83b68..8452940074 100644
--- a/build.rs
+++ b/build.rs
@@ -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,
+ }
+}