Skip to content

Commit 20729e0

Browse files
committed
Backport
Back port #1623 and #1626
1 parent 3d7f274 commit 20729e0

5 files changed

Lines changed: 66 additions & 17 deletions

File tree

‎generate/templates/templates/binding.gyp‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
2+
"variables": {
3+
"is_electron%": "<!(node ./utils/isBuildingForElectron.js <(node_root_dir))"
4+
},
5+
26
"conditions": [
3-
["(OS=='win' and node_root_dir.split('\\\\')[-1].startswith('iojs')) or (OS=='mac' and node_root_dir.split('/')[-1].startswith('iojs'))", {
7+
["(OS=='win' or OS=='mac') and <(is_electron) == 1", {
48
"conditions": [
59
["OS=='win'", {
610
"variables": {
7-
"is_electron%": "1",
811
"openssl_include_dir%": "<(module_root_dir)\\vendor\\openssl"
912
}
1013
}, {
1114
"variables": {
12-
"is_electron%": "1",
1315
"openssl_include_dir%": "<(module_root_dir)/vendor/openssl"
1416
}
1517
}]
@@ -18,12 +20,10 @@
1820
"conditions": [
1921
["OS=='win'", {
2022
"variables": {
21-
"is_electron%": "0",
2223
"openssl_include_dir%": "<(node_root_dir)\\include\\node"
2324
}
2425
}, {
2526
"variables": {
26-
"is_electron%": "0",
2727
"openssl_include_dir%": "<(node_root_dir)/include/node"
2828
}
2929
}]
@@ -35,7 +35,7 @@
3535
{
3636
"target_name": "acquireOpenSSL",
3737
"conditions": [
38-
["<(is_electron) == 1", {
38+
["<(is_electron) == 1 and OS != 'linux'", {
3939
"actions": [{
4040
"action_name": "acquire",
4141
"action": ["node", "utils/acquireOpenSSL.js"],
@@ -121,7 +121,7 @@
121121
[
122122
"OS=='mac'", {
123123
"conditions": [
124-
["node_root_dir.split('/')[-1].startswith('iojs')", {
124+
["<(is_electron) == 1", {
125125
"include_dirs": [
126126
"vendor/openssl/include"
127127
],
@@ -147,7 +147,7 @@
147147
[
148148
"OS=='win'", {
149149
"conditions": [
150-
["node_root_dir.split('\\\\')[-1].startswith('iojs')", {
150+
["<(is_electron) == 1", {
151151
"include_dirs": ["vendor/openssl/include"],
152152
"libraries": [
153153
"<(module_root_dir)/vendor/openssl/lib/libcrypto.lib",
@@ -185,7 +185,7 @@
185185
}
186186
],
187187
[
188-
"OS=='linux' or OS.endswith('bsd')", {
188+
"OS.endswith('bsd') or (<(is_electron) == 1 and OS=='linux')", {
189189
"libraries": [
190190
"-lcrypto",
191191
"-lssl"

‎package-lock.json‎

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
},
4040
"dependencies": {
4141
"fs-extra": "^7.0.0",
42+
"json5": "^2.1.0",
4243
"lodash": "^4.17.11",
4344
"nan": "^2.11.1",
4445
"node-gyp": "^3.8.0",

‎utils/isBuildingForElectron.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const fs = require("fs")
2+
const JSON5 = require("json5");
3+
const path = require("path");
4+
5+
if (process.argv.length < 3) {
6+
process.exit(1);
7+
}
8+
9+
const last = arr => arr[arr.length - 1];
10+
const [, , nodeRootDir] = process.argv;
11+
12+
let isElectron = last(nodeRootDir.split(path.sep)).startsWith("iojs");
13+
14+
if (!isElectron) {
15+
try {
16+
// Not ideal, would love it if there were a full featured gyp package to do this operation instead.
17+
const { variables: { built_with_electron } } = JSON5.parse(
18+
fs.readFileSync(
19+
path.resolve(nodeRootDir, "include", "node", "config.gypi"),
20+
"utf8"
21+
)
22+
);
23+
24+
if (built_with_electron) {
25+
isElectron = true;
26+
}
27+
} catch (e) {}
28+
}
29+
30+
process.stdout.write(isElectron ? "1" : "0");

‎vendor/libgit2.gyp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"library%": "static_library",
88
"openssl_enable_asm%": 0, # only supported with the Visual Studio 2012 (VC11) toolchain.
99
"gcc_version%": 0,
10+
"is_electron%": "<!(node ../utils/isBuildingForElectron.js <(node_root_dir))",
1011
"is_clang%": 0
1112
},
1213
"targets": [
@@ -286,7 +287,7 @@
286287
"conditions": [
287288
["OS=='mac'", {
288289
"conditions": [
289-
["node_root_dir.split('/')[-1].startswith('iojs')", {
290+
["<(is_electron) == 1", {
290291
"include_dirs": [
291292
"openssl/include"
292293
]
@@ -362,7 +363,7 @@
362363
],
363364
},
364365
}],
365-
["node_root_dir.split('\\\\')[-1].startswith('iojs')", {
366+
["<(is_electron) == 1", {
366367
"include_dirs": ["openssl/include"]
367368
}]
368369
],
@@ -537,14 +538,14 @@
537538
]
538539
},
539540
"conditions": [
540-
["OS=='mac' and node_root_dir.split('/')[-1].startswith('iojs')", {
541+
["OS=='mac' and <(is_electron) == 1", {
541542
"include_dirs": [
542543
"openssl/include",
543544
]
544545
}],
545546
["OS=='win'", {
546547
"conditions": [
547-
["node_root_dir.split('\\\\')[-1].startswith('iojs')", {
548+
["<(is_electron) == 1", {
548549
"include_dirs": [
549550
"openssl/include"
550551
],

0 commit comments

Comments
 (0)