(maint) Recreate ability to pass in OPENSSL_LIBS variable

Prior to this commit in 43c951f743 the
ability to pass OPENSSL_LIBS was removed from the build.rs of
openssl-sys. This commit adds the ability to pass custom names for the
OPENSSL_LIBS back in. This is useful for when building openssl across
linux and windows with the same lib names (ssl:crypto) and the default
names provided by the build script are not valid.
This commit is contained in:
Andrew Roetker 2017-03-13 15:59:01 -06:00
parent 06b10a5753
commit 663547a758
2 changed files with 15 additions and 6 deletions

View File

@ -133,6 +133,8 @@ The build script can be configured via environment variables:
(if specified). (if specified).
* `OPENSSL_STATIC` - If specified, OpenSSL libraries will be statically rather * `OPENSSL_STATIC` - If specified, OpenSSL libraries will be statically rather
than dynamically linked. than dynamically linked.
* `OPENSSL_LIBS` - If specified, the names of the OpenSSL libraries that will be
linked, e.g. `ssl:crypto`.
If `OPENSSL_DIR` is specified, then the build script will skip the pkg-config If `OPENSSL_DIR` is specified, then the build script will skip the pkg-config
step. step.

View File

@ -65,16 +65,23 @@ fn main() {
let version = validate_headers(&[include_dir.clone().into()]); let version = validate_headers(&[include_dir.clone().into()]);
let libs = match version { let libs_env = env::var("OPENSSL_LIBS").ok();
Version::Openssl101 | Version::Openssl102 if target.contains("windows") => { let libs = match libs_env {
["ssleay32", "libeay32"] Some(ref v) => v.split(":").collect(),
None => {
match version {
Version::Openssl101 | Version::Openssl102 if target.contains("windows") => {
vec!["ssleay32", "libeay32"]
}
Version::Openssl110 if target.contains("windows") => vec!["libssl", "libcrypto"],
_ => vec!["ssl", "crypto"],
}
} }
Version::Openssl110 if target.contains("windows") => ["libssl", "libcrypto"],
_ => ["ssl", "crypto"],
}; };
let kind = determine_mode(Path::new(&lib_dir), &libs); let kind = determine_mode(Path::new(&lib_dir), &libs);
for lib in libs.iter() { for lib in libs.into_iter() {
println!("cargo:rustc-link-lib={}={}", kind, lib); println!("cargo:rustc-link-lib={}={}", kind, lib);
} }
} }