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

View File

@ -1,6 +1,10 @@
#![allow(non_snake_case, non_camel_case_types)] #![allow(non_snake_case, non_camel_case_types)]
#![cfg_attr(test, allow(deref_nullptr))] // https://github.com/rust-lang/rust-bindgen/issues/2066 #![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::*; pub use self::error::*;
use std::default::Default; use std::default::Default;