Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions generate/templates/templates/binding.gyp
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
{
"conditions": [
["(OS=='win' and node_root_dir.split('\\\\')[-1].startswith('iojs')) or (OS=='mac' and node_root_dir.split('/')[-1].startswith('iojs'))", {
"variables": {
"is_electron%": "1",
}
}, {
"variables": {
"is_electron%": "0",
}
}]
],
"variables": {
"is_electron%": "<!(node ./utils/isBuildingForElectron.js <(node_root_dir))"
},

"targets": [
{
"target_name": "acquireOpenSSL",
"conditions": [
["<(is_electron) == 1", {
["<(is_electron) == 1 and OS != 'linux'", {
"actions": [{
"action_name": "acquire",
"action": ["node", "utils/acquireOpenSSL.js"],
Expand Down Expand Up @@ -168,7 +160,7 @@
}
],
[
"OS.endswith('bsd') or (node_root_dir.split('/')[-1].startswith('iojs') and OS=='linux')", {
"OS.endswith('bsd') or (<(is_electron) == 1 and OS=='linux')", {
"libraries": [
"-lcrypto",
"-lssl"
Expand Down
25 changes: 21 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
},
"dependencies": {
"fs-extra": "^7.0.0",
"json5": "^2.1.0",
"lodash": "^4.17.11",
"nan": "^2.11.1",
"node-gyp": "^3.8.0",
Expand Down
32 changes: 32 additions & 0 deletions utils/isBuildingForElectron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require("fs")
const JSON5 = require("json5");
const path = require("path");

if (process.argv.length < 3) {
process.exit(1);
}

const last = arr => arr[arr.length - 1];
const sep = process.platform === "win32" ? "\\\\" : "/";
const [, , nodeRootDir] = process.argv;

let isElectron = last(nodeRootDir.split(sep)).startsWith("iojs");

if (!isElectron) {
try {
// Not ideal, would love it if there were a full featured gyp package to do this operation instead.
const { variables: { built_with_electron } } = JSON5.parse(
fs.readFileSync(
path.resolve(nodeRootDir, "include", "node", "config.gypi"),
"utf8"
)
);

if (built_with_electron) {
isElectron = true;
}
} catch (e) {}
}

fs.writeFileSync("was_electron", isElectron ? "1" : "0");
process.stdout.write(isElectron ? "1" : "0");