diff options
| author | Steven Fackler <[email protected]> | 2016-12-12 11:44:51 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-12-12 11:44:51 -0800 |
| commit | b310e594cdb48f3bb1214739ba9179e6ab2e071b (patch) | |
| tree | 4a8d5024ee5229f4f09c9bcbcffeae50ccc77746 | |
| parent | Fix ErrorStack display (diff) | |
| parent | Allow OPENSSL_{LIB,INCLUDE}_DIR to override OPENSSL_DIR (diff) | |
| download | rust-openssl-b310e594cdb48f3bb1214739ba9179e6ab2e071b.tar.xz rust-openssl-b310e594cdb48f3bb1214739ba9179e6ab2e071b.zip | |
Merge pull request #531 from aidanhs/aphs-lib-include-dirs
Allow OPENSSL_{LIB,INCLUDE}_DIR to override OPENSSL_DIR
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | openssl-sys/build.rs | 20 |
2 files changed, 20 insertions, 6 deletions
@@ -102,6 +102,12 @@ The build script can be configured via environment variables: * `OPENSSL_DIR` - If specified, a directory that will be used to find OpenSSL installation. It's expected that under this directory the `include` folder has header files and a `lib` folder has the runtime libraries. +* `OPENSSL_LIB_DIR` - If specified, a directory that will be used to find + OpenSSL libraries. Overrides the `lib` folder implied by `OPENSSL_DIR` + (if specified). +* `OPENSSL_INCLUDE_DIR` - If specified, a directory that will be used to find + OpenSSL header files. Overrides the `include` folder implied by `OPENSSL_DIR` + (if specified). * `OPENSSL_STATIC` - If specified, OpenSSL libraries will be statically rather than dynamically linked. diff --git a/openssl-sys/build.rs b/openssl-sys/build.rs index b6c8c2de..ce173192 100644 --- a/openssl-sys/build.rs +++ b/openssl-sys/build.rs @@ -11,17 +11,25 @@ use std::process::Command; fn main() { let target = env::var("TARGET").unwrap(); - let openssl_dir = env::var_os("OPENSSL_DIR").unwrap_or_else(|| { - find_openssl_dir(&target) - }); + let lib_dir = env::var_os("OPENSSL_LIB_DIR").map(PathBuf::from); + let include_dir = env::var_os("OPENSSL_INCLUDE_DIR").map(PathBuf::from); + + let (lib_dir, include_dir) = if lib_dir.is_none() || include_dir.is_none() { + let openssl_dir = env::var_os("OPENSSL_DIR").unwrap_or_else(|| { + find_openssl_dir(&target) + }); + let openssl_dir = Path::new(&openssl_dir); + let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib")); + let include_dir = include_dir.unwrap_or_else(|| openssl_dir.join("include")); + (lib_dir, include_dir) + } else { + (lib_dir.unwrap(), include_dir.unwrap()) + }; - let lib_dir = Path::new(&openssl_dir).join("lib"); - let include_dir = Path::new(&openssl_dir).join("include"); if !Path::new(&lib_dir).exists() { panic!("OpenSSL library directory does not exist: {}", lib_dir.to_string_lossy()); } - if !Path::new(&include_dir).exists() { panic!("OpenSSL include directory does not exist: {}", include_dir.to_string_lossy()); |