@@ -6,25 +6,45 @@ var rooted = function (dir) {
66 return escapedPathForShell ;
77} ;
88
9+ var isWin64 = function ( ) {
10+ return process . platform === "win32" && (
11+ process . arch === "x64" ||
12+ process . env . hasOwnProperty ( "PROCESSOR_ARCHITEW6432" )
13+ ) ;
14+ } ;
15+
916module . exports = function retrieveExternalDependencies ( ) {
1017 if ( process . platform === "win32" ) {
1118 return Promise . resolve ( "" ) ;
1219 }
1320
1421 return new Promise ( function ( resolve , reject ) {
1522 console . info ( "[nodegit] Configuring libssh2." ) ;
16- var opensslDir = rooted ( "vendor/openssl/openssl" ) ;
23+ var opensslDir ;
24+
25+ if ( process . platform === "darwin" ) {
26+ opensslDir = "/usr/local/opt/openssl@1.1" ;
27+ } else if ( process . platform === "win32" ) {
28+ opensslDir = path . join ( process . cwd ( ) , "vendor" , "win" , "openssl" ) ;
29+ }
30+
1731 var newEnv = { } ;
1832 Object . keys ( process . env ) . forEach ( function ( key ) {
1933 newEnv [ key ] = process . env [ key ] ;
2034 } ) ;
21- newEnv . CPPFLAGS = newEnv . CPPFLAGS || "" ;
22- newEnv . CPPFLAGS += " -I" + path . join ( opensslDir , "include" ) ;
23- newEnv . CPPFLAGS = newEnv . CPPFLAGS . trim ( ) ;
35+
36+ const includeDirName = isWin64 ( ) ? "include64" : "include" ;
37+
38+ var maybeLibsslPrefix = "" ;
39+ if ( opensslDir ) {
40+ newEnv . CPPFLAGS = newEnv . CPPFLAGS || "" ;
41+ newEnv . CPPFLAGS += " -I" + path . join ( opensslDir , includeDirName ) ;
42+ newEnv . CPPFLAGS = newEnv . CPPFLAGS . trim ( ) ;
43+ maybeLibsslPrefix = ` --with-libssl-prefix=${ opensslDir } ` ;
44+ }
2445
2546 cp . exec (
26- rooted ( "vendor/libssh2/configure" ) +
27- " --with-libssl-prefix=" + opensslDir ,
47+ rooted ( "vendor/libssh2/configure" ) + maybeLibsslPrefix ,
2848 { cwd : rooted ( "vendor/libssh2/" ) , env : newEnv } ,
2949 function ( err , stdout , stderr ) {
3050 if ( err ) {
0 commit comments