Merge pull request #1253 from coolreader18/no-vendor-env-var

Check for the OPENSSL_NO_VENDOR environment variable
This commit is contained in:
Steven Fackler 2020-04-05 10:01:28 -04:00 committed by GitHub
commit b027f16031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -13,9 +13,9 @@ use std::path::{Path, PathBuf};
mod cfgs;
#[cfg_attr(feature = "vendored", path = "find_vendored.rs")]
#[cfg_attr(not(feature = "vendored"), path = "find_normal.rs")]
mod find;
mod find_normal;
#[cfg(feature = "vendored")]
mod find_vendored;
enum Version {
Openssl11x,
@ -41,12 +41,24 @@ fn env(name: &str) -> Option<OsString> {
env_inner(&prefixed).or_else(|| env_inner(name))
}
fn find_openssl(target: &str) -> (PathBuf, PathBuf) {
#[cfg(feature = "vendored")]
{
// vendor if the feature is present, unless
// OPENSSL_NO_VENDOR exists and isn't `0`
if env("OPENSSL_NO_VENDOR").map_or(true, |s| s == "0") {
return find_vendored::get_openssl(target);
}
}
find_normal::get_openssl(target)
}
fn main() {
check_rustc_versions();
let target = env::var("TARGET").unwrap();
let (lib_dir, include_dir) = find::get_openssl(&target);
let (lib_dir, include_dir) = find_openssl(&target);
if !Path::new(&lib_dir).exists() {
panic!(

View File

@ -53,6 +53,7 @@
//! * `OPENSSL_STATIC` - If set, the crate will statically link to OpenSSL rather than dynamically link.
//! * `OPENSSL_LIBS` - If set, a `:`-separated list of library names to link to (e.g. `ssl:crypto`). This can be used
//! if nonstandard library names were used for whatever reason.
//! * `OPENSSL_NO_VENDOR` - If set, always find OpenSSL in the system, even if the `vendored` feature is enabled.
//!
//! Additionally, these variables can be prefixed with the upper-cased target architecture (e.g.
//! `X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR`), which can be useful when cross compiling.