Find path prefix to OpenSSL installed by Homebrew.
This commit is contained in:
parent
9e5dcb03f2
commit
e037c0fcb8
14
README.md
14
README.md
|
|
@ -48,25 +48,25 @@ make -j$(nproc)
|
||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
|
|
||||||
### OSX
|
### macOS
|
||||||
|
|
||||||
Although OpenSSL 0.9.8 is preinstalled on OSX this library is being phased out
|
Although OpenSSL 0.9.8 is preinstalled on macOS this library is being phased out
|
||||||
of OSX and this crate also does not support that version of OpenSSL. To use this
|
of macOS and this crate also does not support that version of OpenSSL. To use this
|
||||||
crate on OSX you'll need to install OpenSSL via some alternate means, typically
|
crate on macOS you'll need to install OpenSSL via some alternate means, typically
|
||||||
Homebrew:
|
Homebrew:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install openssl
|
brew install openssl
|
||||||
```
|
```
|
||||||
|
|
||||||
Occasionally an update of XCode or MacOS will cause the linker to fail after compilation, to rectify this you may want to try and run:
|
Occasionally an update of XCode or macOS will cause the linker to fail after compilation, to rectify this you may want to try and run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
xcode-select --install
|
xcode-select --install
|
||||||
```
|
```
|
||||||
|
|
||||||
If Homebrew is installed to the default location of `/usr/local`, OpenSSL will be
|
If you're using latest version of Homebrew which supports `--prefix` command,
|
||||||
automatically detected.
|
OpenSSL will be automatically detected.
|
||||||
|
|
||||||
### Windows MSVC
|
### Windows MSVC
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,8 @@ fn find_openssl_dir(target: &str) -> OsString {
|
||||||
let host = env::var("HOST").unwrap();
|
let host = env::var("HOST").unwrap();
|
||||||
|
|
||||||
if host == target && target.contains("apple-darwin") {
|
if host == target && target.contains("apple-darwin") {
|
||||||
|
// Check up default Homebrew installation location first
|
||||||
|
// for quick resolution if possible.
|
||||||
let homebrew = Path::new("/usr/local/opt/openssl@1.1");
|
let homebrew = Path::new("/usr/local/opt/openssl@1.1");
|
||||||
if homebrew.exists() {
|
if homebrew.exists() {
|
||||||
return homebrew.to_path_buf().into();
|
return homebrew.to_path_buf().into();
|
||||||
|
|
@ -112,6 +114,22 @@ fn find_openssl_dir(target: &str) -> OsString {
|
||||||
if homebrew.exists() {
|
if homebrew.exists() {
|
||||||
return homebrew.to_path_buf().into();
|
return homebrew.to_path_buf().into();
|
||||||
}
|
}
|
||||||
|
// Calling `brew --prefix <package>` command usually slow and
|
||||||
|
// takes seconds, and will be used only as a last resort.
|
||||||
|
let output = execute_command_and_get_output("brew", &["--prefix", "openssl@1.1"]);
|
||||||
|
if let Some(ref output) = output {
|
||||||
|
let homebrew = Path::new(&output);
|
||||||
|
if homebrew.exists() {
|
||||||
|
return homebrew.to_path_buf().into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let output = execute_command_and_get_output("brew", &["--prefix", "openssl"]);
|
||||||
|
if let Some(ref output) = output {
|
||||||
|
let homebrew = Path::new(&output);
|
||||||
|
if homebrew.exists() {
|
||||||
|
return homebrew.to_path_buf().into();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try_pkg_config();
|
try_pkg_config();
|
||||||
|
|
@ -548,3 +566,19 @@ fn determine_mode(libdir: &Path, libs: &[&str]) -> &'static str {
|
||||||
// practices with security libs", let's link dynamically.
|
// practices with security libs", let's link dynamically.
|
||||||
"dylib"
|
"dylib"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fn execute_command_and_get_output(cmd: &str, args: &[&str]) -> Option<String> {
|
||||||
|
let out = Command::new(cmd).args(args).output();
|
||||||
|
if let Ok(ref r1) = out {
|
||||||
|
if r1.status.success() {
|
||||||
|
let r2 = String::from_utf8(r1.stdout.clone());
|
||||||
|
if let Ok(r3) = r2 {
|
||||||
|
return Some(r3.trim().to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue