forked from redis-rs/redis-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
33 lines (28 loc) · 900 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::env;
use std::ffi::OsString;
use std::process::Command;
fn get_rustc_version() -> (i32, i32) {
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
let out = String::from_utf8(Command::new(&rustc)
.arg("--version")
.output()
.unwrap().stdout).unwrap();
let mut pieces = out.split(' ');
let _ = pieces.next();
let mut ver_iter = pieces.next().unwrap().split('.').map(|x| x.parse().unwrap());
(ver_iter.next().unwrap(), ver_iter.next().unwrap())
}
fn rustc_has_unix_socket() -> bool {
if !cfg!(unix) {
false
} else {
let (major, minor) = get_rustc_version();
major > 1 || (major == 1 && minor >= 10)
}
}
fn main() {
println!("cargo:rerun-if-changed=build.rs");
if rustc_has_unix_socket() {
println!("cargo:rustc-cfg=feature=\"with-system-unix-sockets\"");
}
}