forked from prebuild/prebuild
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmakebuild.js
43 lines (36 loc) · 1.11 KB
/
cmakebuild.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
var spawn = require('child_process').spawn
var which = require('npm-which')(process.cwd())
function runCmake (opts, target, cb) {
which('cmake-js', function (err, cmakeJsPath) {
if (err) return cb(err)
var args = ['rebuild']
if (opts.runtime !== 'napi') args.push('--runtime-version=' + target)
args.push('--arch=' + opts.arch)
if (opts.runtime !== 'napi') args.push('--runtime=' + opts.runtime)
if (opts.runtime === 'napi' && target) {
args.push('--CDnapi_build_version=' + target)
}
if (opts.debug) args.push('--debug')
// Just get this working
args.push('--target');
args.push('install');
var foundRest = false
for (var arg of opts.argv) {
if (arg === '--') {
foundRest = true
} else if (foundRest) {
args.push(arg)
}
}
var proc = spawn(cmakeJsPath, args)
proc.stdout.pipe(process.stdout)
proc.stderr.pipe(process.stderr)
proc.on('exit', function (code) {
if (code !== 0) {
return cb(new Error('Failed to build cmake with exit code ' + code))
}
cb()
})
})
}
module.exports = runCmake