diff options
author | Linus Färnstrand <linus@mullvad.net> | 2018-06-20 18:25:55 +0200 |
---|---|---|
committer | Linus Färnstrand <linus@mullvad.net> | 2018-06-20 18:25:55 +0200 |
commit | 1b083b4bc455fcffcbc181ada196d718903ce3df (patch) | |
tree | 3afe8dbc99b0d0a03afcf8952dcee655fed8408b | |
parent | 89c416f2a03fafc508a9346930ad0587cd189b35 (diff) | |
parent | 956e891d0367a64675de7a52b5a54d843e4bdfde (diff) |
Merge branch 'improve-lib-dir-handling'
-rw-r--r-- | nftnl-sys/build.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/nftnl-sys/build.rs b/nftnl-sys/build.rs index 5494522..42268dd 100644 --- a/nftnl-sys/build.rs +++ b/nftnl-sys/build.rs @@ -18,8 +18,13 @@ const MIN_VERSION: &str = "1.0.7"; #[cfg(not(feature = "nftnl-1-0-7"))] const MIN_VERSION: &str = "1.0.6"; +fn get_env(var: &'static str) -> Option<PathBuf> { + println!("cargo:rerun-if-env-changed={}", var); + env::var_os(var).map(PathBuf::from) +} + fn main() { - if let Ok(lib_dir) = env::var("LIBNFTNL_LIB_DIR").map(PathBuf::from) { + if let Some(lib_dir) = get_env("LIBNFTNL_LIB_DIR") { if !lib_dir.is_dir() { panic!( "libnftnl library directory does not exist: {}", @@ -37,7 +42,7 @@ fn main() { .unwrap(); } - if let Ok(lib_dir) = env::var("LIBMNL_LIB_DIR").map(PathBuf::from) { + if let Some(lib_dir) = get_env("LIBMNL_LIB_DIR") { if !lib_dir.is_dir() { panic!( "libmnl library directory does not exist: {}", |