Commit b89432a6 authored by Steven Fackler's avatar Steven Fackler
Browse files

Support homebrew openssl@3

parent 4707adca
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -22,23 +22,29 @@ pub fn get_openssl(target: &str) -> (PathBuf, PathBuf) {
}

fn resolve_with_wellknown_homebrew_location(dir: &str) -> Option<PathBuf> {
    let versions = ["openssl@3", "openssl@1.1"];

    // Check up default aarch 64 Homebrew installation location first
    // for quick resolution if possible.
    //  `pkg-config` on brew doesn't necessarily contain settings for openssl apparently.
    let homebrew = Path::new(dir).join("opt/openssl@1.1");
    for version in versions {
        let homebrew = Path::new(dir).join(format!("opt/{}", version));
        if homebrew.exists() {
            return Some(homebrew);
        }
    }

    for version in versions {
        // 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"]);
        let output = execute_command_and_get_output("brew", &["--prefix", version]);
        if let Some(ref output) = output {
            let homebrew = Path::new(&output);
            if homebrew.exists() {
                return Some(homebrew.to_path_buf());
            }
        }
    }

    None
}