-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
90 lines (69 loc) · 1.99 KB
/
build.js
File metadata and controls
90 lines (69 loc) · 1.99 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env node
'use strict';
let path = require('path'),
child_process = require('child_process'),
mkdirp = require('mkdirp'),
cmake = require('cmake-cli');
main();
function main() {
var os = (process.platform === 'win32') ? 'windows' : 'linux',
buildType = 'release';
[32, 64].forEach((bits) => {
cmakeGenerate(os, bits, buildType);
[1, 2, 3].forEach((i) => {
cmakeBuild(`exec${i}`, os, bits, buildType);
});
});
}
function cmakeGenerate(os, bits, buildType) {
let pkg = require(`${__dirname}/package.json`),
generator = pkg.generators[os] || '',
options = {
stdio: 'inherit',
cwd: path.join(__dirname, 'target', 'build', `${buildType}-${bits}`)
};
if (generator.indexOf('Visual Studio') > -1) {
if (bits === 64)
generator += ' Win64';
}
mkdirp.sync(options.cwd);
let args = [
'-G',
generator,
'-DCMAKE_BUILD_TYPE:STRING=' + buildType,
'-DTARGET_ARCH:STRING=' + bits,
__dirname
];
child_process.spawnSync(cmake.path(), args, options);
}
/*
function mkdirp(target) {
let dirs = [];
while (!fs.existsSync(target)) {
let temp = target.split(path.sep);
dirs.push(temp.pop());
target = temp.join(path.sep);
}
while (dirs.length > 0) {
target = path.join(target, dirs.pop());
fs.mkdirSync(target);
}
}
*/
function cmakeBuild(project, os, bits, buildType) {
let identifier = `${buildType}-${bits}`,
projectDir = path.join(__dirname, 'target', 'build', identifier),
options = {
stdio: 'inherit',
cwd: projectDir
};
let args = [
'--build',
projectDir,
'--target',
project,
'--config',
buildType
];
child_process.spawnSync(cmake.path(), args, options);
}