11extern crate cc;
22
33use std:: env;
4- use std:: ffi:: OsStr ;
4+ use std:: ffi:: { OsStr , OsString } ;
55use std:: fs;
66use std:: path:: { Path , PathBuf } ;
77use std:: process:: Command ;
@@ -18,6 +18,8 @@ pub struct Build {
1818 out_dir : Option < PathBuf > ,
1919 target : Option < String > ,
2020 host : Option < String > ,
21+ // Only affects non-windows builds for now.
22+ openssl_dir : Option < PathBuf > ,
2123}
2224
2325pub struct Artifacts {
@@ -34,6 +36,7 @@ impl Build {
3436 out_dir : env:: var_os ( "OUT_DIR" ) . map ( |s| PathBuf :: from ( s) . join ( "openssl-build" ) ) ,
3537 target : env:: var ( "TARGET" ) . ok ( ) ,
3638 host : env:: var ( "HOST" ) . ok ( ) ,
39+ openssl_dir : Some ( PathBuf :: from ( "/usr/local/ssl" ) ) ,
3740 }
3841 }
3942
@@ -52,6 +55,11 @@ impl Build {
5255 self
5356 }
5457
58+ pub fn openssl_dir < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Build {
59+ self . openssl_dir = Some ( path. as_ref ( ) . to_path_buf ( ) ) ;
60+ self
61+ }
62+
5563 fn cmd_make ( & self ) -> Command {
5664 let host = & self . host . as_ref ( ) . expect ( "HOST dir not set" ) [ ..] ;
5765 if host. contains ( "dragonfly" )
@@ -154,11 +162,18 @@ impl Build {
154162
155163 // Specify that openssl directory where things are loaded at runtime is
156164 // not inside our build directory. Instead this should be located in the
157- // default locations of the OpenSSL build scripts.
165+ // default locations of the OpenSSL build scripts, or as specified by whatever
166+ // configured this builder.
158167 if target. contains ( "windows" ) {
159168 configure. arg ( "--openssldir=SYS$MANAGER:[OPENSSL]" ) ;
160169 } else {
161- configure. arg ( "--openssldir=/usr/local/ssl" ) ;
170+ let openssl_dir = self
171+ . openssl_dir
172+ . as_ref ( )
173+ . expect ( "path to the openssl directory must be set" ) ;
174+ let mut dir_arg: OsString = "--openssldir=" . into ( ) ;
175+ dir_arg. push ( openssl_dir) ;
176+ configure. arg ( dir_arg) ;
162177 }
163178
164179 configure
0 commit comments