Bootstrap.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. var os = require('os');
  2. var path = require('path');
  3. // get the root folder
  4. var atomicRoot = path.resolve(__dirname, "../..") + "/";
  5. // patch in our local node_modules
  6. process.env.NODE_PATH = atomicRoot + "Build/node_modules/";
  7. require('module').Module._initPaths();
  8. var fs = require('fs-extra');
  9. // Load `jake` global
  10. require('../node_modules/jake/lib/jake');
  11. var config = require('./BuildConfig');
  12. var host = require('./Host');
  13. require('./BuildCommon');
  14. var cmd = config._[0];
  15. function printHelp() {
  16. console.log("\nAtomic Editor Build Script");
  17. console.log("--------------------------");
  18. console.log("--help : This help text");
  19. console.log("--with-android : Build with Android platform support");
  20. console.log("--with-ios : Build with iOS platform support");
  21. console.log("--with-web : Build with Web platform support");
  22. if (os.platform() == "win32") {
  23. console.log("--opengl : Enable OpenGL renderer");
  24. console.log("--d3d11 : Enable DirectX 11 renderer");
  25. }
  26. console.log("--debug : Build debug version of the editor and associated platform runtimes");
  27. console.log("--noclean : Do not clean before building, useful during development");
  28. console.log("--nonet : Build without AtomicNET C# scripting support");
  29. console.log("--with-docs : Build and install API documents into the editor (requires npm on path)");
  30. console.log("--noexamples : Don't include examples with editor");
  31. console.log("--task=name : Build the specified task (for development)");
  32. console.log("--package : packages the editor to Artifacts/Dist");
  33. console.log("--------------------------")
  34. process.exit(0);
  35. }
  36. if (config["help"]) {
  37. printHelp();
  38. }
  39. if (config["lint"]) {
  40. var lintTask = jake.Task['build:lint'];
  41. lintTask.invoke();
  42. }
  43. if (config["task"]) {
  44. var task = jake.Task[config["task"]];
  45. if (!task) {
  46. console.log("\nBUILD ERROR:\n\nUnknown task: " + config["task"] + "\n");
  47. process.exit(1);
  48. }
  49. cmd = "";
  50. task.invoke();
  51. }
  52. // Atomic Editor Build
  53. if (cmd == "buildeditor") {
  54. console.log("\n\nBuilding Atomic Editor, this process will take a few minutes\n");
  55. var buildTask = jake.Task['build:atomiceditor'];
  56. if (config["with-android"]) {
  57. if (!process.env.ANDROID_NDK) {
  58. console.log("\nANDROID_NDK environment variable not set, exiting\n");
  59. process.exit(1);
  60. }
  61. }
  62. if (config["with-web"]) {
  63. if (!process.env.EMSCRIPTEN) {
  64. console.log("\nEMSCRIPTEN environment variable not set, consider running 'source /Path/To/emsdk_env.sh', exiting\n");
  65. process.exit(1);
  66. }
  67. }
  68. if (config["with-ios"]) {
  69. if (os.platform() != "darwin") {
  70. console.log("\niOS platform requires macOS, exiting\n");
  71. process.exit(1);
  72. }
  73. }
  74. if (config["d3d11"] && config["opengl"]) {
  75. if (os.platform() == "win32") {
  76. console.log("\nBoth DirectX 11 and OpenGL flags specified. Please choose only one at a time.\nExiting...\n");
  77. process.exit(1);
  78. }
  79. }
  80. if (config["d3d11"]) {
  81. if (os.platform() != "win32") {
  82. console.log("\nDirectX 11 build requires Windows, exiting\n");
  83. process.exit(1);
  84. }
  85. else {
  86. console.log("\nDirectX 11 build selected.\n");
  87. }
  88. }
  89. if (config["opengl"]) {
  90. if (os.platform() != "win32") {
  91. console.log("\nOpenGL flag ignored, OpenGL is default on non-Windows platforms anyway.\nContinuing...\n");
  92. }
  93. else {
  94. console.log("\nOpenGL build selected.\n");
  95. }
  96. }
  97. buildTask.invoke();
  98. }