forked from AtomicGameEngine/AtomicGameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeWindows.js
More file actions
104 lines (70 loc) · 2.5 KB
/
CMakeWindows.js
File metadata and controls
104 lines (70 loc) · 2.5 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var fs = require('fs-extra');
var path = require("path");
var host = require("./Host");
var buildTasks = require("./BuildTasks");
var config = require("./BuildConfig");
const nodeSpawn = require('child_process').spawn;
var atomicRoot = config.atomicRoot;
var buildDir = config.artifactsRoot + "Build/Windows/";
var editorAppFolder = config.editorAppFolder
namespace('build', function() {
// converts / to \ and removes trailing slash
function fixpath(path) {
return path.replace(/\//g, "\\").replace(/\\$/, "");
}
// get CMake flags for generator, vsver parameter can be VS2017/VS2015, etc
function getCMakeFlags(vsver) {
// local cmake builds are always dev builds
var flags = "-DATOMIC_DEV_BUILD=1";
// graphics backend overrides, defaults DX11
flags += " -DATOMIC_OPENGL=" + (config["opengl"] ? "ON" : "OFF");
flags += " -DATOMIC_D3D11=" + (config["d3d9"] ? "OFF" : "ON");
return flags;
}
// spawn cmake process
function spawnCMake(vsver) {
host.cleanCreateDir(atomicRoot + "/Artifacts/Build/Source/Generated");
var slnRoot = fixpath(path.resolve(atomicRoot, "") + "-" + vsver);
// we're running cmd.exe, this exits the shell when the command have finished
var args = ["/C"];
// Windows batch file which runs cmake
args.push(fixpath(atomicRoot + "\\Build\\Scripts\\Windows\\GenerateVSSolution.bat"));
// vsver VS2015/VS2017
args.push(vsver);
// Atomic root source dir
args.push(fixpath(atomicRoot));
// Folder to put generated solution in
args.push(fixpath(slnRoot));
// CMake flags
args.push(getCMakeFlags(vsver));
// we're using nodeSpawn here instead of jake.exec as the later was having much trouble with quotes
var cmakeProcess = nodeSpawn("cmd.exe", args);
cmakeProcess.stdout.on('data', (data) => {
process.stdout.write(data.toString());
});
cmakeProcess.stderr.on('data', (data) => {
process.stdout.write(data.toString());
});
cmakeProcess.on('exit', (code) => {
if (code != 0) {
fail(`CMake process exited with code ${code}`);
}
console.log("\n\n" + vsver + " solution created in " + fixpath(slnRoot) + "\n\n");
complete();
});
}
task('genvs2017', {
async: true
}, function() {
spawnCMake("VS2017");
}, {
printStdout: true,
printStderr: true
});
// Generate a Visual Studio 2015 solution
task('genvs2015', {
async: true
}, function() {
spawnCMake("VS2015");
});
});// end of build namespace