| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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 default DX9)
- flags += " -DATOMIC_OPENGL=" + (config["opengl"] ? "ON" : "OFF");
- flags += " -DATOMIC_D3D11=" + (config["d3d11"] ? "ON" : "OFF");
- 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
|