Merge pull request #1253 from coolreader18/no-vendor-env-var
Check for the OPENSSL_NO_VENDOR environment variable
This commit is contained in:
commit
b027f16031
|
|
@ -13,9 +13,9 @@ use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
mod cfgs;
|
mod cfgs;
|
||||||
|
|
||||||
#[cfg_attr(feature = "vendored", path = "find_vendored.rs")]
|
mod find_normal;
|
||||||
#[cfg_attr(not(feature = "vendored"), path = "find_normal.rs")]
|
#[cfg(feature = "vendored")]
|
||||||
mod find;
|
mod find_vendored;
|
||||||
|
|
||||||
enum Version {
|
enum Version {
|
||||||
Openssl11x,
|
Openssl11x,
|
||||||
|
|
@ -41,12 +41,24 @@ fn env(name: &str) -> Option<OsString> {
|
||||||
env_inner(&prefixed).or_else(|| env_inner(name))
|
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() {
|
fn main() {
|
||||||
check_rustc_versions();
|
check_rustc_versions();
|
||||||
|
|
||||||
let target = env::var("TARGET").unwrap();
|
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() {
|
if !Path::new(&lib_dir).exists() {
|
||||||
panic!(
|
panic!(
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@
|
||||||
//! * `OPENSSL_STATIC` - If set, the crate will statically link to OpenSSL rather than dynamically link.
|
//! * `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
|
//! * `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.
|
//! 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.
|
//! 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.
|
//! `X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR`), which can be useful when cross compiling.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue