From 830658ec0bdae8ba1f6310f2e8116750d01c1b82 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Sat, 4 Apr 2020 21:09:18 -0500 Subject: [PATCH 1/3] Add OPENSSL_NO_VENDOR env var check --- openssl-sys/build/main.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/openssl-sys/build/main.rs b/openssl-sys/build/main.rs index 162e11a6..9c4e6f40 100644 --- a/openssl-sys/build/main.rs +++ b/openssl-sys/build/main.rs @@ -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 { 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!( From d6772960a3611892f09fb2e84cb194e60abb9f04 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Sat, 4 Apr 2020 21:18:20 -0500 Subject: [PATCH 2/3] Add documentation for OPENSSL_NO_VENDOR --- openssl/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs index 59e65649..fd79379f 100644 --- a/openssl/src/lib.rs +++ b/openssl/src/lib.rs @@ -53,6 +53,8 @@ //! * `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 present, always find openssl in the system, even if the `vendored` feature is set by +//! the crate that's using this one. //! //! 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. From 517fc81d4053537188232fdef7329e9f2a95d28e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 5 Apr 2020 09:52:20 -0400 Subject: [PATCH 3/3] Update openssl/src/lib.rs --- openssl/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs index fd79379f..b4e647c0 100644 --- a/openssl/src/lib.rs +++ b/openssl/src/lib.rs @@ -53,8 +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 present, always find openssl in the system, even if the `vendored` feature is set by -//! the crate that's using this one. +//! * `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.