aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Mazur <[email protected]>2015-06-15 19:13:30 +0300
committerSimon Mazur <[email protected]>2015-06-15 19:13:30 +0300
commit27b0e4d7afc6b2cb032669d5bd8e4169c4fc62ee (patch)
treedebe13509e7de8284f2bad7795c3281601bae4b1
parentAdded support for building on Windows with MinGW (diff)
downloadrust-openssl-27b0e4d7afc6b2cb032669d5bd8e4169c4fc62ee.tar.xz
rust-openssl-27b0e4d7afc6b2cb032669d5bd8e4169c4fc62ee.zip
Don't ignore environment variables if building with mingw
-rw-r--r--openssl-sys/build.rs44
1 files changed, 23 insertions, 21 deletions
diff --git a/openssl-sys/build.rs b/openssl-sys/build.rs
index ff4a213e..de43c462 100644
--- a/openssl-sys/build.rs
+++ b/openssl-sys/build.rs
@@ -18,16 +18,18 @@ fn main() {
build_old_openssl_shim(&info.include_paths);
return;
}
+ if let Some(mingw_paths) = get_mingw_in_path() {
+ for path in mingw_paths {
+ println!("cargo:rustc-flags=-L native={}", path);
+ }
+ }
}
let libs_env = env::var("OPENSSL_LIBS").ok();
let libs = match libs_env {
Some(ref v) => v.split(":").collect(),
None => if target.contains("windows") {
- if let Some(mingw_paths) = check_mingw_path() {
- for path in mingw_paths {
- println!("cargo:rustc-flags=-L native={}", path);
- }
+ if get_mingw_in_path().is_some() && lib_dir.is_none() && include_dir.is_none() {
vec!("eay32", "ssleay32")
} else {
vec!("eay32", "ssl32")
@@ -70,24 +72,24 @@ fn build_old_openssl_shim(include_paths: &[PathBuf]) {
.compile("libold_openssl_shim.a");
}
-fn check_mingw_path() -> Option<Vec<String>> {
- use std::ascii::AsciiExt;
-
- let mut paths = vec![];
-
- if let Some(env_path) = env::var("PATH").ok() {
- for path in env::split_paths(&env_path) {
- if let Some(path_str) = path.to_str() {
- if path_str.to_ascii_lowercase().contains("mingw") {
- paths.push(path_str.to_string());
+fn get_mingw_in_path() -> Option<Vec<String>> {
+ match env::var_os("PATH") {
+ Some(env_path) => {
+ let paths: Vec<String> = env::split_paths(&env_path).filter_map(|path| {
+ use std::ascii::AsciiExt;
+
+ match path.to_str() {
+ Some(path_str) => {
+ if path_str.to_ascii_lowercase().contains("mingw") {
+ Some(path_str.to_string())
+ } else { None }
+ },
+ None => None
}
- }
- }
- }
+ }).collect();
- if paths.len() > 0 {
- Option::Some(paths)
- } else {
- Option::None
+ if paths.len() > 0 { Some(paths) } else { None }
+ },
+ None => None
}
}