BuildWindows.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. var fs = require('fs-extra');
  2. var path = require("path");
  3. var host = require("./Host");
  4. var buildTasks = require("./BuildTasks");
  5. var config = require("./BuildConfig");
  6. var atomicRoot = config.atomicRoot;
  7. var buildDir = config.artifactsRoot + "Build/Windows/";
  8. var editorAppFolder = config.editorAppFolder
  9. function copyAtomicNET() {
  10. if (!config["with-atomicnet"])
  11. return;
  12. fs.copySync(atomicRoot + "Artifacts/AtomicNET/" + config["config"],
  13. editorAppFolder + "Resources/ToolData/AtomicNET/" + config["config"]);
  14. fs.copySync(atomicRoot + "Script/AtomicNET/AtomicProject.json",
  15. editorAppFolder + "Resources/ToolData/AtomicNET/Build/Projects/AtomicProject.json");
  16. }
  17. function copyAtomicEditor() {
  18. // Copy the Editor binaries
  19. fs.copySync(buildDir + "Source/AtomicEditor/" + config["config"],
  20. config.artifactsRoot + "AtomicEditor");
  21. // copy AtomicTool
  22. fs.copySync(buildDir + "Source/AtomicTool/" + config["config"] +"/AtomicTool.exe",
  23. editorAppFolder + "AtomicTool.exe");
  24. // We need some resources to run
  25. fs.copySync(atomicRoot + "Resources/CoreData",
  26. editorAppFolder + "Resources/CoreData");
  27. fs.copySync(atomicRoot + "Resources/PlayerData",
  28. editorAppFolder + "Resources/PlayerData");
  29. fs.copySync(atomicRoot + "Data/AtomicEditor",
  30. editorAppFolder + "Resources/ToolData");
  31. fs.copySync(atomicRoot + "Resources/EditorData",
  32. editorAppFolder + "Resources/EditorData");
  33. fs.copySync(atomicRoot + "Artifacts/Build/Resources/EditorData/AtomicEditor/EditorScripts",
  34. editorAppFolder + "Resources/EditorData/AtomicEditor/EditorScripts");
  35. fs.copySync(buildDir + "Source/AtomicPlayer/Application/" + config["config"] +"/AtomicPlayer.exe",
  36. editorAppFolder + "Resources/ToolData/Deployment/Windows/x64/AtomicPlayer.exe");
  37. fs.copySync(buildDir + "Source/AtomicPlayer/Application/" + config["config"] + "/D3DCompiler_47.dll",
  38. editorAppFolder + "Resources/ToolData/Deployment/Windows/x64/D3DCompiler_47.dll");
  39. copyAtomicNET();
  40. }
  41. namespace('build', function() {
  42. task('atomiceditor_phase2', {
  43. async: true
  44. }, function() {
  45. process.chdir(buildDir);
  46. var cmds = [];
  47. cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditorPhase2.bat " + config["config"]);
  48. jake.exec(cmds, function() {
  49. copyAtomicEditor();
  50. if (config.package) {
  51. jake.Task['package:windows_editor'].invoke();
  52. }
  53. complete();
  54. }, {
  55. printStdout: true
  56. });
  57. });
  58. // Builds a standalone Atomic Editor, which can be distributed out of build tree
  59. task('atomiceditor', {
  60. async: true
  61. }, function() {
  62. // Always cleanly create the editor target folder
  63. host.cleanCreateDir(editorAppFolder);
  64. // We clean atomicNET here as otherwise platform binaries would be deleted
  65. var createDirs = [config.artifactsRoot + "AtomicNET/", buildDir, host.getGenScriptRootDir()];
  66. var removeDirs = [config.artifactsRoot + "Build/Android/"];
  67. host.setupDirs(!config.noclean, createDirs, removeDirs);
  68. process.chdir(buildDir);
  69. var cmds = [];
  70. // Generate Atomic solution, AtomicTool binary, and script bindings
  71. cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditorPhase1.bat " + config["config"]);
  72. jake.exec(cmds, function() {
  73. var rootTask = jake.Task['build:atomiceditor_phase2'];
  74. buildTasks.installBuildTasks(rootTask);
  75. rootTask.addListener('complete', function () {
  76. console.log("\n\nAtomic Editor built to " + editorAppFolder + "\n\n");
  77. complete();
  78. });
  79. rootTask.invoke();
  80. }, {
  81. printStdout: true,
  82. printStderr: true
  83. });
  84. });
  85. // Generate a Visual Studio 2015 solution
  86. task('genvs2015', {
  87. async: true
  88. }, function(devBuild) {
  89. if (devBuild === undefined)
  90. devBuild = 1;
  91. var opengl = config["opengl"] ? "ON" : "OFF";
  92. var d3d11 = config["d3d11"] ? "ON" : "OFF";
  93. var slnRoot = path.resolve(atomicRoot, "") + "-VS2015\\";
  94. if (!fs.existsSync(slnRoot)) {
  95. jake.mkdirP(slnRoot);
  96. }
  97. process.chdir(slnRoot);
  98. var cmds = [];
  99. cmds.push(atomicRoot + "Build/Scripts/Windows/GenerateVS2015.bat " + atomicRoot + " " + devBuild + " " + opengl + " " + d3d11);
  100. jake.exec(cmds, function() {
  101. complete();
  102. }, {
  103. printStdout: true
  104. });
  105. });
  106. });// end of build namespace