Commit c532c199 authored by Simon Mazur's avatar Simon Mazur
Browse files

Added support for building on Windows with MinGW

parent 1b824022
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -24,7 +24,14 @@ fn main() {
    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);
                }
                vec!("eay32", "ssleay32")
            } else {
                vec!("eay32", "ssl32")
            }
        } else {
            vec!("crypto", "ssl")
        }
@@ -62,3 +69,25 @@ fn build_old_openssl_shim(include_paths: &[PathBuf]) {
    config.file("src/old_openssl_shim.c")
        .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());
                }
            }
        }
    }

    if paths.len() > 0 {
        Option::Some(paths)
    } else {
        Option::None
    }
}