Fix OpenSSL linking on Windows

Technically this is a breaking change moving from `libeay32` to
`libcrypto` but no one should be using an openssl version from <=2016.
This commit is contained in:
BlackHoleFox 2021-10-06 00:04:04 -05:00 committed by Thom Chiovoloni
parent 3982393bbe
commit 66ace52c4a
2 changed files with 11 additions and 15 deletions

View File

@ -181,31 +181,23 @@ mod build_bundled {
if cfg!(feature = "bundled-sqlcipher-vendored-openssl") {
cfg.include(std::env::var("DEP_OPENSSL_INCLUDE").unwrap());
println!("cargo:rustc-link-lib=static=crypto"); // cargo will
// resolve downstream
// to the static
// lib in openssl-sys
// cargo will resolve downstream to the static lib in openssl-sys
} else if is_windows {
// FIXME README says that bundled-sqlcipher is Unix only, and the sources are
// configured on a Unix machine. So maybe this should be made unreachable.
// Windows without `-vendored-openssl` takes this to link against a prebuilt OpenSSL lib
cfg.include(inc_dir.to_string_lossy().as_ref());
let mut lib = String::new();
lib.push_str(lib_dir.to_string_lossy().as_ref());
lib.push('\\');
lib.push_str("libeay32.lib");
cfg.flag(&lib);
let lib = lib_dir.join("libcrypto.lib");
cfg.flag(lib.to_string_lossy().as_ref());
} else if use_openssl {
cfg.include(inc_dir.to_string_lossy().as_ref());
// branch not taken on Windows, just `crypto` is fine.
println!("cargo:rustc-link-lib=dylib=crypto");
println!(
"cargo:rustc-link-search={}",
lib_dir.to_string_lossy().as_ref()
);
println!("cargo:rustc-link-search={}", lib_dir.to_string_lossy());
} else if is_apple {
cfg.flag("-DSQLCIPHER_CRYPTO_CC");
println!("cargo:rustc-link-lib=framework=SecurityFoundation");
println!("cargo:rustc-link-lib=framework=CoreFoundation");
} else {
// branch not taken on Windows, just `crypto` is fine.
println!("cargo:rustc-link-lib=dylib=crypto");
}
}

View File

@ -1,6 +1,10 @@
#![allow(non_snake_case, non_camel_case_types)]
#![cfg_attr(test, allow(deref_nullptr))] // https://github.com/rust-lang/rust-bindgen/issues/2066
// force linking to openssl
#[cfg(feature = "bundled-sqlcipher-vendored-openssl")]
extern crate openssl_sys;
pub use self::error::*;
use std::default::Default;