Skip to content

Commit a09613c

Browse files
committed
Copy Windows / Darwin static configuration files into libssh as configure step
1 parent 0fe23f3 commit a09613c

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
/vendor/libssh2/example/stamp-h2
3030
/vendor/libssh2/libssh2.pc
3131
/vendor/libssh2/libtool
32+
/vendor/libssh2/darwin/
33+
/vendor/libssh2/win32/
3234
/vendor/libssh2/src/.deps/
3335
/vendor/libssh2/src/Makefile
3436
/vendor/libssh2/src/libssh2_config.h

utils/configureLibssh2.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
var cp = require("child_process");
2+
var fse = require('fs-extra');
23
var path = require("path");
3-
var rooted = function (dir) {
4-
var fullPath = path.join(__dirname, "..", dir);
5-
var escapedPathForShell = fullPath.replace(/ /g, "\\ ");
6-
return escapedPathForShell;
7-
};
4+
5+
const libssh2VendorDirectory = path.resolve(__dirname, "..", "vendor", "libssh2");
6+
const libssh2ConfigureScript = path.join(libssh2VendorDirectory, "configure");
7+
const libssh2StaticConfigDirectory = path.resolve(__dirname, "..", "vendor", "static_config", "libssh2");
88

99
module.exports = function retrieveExternalDependencies() {
10-
// Do not configure on Windows
11-
if (process.platform === "win32") {
12-
return Promise.resolve("");
10+
console.info("[nodegit] Configuring libssh2.");
11+
12+
// Copy Windows / Mac preconfigured files
13+
if (process.platform === "win32" || process.platform === "darwin") {
14+
return fse.copy(
15+
path.join(libssh2StaticConfigDirectory, process.platform),
16+
path.join(libssh2VendorDirectory, process.platform)
17+
);
1318
}
1419

20+
// Run the `configure` script on Linux
1521
return new Promise(function(resolve, reject) {
16-
console.info("[nodegit] Configuring libssh2.");
22+
1723
var opensslDir = process.argv[2];
1824
var isElectron = process.argv[3] === "1";
1925
var opensslIncludes = isElectron ? path.join(opensslDir, "includes") : opensslDir;
2026

2127
var newEnv = {};
22-
23-
// For some magic reason, MacOS fails to build if we copy over the current environment variables, but Linux
24-
// builds fail if we DON'T copy over the current environment variables
25-
if (process.platform !== "darwin") {
26-
Object.keys(process.env).forEach(function(key) {
27-
newEnv[key] = process.env[key];
28-
});
29-
}
28+
Object.keys(process.env).forEach(function(key) {
29+
newEnv[key] = process.env[key];
30+
});
3031

3132
newEnv.CPPFLAGS = newEnv.CPPFLAGS || "";
3233
newEnv.CPPFLAGS += ` -I${opensslIncludes}`;
@@ -38,8 +39,11 @@ module.exports = function retrieveExternalDependencies() {
3839
}
3940

4041
cp.exec(
41-
rooted("vendor/libssh2/configure") + maybeLibsslPrefix,
42-
{cwd: rooted("vendor/libssh2/"), env: newEnv},
42+
libssh2ConfigureScript + maybeLibsslPrefix,
43+
{
44+
cwd: libssh2VendorDirectory,
45+
env: newEnv
46+
},
4347
function(err, stdout, stderr) {
4448
if (err) {
4549
console.error(err);

vendor/libgit2.gyp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,16 @@
537537
]
538538
},
539539
"conditions": [
540-
["OS=='mac' and node_root_dir.split('/')[-1].startswith('iojs')", {
540+
["OS=='mac'", {
541541
"include_dirs": [
542-
"openssl/include"
542+
"libssh2/darwin"
543+
],
544+
"conditions": [
545+
["node_root_dir.split('/')[-1].startswith('iojs')", {
546+
"include_dirs": [
547+
"openssl/include",
548+
]
549+
}]
543550
]
544551
}],
545552
["OS=='win'", {

0 commit comments

Comments
 (0)