Bootstrap.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. // Check that we're in a local repo and not a downloaded zip
  16. if (!fs.existsSync(atomicRoot + ".git")) {
  17. console.log("\nBUILD ERROR:\n\nAtomic must be built from a local git clone for submodules and git build information.\n");
  18. console.log("Please see: https://github.com/AtomicGameEngine/AtomicGameEngine/wiki/Building-Atomic-from-Source");
  19. process.exit(1);
  20. }
  21. function printHelp() {
  22. console.log("\nAtomic Editor Build Script");
  23. console.log("--------------------------");
  24. console.log("--help : This help text");
  25. console.log("--with-android : Build with Android platform support");
  26. console.log("--with-ios : Build with iOS platform support");
  27. console.log("--with-web : Build with Web platform support");
  28. console.log("--debug : Build debug version of the editor and associated platform runtimes");
  29. console.log("--noclean : Do not clean before building, useful during development");
  30. console.log("--nonet : Build without AtomicNET C# scripting support");
  31. console.log("--with-docs : Build and install API documents into the editor (requires npm on path)");
  32. console.log("--noexamples : Don't include examples with editor");
  33. console.log("--task=name : Build the specified task (for development)");
  34. console.log("--package : packages the editor to Artifacts/Dist");
  35. if (os.platform() == "win32") {
  36. console.log("--vs2015 : Build with VS2015");
  37. console.log("--vs2017 : Build with VS2017");
  38. console.log("--opengl : Enable OpenGL renderer");
  39. console.log("--d3d9 : Enable DirectX 9 renderer");
  40. }
  41. console.log("--------------------------")
  42. process.exit(0);
  43. }
  44. if (config["help"]) {
  45. printHelp();
  46. }
  47. if (config["lint"]) {
  48. var lintTask = jake.Task['build:lint'];
  49. lintTask.invoke();
  50. }
  51. if (config["task"]) {
  52. var task = jake.Task[config["task"]];
  53. if (!task) {
  54. console.log("\nBUILD ERROR:\n\nUnknown task: " + config["task"] + "\n");
  55. process.exit(1);
  56. }
  57. cmd = "";
  58. task.invoke();
  59. }
  60. // Atomic Editor Build
  61. if (cmd == "buildeditor") {
  62. console.log("\n\nBuilding Atomic Editor, this process will take a few minutes\n");
  63. var buildTask = jake.Task['build:atomiceditor'];
  64. if (config["with-android"]) {
  65. if (!process.env.ANDROID_NDK) {
  66. console.log("\nANDROID_NDK environment variable not set, exiting\n");
  67. process.exit(1);
  68. }
  69. }
  70. if (config["with-web"]) {
  71. if (!process.env.EMSCRIPTEN) {
  72. console.log("\nEMSCRIPTEN environment variable not set, consider running 'source /Path/To/emsdk_env.sh', exiting\n");
  73. process.exit(1);
  74. }
  75. }
  76. if (config["with-ios"]) {
  77. if (os.platform() != "darwin") {
  78. console.log("\niOS platform requires macOS, exiting\n");
  79. process.exit(1);
  80. }
  81. }
  82. if (config["d3d9"] && config["opengl"]) {
  83. if (os.platform() == "win32") {
  84. console.log("\nBoth DirectX 9 and OpenGL flags specified. Please choose only one at a time.\nExiting...\n");
  85. process.exit(1);
  86. }
  87. }
  88. if (config["d3d9"]) {
  89. if (os.platform() != "win32") {
  90. console.log("\nDirectX 9 build requires Windows, exiting\n");
  91. process.exit(1);
  92. }
  93. else {
  94. console.log("\nDirectX 9 build selected.\n");
  95. }
  96. }
  97. if (config["opengl"]) {
  98. if (os.platform() != "win32") {
  99. console.log("\nOpenGL flag ignored, OpenGL is default on non-Windows platforms anyway.\nContinuing...\n");
  100. }
  101. else {
  102. console.log("\nOpenGL build selected.\n");
  103. }
  104. }
  105. buildTask.invoke();
  106. }