forked from prebuild/prebuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gypbuild.js
58 lines (53 loc) · 1.62 KB
/
gypbuild.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var napi = require('napi-build-utils')
var gyp = require('./gyp')
function runGyp (opts, target, cb) {
var args = ['node', 'index.js']
if (opts.backend === 'node-ninja') {
args.push('configure')
args.push('build')
args.push('--builddir=build/' + target)
} else {
args.push('rebuild')
}
if (napi.isNapiRuntime(opts.runtime)) {
args.push('--napi_build_version=' + target)
} else {
args.push('--target=' + target)
}
args.push('--target_arch=' + opts.arch)
if (opts.runtime === 'electron') {
args.push('--runtime=electron')
args.push('--dist-url=https://atom.io/download/electron')
} else if (opts.runtime === 'node-webkit') {
args.push('--runtime=node-webkit')
} else if (opts.runtime === 'node') {
// work around bug introduced in node 10's build https://github.com/nodejs/node-gyp/issues/1457
args.push('--build_v8_with_gn=false')
// work around the same kind of bug for node 11
args.push('--enable_lto=false')
}
if (opts.debug) args.push('--debug')
if (opts.format) args.push('--', '--format', opts.format)
gyp({
gyp: opts.gyp,
runtime: opts.runtime,
backend: opts.backend,
log: opts.log,
args: args,
filter: function (command) {
if (command.name === 'configure') {
return configurePreGyp(command, opts)
}
}
}, cb)
}
function configurePreGyp (command, opts) {
var binary = opts.pkg.binary
if (binary && binary.module_name) {
command.args.push('-Dmodule_name=' + binary.module_name)
}
if (binary && binary.module_path) {
command.args.push('-Dmodule_path=' + binary.module_path)
}
}
module.exports = runGyp