Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow openssldir to be configured. #220

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate cc;

use std::env;
use std::ffi::OsStr;
use std::ffi::{OsStr, OsString};
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand All @@ -18,6 +18,8 @@ pub struct Build {
out_dir: Option<PathBuf>,
target: Option<String>,
host: Option<String>,
// Only affects non-windows builds for now.
openssl_dir: Option<PathBuf>,
}

pub struct Artifacts {
Expand All @@ -34,6 +36,7 @@ impl Build {
out_dir: env::var_os("OUT_DIR").map(|s| PathBuf::from(s).join("openssl-build")),
target: env::var("TARGET").ok(),
host: env::var("HOST").ok(),
openssl_dir: Some(PathBuf::from("/usr/local/ssl")),
}
}

Expand All @@ -52,6 +55,11 @@ impl Build {
self
}

pub fn openssl_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Build {
self.openssl_dir = Some(path.as_ref().to_path_buf());
self
}

fn cmd_make(&self) -> Command {
let host = &self.host.as_ref().expect("HOST dir not set")[..];
if host.contains("dragonfly")
Expand Down Expand Up @@ -154,11 +162,18 @@ impl Build {

// Specify that openssl directory where things are loaded at runtime is
// not inside our build directory. Instead this should be located in the
// default locations of the OpenSSL build scripts.
// default locations of the OpenSSL build scripts, or as specified by whatever
// configured this builder.
if target.contains("windows") {
configure.arg("--openssldir=SYS$MANAGER:[OPENSSL]");
} else {
configure.arg("--openssldir=/usr/local/ssl");
let openssl_dir = self
.openssl_dir
.as_ref()
.expect("path to the openssl directory must be set");
let mut dir_arg: OsString = "--openssldir=".into();
dir_arg.push(openssl_dir);
configure.arg(dir_arg);
}

configure
Expand Down