BuildWindows.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. // We clean atomicNET here as otherwise platform binaries would be deleted
  60. var createDirs = [config.artifactsRoot + "AtomicNET/", buildDir, editorAppFolder, host.getGenScriptRootDir()];
  61. var removeDirs = [config.artifactsRoot + "Build/Android/"];
  62. host.setupDirs(!config.noclean, createDirs, removeDirs);
  63. process.chdir(buildDir);
  64. var cmds = [];
  65. // Generate Atomic solution, AtomicTool binary, and script bindings
  66. cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditorPhase1.bat " + config["config"]);
  67. jake.exec(cmds, function() {
  68. var rootTask = jake.Task['build:atomiceditor_phase2'];
  69. buildTasks.installBuildTasks(rootTask);
  70. rootTask.addListener('complete', function () {
  71. console.log("\n\nAtomic Editor built to " + editorAppFolder + "\n\n");
  72. complete();
  73. });
  74. rootTask.invoke();
  75. }, {
  76. printStdout: true,
  77. printStderr: true
  78. });
  79. });
  80. // Generate a Visual Studio 2015 solution
  81. task('genvs2015', {
  82. async: true
  83. }, function(devBuild) {
  84. if (devBuild === undefined)
  85. devBuild = 1;
  86. var slnRoot = path.resolve(atomicRoot, "") + "-VS2015\\";
  87. if (!fs.existsSync(slnRoot)) {
  88. jake.mkdirP(slnRoot);
  89. }
  90. process.chdir(slnRoot);
  91. var cmds = [];
  92. cmds.push(atomicRoot + "Build/Scripts/Windows/GenerateVS2015.bat " + atomicRoot + " " + devBuild);
  93. jake.exec(cmds, function() {
  94. complete();
  95. }, {
  96. printStdout: true
  97. });
  98. });
  99. });// end of build namespace