BuildWindows.js 4.3 KB

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