diff options
| author | Steven Fackler <[email protected]> | 2015-06-20 18:07:41 -0400 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2015-06-20 18:07:41 -0400 |
| commit | bfff71b7d6d74e390f3184c725388d8c1d17befa (patch) | |
| tree | 845d24c38ca78581e6420289aac946964c040258 /openssl-sys | |
| parent | Merge pull request #226 from jethrogb/topic/crypto_iv_slice (diff) | |
| parent | Mention mingw in README (diff) | |
| download | rust-openssl-bfff71b7d6d74e390f3184c725388d8c1d17befa.tar.xz rust-openssl-bfff71b7d6d74e390f3184c725388d8c1d17befa.zip | |
Merge pull request #225 from semmaz/mingw-build-fix
Added support for building on Windows with MinGW
Diffstat (limited to 'openssl-sys')
| -rw-r--r-- | openssl-sys/build.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/openssl-sys/build.rs b/openssl-sys/build.rs index 51d78ffc..de43c462 100644 --- a/openssl-sys/build.rs +++ b/openssl-sys/build.rs @@ -18,13 +18,22 @@ 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") { - vec!("eay32", "ssl32") + if get_mingw_in_path().is_some() && lib_dir.is_none() && include_dir.is_none() { + vec!("eay32", "ssleay32") + } else { + vec!("eay32", "ssl32") + } } else { vec!("crypto", "ssl") } @@ -62,3 +71,25 @@ fn build_old_openssl_shim(include_paths: &[PathBuf]) { config.file("src/old_openssl_shim.c") .compile("libold_openssl_shim.a"); } + +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 { Some(paths) } else { None } + }, + None => None + } +} |