Skip to content

Commit 136dace

Browse files
committed
WIP on action for acquiring OpenSSL
1 parent d3698fd commit 136dace

File tree

4 files changed

+73
-18
lines changed

4 files changed

+73
-18
lines changed

generate/templates/templates/binding.gyp

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,69 @@
11
{
2+
"conditions": [
3+
["(OS=='win' and node_root_dir.split('\\\\')[-1].startswith('iojs')) or (OS=='mac' and node_root_dir.split('/')[-1].startswith('iojs'))", {
4+
"conditions": [
5+
["OS=='win'", {
6+
"variables": {
7+
"is_electron%": "1",
8+
"openssl_include_dir%": "<(module_root_dir)\\vendor\\openssl"
9+
}
10+
}, {
11+
"variables": {
12+
"is_electron%": "1",
13+
"openssl_include_dir%": "<(module_root_dir)/vendor/openssl"
14+
}
15+
}]
16+
],
17+
}, {
18+
"conditions": [
19+
["OS=='win'", {
20+
"variables": {
21+
"is_electron%": "0",
22+
"openssl_include_dir%": "<(node_root_dir)\\include\\node"
23+
}
24+
}, {
25+
"variables": {
26+
"is_electron%": "0",
27+
"openssl_include_dir%": "<(node_root_dir)/include/node"
28+
}
29+
}]
30+
]
31+
}]
32+
],
33+
234
"targets": [
35+
{
36+
"target_name": "acquireOpenSSL",
37+
"conditions": [
38+
["<(is_electron) == 1", {
39+
"actions": [{
40+
"action_name": "acquire",
41+
"action": ["node", "utils/acquireOpenSSL.js"],
42+
"inputs": ["vendor/openssl_distributions.json"],
43+
"outputs": ["vendor/openssl"]
44+
}]
45+
}]
46+
]
47+
},
48+
{
49+
"target_name": "configureLibssh2",
50+
"actions": [{
51+
"action_name": "configure",
52+
"action": ["node", "utils/configureLibssh2.js", "<(openssl_include_dir)", "<(is_electron)"],
53+
"inputs": [""],
54+
"outputs": [""]
55+
}],
56+
"hard_dependencies": [
57+
"acquireOpenSSL"
58+
]
59+
},
360
{
461
"target_name": "nodegit",
562

63+
"hard_dependencies": [
64+
"configureLibssh2"
65+
],
66+
667
"dependencies": [
768
"vendor/libgit2.gyp:libgit2"
869
],
@@ -64,8 +125,8 @@
64125
"vendor/openssl/include"
65126
],
66127
"libraries": [
67-
"<(module_root_dir)/vendor/openssl/lib/libcrypto.a",
68-
"<(module_root_dir)/vendor/openssl/lib/libssl.a"
128+
"<(module_root_dir)/vendor/openssl/lib/libcrypto.dylib",
129+
"<(module_root_dir)/vendor/openssl/lib/libssl.dylib"
69130
]
70131
}]
71132
],

lifecycleScripts/preinstall.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ var path = require("path");
22
var local = path.join.bind(path, __dirname);
33

44
var exec = require(local("../utils/execPromise"));
5-
var configure = require(local("configureLibssh2"));
65
var buildFlags = require(local("../utils/buildFlags"));
76

87
module.exports = function prepareForBuild() {
@@ -17,9 +16,6 @@ module.exports = function prepareForBuild() {
1716

1817
return Promise.resolve();
1918
})
20-
.then(function() {
21-
return configure();
22-
})
2319
.then(function() {
2420
if (buildFlags.isGitRepo) {
2521
var submodules = require(local("submodules"));

utils/acquireOpenSSL.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const fs = require('fs');
21
const fse = require('fs-extra');
32
const path = require('path');
43
const R = require('ramda');
@@ -7,7 +6,7 @@ const stream = require('stream');
76
const tar = require('tar-fs');
87
const zlib = require('zlib');
98

10-
const vendorPath = path.resolve('..', 'vendor');
9+
const vendorPath = path.resolve(__dirname, '..', 'vendor');
1110
const distrosFilePath = path.join(vendorPath, 'openssl_distributions.json');
1211
const extractPath = path.join(vendorPath, 'openssl');
1312

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,21 @@ module.exports = function retrieveExternalDependencies() {
1313

1414
return new Promise(function(resolve, reject) {
1515
console.info("[nodegit] Configuring libssh2.");
16-
var opensslDir;
17-
18-
if (process.platform === "darwin") {
19-
opensslDir = "vendor/openssl";
20-
}
16+
var opensslDir = process.argv[2];
17+
var isElectron = process.argv[3] === "1";
18+
var opensslIncludes = isElectron ? path.join(opensslDir, "includes") : opensslDir;
2119

2220
var newEnv = {};
2321
Object.keys(process.env).forEach(function(key) {
2422
newEnv[key] = process.env[key];
2523
});
2624

25+
newEnv.CPPFLAGS = newEnv.CPPFLAGS || "";
26+
newEnv.CPPFLAGS += ` -I${opensslIncludes}`;
27+
newEnv.CPPFLAGS = newEnv.CPPFLAGS.trim();
28+
2729
var maybeLibsslPrefix = "";
28-
if (opensslDir) {
29-
newEnv.CPPFLAGS = newEnv.CPPFLAGS || "";
30-
newEnv.CPPFLAGS += " -I" + path.join(opensslDir, "include");
31-
newEnv.CPPFLAGS = newEnv.CPPFLAGS.trim();
30+
if (isElectron) {
3231
maybeLibsslPrefix = ` --with-libssl-prefix=${opensslDir}`;
3332
}
3433

@@ -55,6 +54,6 @@ if (require.main === module) {
5554
console.log("nothing to do");
5655
}
5756
else {
58-
module.exports().done();
57+
module.exports();
5958
}
6059
}

0 commit comments

Comments
 (0)