Unverified Commit b027f160 authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

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

Check for the OPENSSL_NO_VENDOR environment variable
parents 9c8e7cdd 517fc81d
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -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!(
+1 −0
Original line number Diff line number Diff line
@@ -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.