Skip to content

Commit 299414f

Browse files
authored
Merge pull request nodegit#1623 from implausible/fix/electron-4-builds
Handle new gyp information for electron builds
2 parents 7c11a12 + f8cdcf6 commit 299414f

4 files changed

Lines changed: 59 additions & 17 deletions

File tree

generate/templates/templates/binding.gyp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
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-
"variables": {
5-
"is_electron%": "1",
6-
}
7-
}, {
8-
"variables": {
9-
"is_electron%": "0",
10-
}
11-
}]
12-
],
2+
"variables": {
3+
"is_electron%": "<!(node ./utils/isBuildingForElectron.js <(node_root_dir))"
4+
},
135

146
"targets": [
157
{
168
"target_name": "acquireOpenSSL",
179
"conditions": [
18-
["<(is_electron) == 1", {
10+
["<(is_electron) == 1 and OS != 'linux'", {
1911
"actions": [{
2012
"action_name": "acquire",
2113
"action": ["node", "utils/acquireOpenSSL.js"],
@@ -168,7 +160,7 @@
168160
}
169161
],
170162
[
171-
"OS.endswith('bsd') or (node_root_dir.split('/')[-1].startswith('iojs') and OS=='linux')", {
163+
"OS.endswith('bsd') or (<(is_electron) == 1 and OS=='linux')", {
172164
"libraries": [
173165
"-lcrypto",
174166
"-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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 sep = process.platform === "win32" ? "\\\\" : "/";
11+
const [, , nodeRootDir] = process.argv;
12+
13+
let isElectron = last(nodeRootDir.split(sep)).startsWith("iojs");
14+
15+
if (!isElectron) {
16+
try {
17+
// Not ideal, would love it if there were a full featured gyp package to do this operation instead.
18+
const { variables: { built_with_electron } } = JSON5.parse(
19+
fs.readFileSync(
20+
path.resolve(nodeRootDir, "include", "node", "config.gypi"),
21+
"utf8"
22+
)
23+
);
24+
25+
if (built_with_electron) {
26+
isElectron = true;
27+
}
28+
} catch (e) {}
29+
}
30+
31+
fs.writeFileSync("was_electron", isElectron ? "1" : "0");
32+
process.stdout.write(isElectron ? "1" : "0");

0 commit comments

Comments
 (0)