Browse Source

Build cleanups, get doc generating on Windows/Linux (+6 squashed commits)
Squashed commits:
[5dbc137] Getting doc generation working on Linux, build updates
[a3d9776] Note about tsdoc issue on Windows
[97a7834] Build updates, make doc generation work on Windows
[ec96775] Add option to run a specified build task
[1b28bb5] More build updates
[5395dc1] Build cleanups (WIP)

Josh Engebretson 9 years ago
parent
commit
69f7dfe177

+ 39 - 22
Build/Scripts/Bootstrap.js

@@ -1,53 +1,70 @@
 var os = require('os');
+var path = require('path');
+
+// get the root folder
+var atomicRoot = path.resolve(__dirname, "../..") + "/";
+
+// patch in our local node_modules
+process.env.NODE_PATH = atomicRoot + "Build/node_modules/";
+require('module').Module._initPaths();
+
 var fs = require('fs-extra');
 
 // Load `jake` global
 require('../node_modules/jake/lib/jake');
 
-// Load jake tasks, patch in our node modules, etc
+var config = require('./BuildConfig');
 var host = require('./Host');
+require('./BuildCommon');
 
-// Parse args
-var options = require('minimist')(process.argv.slice(2));
-var cmd = options._[0];
-
-
-
-// Make options availabe to host
-host.options = options;
+var cmd = config._[0];
 
 function printHelp() {
 
-    console.log("\nAtomic Editor Build Script")
-    console.log("--------------------------")
-    console.log("--help          : This help text")
+    console.log("\nAtomic Editor Build Script");
+    console.log("--------------------------");
+    console.log("--help          : This help text");
     console.log("--with-android  : Build with Android platform support");
     console.log("--with-ios      : Build with iOS platform support");
-    console.log("--debug         : Build debug version of the editor and associated platform runtimes")
-    console.log("--noclean       : Do not clean before building, useful during development")
-    console.log("--nonet         : Build without AtomicNET C# scripting support")
-    console.log("--with-docs     : Build and install API documents into the editor")
-    console.log("--with-examples : Install examples into the editor")
+    console.log("--debug         : Build debug version of the editor and associated platform runtimes");
+    console.log("--noclean       : Do not clean before building, useful during development");
+    console.log("--nonet         : Build without AtomicNET C# scripting support");
+    console.log("--with-docs     : Build and install API documents into the editor (requires npm on path)");
+    console.log("--with-examples : Install examples into the editor (require git on path)");
+    console.log("--task=name     : Build the specified task (for development)");
     console.log("--------------------------")
 
     process.exit(0);
 }
 
-if (options["help"]) {
+if (config["help"]) {
     printHelp();
 }
 
-if (options["lint"]) {
+if (config["lint"]) {
     var lintTask = jake.Task['build:lint'];
     lintTask.invoke();
 }
 
+if (config["task"]) {
+
+    var task = jake.Task[config["task"]];
+
+    if (!task) {
+        console.log("\nBUILD ERROR:\n\nUnknown task: " + config["task"] + "\n");
+        process.exit(1);
+    }
+
+    cmd = "";
+    task.invoke();
+}
+
 // Atomic Editor Build
 if (cmd == "buildeditor") {
 
     // simple build check for submodules not being initialized
 
-    if (!fs.existsSync(host.atomicRoot + "Submodules/CEF/Windows")) {
+    if (!fs.existsSync(config.atomicRoot + "Submodules/CEF/Windows")) {
 
         console.log("\nBUILD ERROR:\n\nSubmodules not initialized.  When cloning repository, please use:\ngit clone --recursive https://github.com/AtomicGameEngine/AtomicGameEngine\n")
         process.exit(1);
@@ -57,7 +74,7 @@ if (cmd == "buildeditor") {
 
     var buildTask = jake.Task['build:atomiceditor'];
 
-    if (options["with-android"]) {
+    if (config["with-android"]) {
 
         if (!process.env.ANDROID_NDK) {
             console.log("\nANDROID_NDK environment variable not set, exiting\n");
@@ -65,7 +82,7 @@ if (cmd == "buildeditor") {
         }
     }
 
-    if (options["with-ios"]) {
+    if (config["with-ios"]) {
 
         if (os.platform() != "darwin") {
             console.log("\niOS platform requires macOS, exiting\n");

+ 8 - 13
Build/Scripts/BuildAndroid.js

@@ -1,10 +1,11 @@
+var os = require('os');
 var fs = require('fs-extra');
 var path = require("path");
 var host = require("./Host");
-var os = require('os');
+var config = require('./BuildConfig');
 
-var atomicRoot = host.atomicRoot;
-var buildDir = host.artifactsRoot + "Build/Android/";
+var atomicRoot = config.atomicRoot;
+var buildDir = config.artifactsRoot + "Build/Android/";
 
 namespace('build', function() {
 
@@ -12,29 +13,23 @@ namespace('build', function() {
         async: true
     }, function() {
 
-        var options = host.options;
-        var cleanBuild = options["noclean"] ? false : true;
-        var debug = options["debug"] ? true : false;
-        var config = debug ? "Debug" : "Release";
-
-
-        host.setupDirs(cleanBuild, [buildDir]);
+        host.setupDirs(!config["noclean"], [buildDir]);
 
         process.chdir(buildDir);
 
         var cmds = [];
 
         if (os.platform() == "win32") {
-            cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAndroid.bat " + config);
+            cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAndroid.bat " + config["config"]);
         }
         else {
-            cmds.push("cmake -G \"Unix Makefiles\" -DCMAKE_TOOLCHAIN_FILE=../../../Build/CMake/Toolchains/android.toolchain.cmake -DCMAKE_BUILD_TYPE="  + config + " ../../../");
+            cmds.push("cmake -G \"Unix Makefiles\" -DCMAKE_TOOLCHAIN_FILE=../../../Build/CMake/Toolchains/android.toolchain.cmake -DCMAKE_BUILD_TYPE="  + config["config"] + " ../../../");
             cmds.push("make -j4");
         }
 
         jake.exec(cmds, function() {
 
-            var editorResourceFolder = host.artifactsRoot + (os.platform() == "win32" ? "AtomicEditor/Resources/" : "AtomicEditor/AtomicEditor.app/Contents/Resources/");
+            var editorResourceFolder = config.artifactsRoot + (os.platform() == "win32" ? "AtomicEditor/Resources/" : "AtomicEditor/AtomicEditor.app/Contents/Resources/");
 
             // Install Deployment
             fs.copySync(buildDir + "Source/AtomicPlayer/Application/libAtomicPlayer.so",

+ 11 - 12
Build/Scripts/BuildAtomicNET.js

@@ -2,7 +2,9 @@ var fs = require('fs-extra');
 var path = require("path");
 var host = require("./Host");
 var os = require('os');
-var atomicRoot = host.atomicRoot;
+var config = require('./BuildConfig');
+
+var atomicRoot = config.atomicRoot;
 
 namespace('build', function() {
 
@@ -10,24 +12,21 @@ namespace('build', function() {
         async: true
     }, function() {
 
-        var options = host.options;
-
-        var android = options["with-android"] ? true : false;
-        var ios = options["with-ios"] ? true : false;
-        var debug = options["debug"] ? true : false;
-
-        var cmds = [];
 
         platforms = "-platform desktop";
-        if (android)
+
+        if (config["with-android"])
             platforms += " -platform android";
-        if (ios)
+
+        if (config["with-ios"])
             platforms += " -platform ios";
 
-        var netCmd = host.atomicTool + " net compile " + atomicRoot + "Script/AtomicNET/AtomicNETProject.json " + platforms + " -config " + (debug ? "Debug" : "Release");
+        var cmds = [];
+
+        var netCmd = host.atomicTool + " net compile " + atomicRoot + "Script/AtomicNET/AtomicNETProject.json " + platforms + " -config " + config["config"];
 
         console.log(netCmd);
-        
+
         cmds.push(netCmd);
 
         jake.exec(cmds, function() {

+ 44 - 38
Build/Scripts/BuildCommon.js

@@ -1,17 +1,16 @@
 var fs = require('fs-extra');
 var os = require('os');
 var path = require("path");
-var host = require("./Host");
-var atomicRoot = host.atomicRoot;
 var glob = require('glob');
-
 var Tslint = require("tslint");
-
 var fso = require('fs');
-var buildInfoDir = atomicRoot + "Source/AtomicBuildInfo/";
-var editorAppFolder = host.artifactsRoot + "AtomicEditor/";
-var toolDataFolder = editorAppFolder + "Resources/ToolData/";
-var jsDocFolder = host.artifactsRoot + "Build/JSDoc/";
+var spawnSync = require('child_process').spawnSync;
+
+var host = require("./Host");
+var config = require('./BuildConfig');
+
+var atomicRoot = config.atomicRoot;
+var jsDocFolder = config.artifactsRoot + "Build/JSDoc/";
 
 namespace('build', function() {
 
@@ -22,7 +21,7 @@ namespace('build', function() {
 
         console.log("TSLINT: Linting files in " + fileMask);
         var lintConfig = JSON.parse(fs.readFileSync("./Script/tslint.json"));
-        var options = {
+        var tslintConfig = {
             configuration: lintConfig,
             formatter: "prose"
         };
@@ -37,7 +36,7 @@ namespace('build', function() {
 
                 var contents = fs.readFileSync(filename, "utf8");
 
-                var ll = new Tslint(filename, contents, options);
+                var ll = new Tslint(filename, contents, tslintConfig);
                 var result = ll.lint();
                 if (result.failureCount > 0) {
                     lintErrors.push(result.output);
@@ -146,23 +145,11 @@ namespace('build', function() {
 
         var modules = host.getScriptModules();
         var bindCmd = host.atomicTool + " bind \"" + atomicRoot + "\" ";
-        var node;
+        var node = host.node;
         var tsc = "./Build/node_modules/typescript/lib/tsc";
         var tslint = "./Build/node_modules/tslint/lib/tslint-cli";
         var dtsGenerator = "./Build/node_modules/dts-generator/bin/dts-generator";
 
-        switch(os.platform()) {
-            case "win32":
-            node = "Build\\Windows\\node\\node.exe";
-            break;
-            case "darwin":
-            node = "Build/Mac/node/node";
-            break;
-            case "linux":
-            node = "Build/Linux/node/node";
-            break;
-        }
-
         var cmds = [];
         for (var pkgName in modules) {
             cmds.push(bindCmd + "Script/Packages/" + pkgName + "/");
@@ -213,55 +200,74 @@ namespace('build', function() {
 
     });
 
- 
+
   task('gendocs', {
     async: true
     }, function() {
 
+    console.log( "Generating Docs..." );
+
     fs.copySync(atomicRoot + "Build/Docs/Readme.md", jsDocFolder + "Readme.md");
     fs.copySync(atomicRoot + "Build/Docs/atomic-theme", jsDocFolder + "atomic-theme");
 
+
+    var typeDoc;
+    if (os.platform() == "win32") {
+        // uses system node for typedoc, which should have as require npm
+        typeDoc = "node_modules\\.bin\\typedoc.cmd";
+    }
+    else
+        typeDoc = host.node + " ./node_modules/.bin/typedoc";
+
+    // tsdoc is having problems when name has spaces on Windows and Linux, tried quoting/escaping
+    // what should happen here is instead of command line use a json config file (or maybe new version of tsdoc fixes this)
+    var name = "Atomic-Game-Engine";
+
     cmds = [
       "cd " + jsDocFolder + " && echo {} > package.json", // newer versions of npm require package.json to be in the folder or else it searches up the heirarchy
       "cd " + jsDocFolder + " && npm install typedoc",
-      "cd " + jsDocFolder + " && ./node_modules/.bin/typedoc --out out " + toolDataFolder + "TypeScriptSupport/Atomic.d.ts --module commonjs --includeDeclarations --mode file --theme atomic-theme --name 'Atomic Game Engine' --readme ./Readme.md",
+      "cd " + jsDocFolder + " && " + typeDoc + " --out out " + config.atomicRoot +
+              "Script/TypeScript/dist/Atomic.d.ts --module commonjs --includeDeclarations --mode file --theme atomic-theme --name " +
+              name + " --readme ./Readme.md"
     ];
 
     jake.exec(cmds, function() {
-        
-      common.cleanCreateDir( toolDataFolder + "Docs");
 
-      fs.copySync(jsDocFolder + "out", toolDataFolder + "Docs/JSDocs");
-    
+      common.cleanCreateDir( config.toolDataFolder + "Docs");
+
+      fs.copySync(jsDocFolder + "out", config.toolDataFolder + "Docs/JSDocs");
+
       complete();
 
       console.log( "completed installing API documentation" );
 
     }, {
-        
+
       printStdout: true
 
     });
 
   });
-  
-  
+
+
   task('genexamples', {
     async: true
     }, function() {
-    
-    common.cleanCreateDir( toolDataFolder + "AtomicExamples");
+
+    console.log( "Generating Examples..." );
+
+    common.cleanCreateDir( config.toolDataFolder + "AtomicExamples");
 
     cmds = [
-      "git clone https://github.com/AtomicGameEngine/AtomicExamples " + toolDataFolder + "AtomicExamples",
+      "git clone https://github.com/AtomicGameEngine/AtomicExamples " + config.toolDataFolder + "AtomicExamples",
     ];
 
     jake.exec(cmds, function() {
-        
-      fs.removeSync( toolDataFolder + "AtomicExamples/.git" );
+
+      fs.removeSync( config.toolDataFolder + "AtomicExamples/.git" );
 
       complete();
-      
+
       console.log( "completed installing example programs" )
 
         }, {

+ 44 - 0
Build/Scripts/BuildConfig.js

@@ -0,0 +1,44 @@
+var os = require('os');
+var path = require('path');
+var spawnSync = require('child_process').spawnSync;
+
+function processOptions(config) {
+
+    config["config"] = config["debug"] ? "Debug" : "Release";
+
+    // AtomicNET
+    if (config["nonet"]) {
+        config["with-atomicnet"] = false;
+    } else {
+        if (os.platform() == "win32") {
+            config["with-atomicnet"] = true;
+        } else {
+            // see if xbuild is available
+            config["with-atomicnet"]  = false;
+            if ( spawnSync) // TODO: CI box doesn't have spawnSync
+                config["with-atomicnet"] = spawnSync("which", ["xbuild"]).status == 1 ? false : true;
+        }
+    }
+
+
+    // paths
+    config.atomicRoot = path.resolve(__dirname, "../..") + "/";
+    config.artifactsRoot = config.atomicRoot + "/Artifacts/";
+
+    config.editorAppFolder = (os.platform() == "darwin") ? config.artifactsRoot + "/AtomicEditor/AtomicEditor.app/" : config.artifactsRoot + "AtomicEditor/";
+    config.toolDataFolder = config.editorAppFolder + (os.platform() == "darwin" ? "Contents/Resources/ToolData/" : "Resources/ToolData/");
+
+    return config;
+}
+
+exports = module.exports = processOptions(require('minimist')(process.argv.slice(2), {
+    "default" : {
+        "noclean" : false,
+        "debug" : false,
+        "nonet" : false,
+        "with-android" : false,
+        "with-ios" : false,
+        "with-docs" : false,
+        "with-examples" : false
+    }
+}));

+ 8 - 12
Build/Scripts/BuildIOS.js

@@ -1,12 +1,13 @@
+var os = require('os');
 var fs = require('fs-extra');
 var path = require("path");
 var host = require("./Host");
-var os = require('os');
+var config = require("./BuildConfig");
 
 var jenkinsBuild = process.env.ATOMIC_JENKINS_BUILD == 1;
 
-var atomicRoot = host.atomicRoot;
-var buildDir = host.artifactsRoot + "Build/IOS/";
+var atomicRoot = config.atomicRoot;
+var buildDir = config.artifactsRoot + "Build/IOS/";
 
 namespace('build', function() {
 
@@ -14,14 +15,10 @@ namespace('build', function() {
         async: true
     }, function() {
 
-        var options = host.options;
-        var cleanBuild = options["noclean"] ? false : true;
-        var debug = options["debug"] ? true : false;
+        var NETNativeSrcDir = buildDir + "Source/AtomicNET/NETNative/" + config["config"] + "-iphoneos/";
+        var NETNativeDestDir = config.artifactsRoot + "AtomicNET/" + config["config"] + "/Native/iOS/";
 
-        var NETNativeSrcDir = buildDir + "Source/AtomicNET/NETNative/" + (debug ? "Debug" : "Release") + "-iphoneos/";
-        var NETNativeDestDir = host.artifactsRoot + "AtomicNET/" + (debug ? "Debug" : "Release") + "/Native/iOS/";
-
-        host.setupDirs(cleanBuild, [buildDir, NETNativeDestDir]);
+        host.setupDirs(!config["noclean"], [buildDir, NETNativeDestDir]);
 
         process.chdir(buildDir);
 
@@ -29,13 +26,12 @@ namespace('build', function() {
 
         cmds.push("cmake -DIOS=1 -DATOMIC_DEV_BUILD=0 -G Xcode ../../../");
 
-
         if (jenkinsBuild) {
             cmds.push("security -v list-keychains -d system -s /Users/jenkins/Library/Keychains/codesign.keychain");
             cmds.push("security -v unlock-keychain /Users/jenkins/Library/Keychains/codesign.keychain");
         }
 
-        cmds.push("xcodebuild -configuration " + (debug ? "Debug" : "Release") + " -parallelizeTargets -jobs 4");
+        cmds.push("xcodebuild -configuration " + config["config"] + " -parallelizeTargets -jobs 4");
         // Note that this install_name_tool invocation invalidates the code signing, Xamarin/Visual Studio should resign the binary on deploy to device
         cmds.push("cd \"" + NETNativeSrcDir + "\" && install_name_tool -id @rpath/AtomicNETNative.framework/AtomicNETNative AtomicNETNative.framework/AtomicNETNative");
         //cmds.push("cd \"" + NETNativeSrcDir + "\" && codesign --deep --force --verify --sign \"iPhone Developer\" ./AtomicNETNative.framework/");

+ 3 - 3
Build/Scripts/BuildLint.js

@@ -1,12 +1,12 @@
 var fs = require('fs-extra');
 var path = require("path");
-var host = require("./Host");
 var os = require('os');
 var glob = require("glob");
+var config = require("./BuildConfig");
 
 var fixTabs = false;
 
-var atomicRoot = host.atomicRoot;
+var atomicRoot = config.atomicRoot;
 
 // Oh, JavaScript
 atomicRoot = atomicRoot.split("\\");
@@ -21,7 +21,7 @@ function lintFile(filename) {
         console.log(filename + "  contains tab character");
 
         if (fixTabs) {
-            
+
             var fd = fs.openSync(filename, "w");
 
             var tabbed = file.split('\t');

+ 17 - 62
Build/Scripts/BuildLinux.js

@@ -1,23 +1,20 @@
 var fs = require('fs-extra');
 var path = require("path");
 var host = require("./Host");
-var spawnSync = require('child_process').spawnSync
+var config = require("./BuildConfig");
+var buildTasks = require("./BuildTasks");
 
-var atomicRoot = host.atomicRoot;
-var buildDir = host.artifactsRoot + "Build/Linux/";
-var editorAppFolder = host.artifactsRoot + "AtomicEditor/";
-
-var buildAtomicNET = false;
-var debug = false;
-var config = "Release";
+var atomicRoot = config.atomicRoot;
+var buildDir = config.artifactsRoot + "Build/Linux/";
+var editorAppFolder = config.artifactsRoot + "AtomicEditor/";
 
 function copyAtomicNET() {
 
-    if (!buildAtomicNET)
+    if (!config["with-atomicnet"])
         return;
 
-    fs.copySync(atomicRoot + "Artifacts/AtomicNET/" + config,
-    editorAppFolder + "Resources/ToolData/AtomicNET/" + config);
+    fs.copySync(atomicRoot + "Artifacts/AtomicNET/" + config["config"],
+    editorAppFolder + "Resources/ToolData/AtomicNET/" + config["config"]);
 
     fs.copySync(atomicRoot + "Script/AtomicNET/AtomicProject.json",
     editorAppFolder + "Resources/ToolData/AtomicNET/Build/Projects/AtomicProject.json");
@@ -28,7 +25,7 @@ function copyAtomicEditor() {
 
     // Copy the Editor binaries
     fs.copySync(buildDir + "Source/AtomicEditor/AtomicEditor",
-    host.artifactsRoot + "AtomicEditor/AtomicEditor");
+    config.artifactsRoot + "AtomicEditor/AtomicEditor");
 
     // We need some resources to run
     fs.copySync(atomicRoot + "Resources/CoreData",
@@ -68,9 +65,7 @@ function copyAtomicEditor() {
     }
 
 
-    if (buildAtomicNET) {
-        copyAtomicNET();
-    }
+    copyAtomicNET();
 
 }
 
@@ -82,8 +77,7 @@ namespace('build', function() {
 
         process.chdir(buildDir);
 
-        var cmds = [];
-        cmds.push("make AtomicEditor AtomicPlayer -j2")
+        var cmds = ["make AtomicEditor AtomicPlayer -j2"];
 
         jake.exec(cmds, function() {
 
@@ -101,70 +95,31 @@ namespace('build', function() {
         async: true
     }, function() {
 
-        var options = host.options;
-
-        var android = options["with-android"] ? true : false;
-        var cleanBuild = options["noclean"] ? false : true;
-        var installDocs = options["with-docs"] ? true : false;
-        var installExamples = options["with-examples"] ? true : false;
-        debug = options["debug"] ? true : false;
-        config = debug ? "Debug" : "Release";
-
-        var createDirs = [];
-        var removeDirs = [];
-
         // We clean atomicNET here as otherwise platform binaries would be deleted
-        createDirs.push(host.artifactsRoot + "AtomicNET/");
-        createDirs.push(buildDir);
-        createDirs.push(editorAppFolder);
-        createDirs.push(host.getGenScriptRootDir());
+        var createDirs = [config.artifactsRoot + "AtomicNET/", buildDir, editorAppFolder, host.getGenScriptRootDir()];
 
-        removeDirs.push(host.artifactsRoot + "Build/Android/");
+        var removeDirs = [config.artifactsRoot + "Build/Android/"];
 
-        host.setupDirs(cleanBuild, createDirs, removeDirs);
-
-        // TODO: build box has old node
-        if (spawnSync)
-            buildAtomicNET = spawnSync("which", ["xbuild"]).status == 1 ? false : true;
+        host.setupDirs(!config.noclean, createDirs, removeDirs);
 
         process.chdir(buildDir);
 
         var cmds = [];
 
         // Generate Atomic solution, AtomicTool binary, and script bindings
-        cmds.push("cmake ../../../ -DATOMIC_DEV_BUILD=0 -DCMAKE_BUILD_TYPE=" + config);
+        cmds.push("cmake ../../../ -DATOMIC_DEV_BUILD=0 -DCMAKE_BUILD_TYPE=" + config["config"]);
         cmds.push("make AtomicNETNative -j2")
 
         jake.exec(cmds, function() {
 
             var rootTask = jake.Task['build:atomiceditor_phase2'];
-            var task = rootTask;
-
-            // add optional build components in reverse order
-            if (buildAtomicNET) {
-                var netTask = jake.Task['build:atomicnet'];
-                task.prereqs.push("build:atomicnet")
-                task = netTask;
-            }
 
-            if (android) {
-                var androidTask = jake.Task['build:android_native'];
-                task.prereqs.push("build:android_native")
-                task = androidTask;
-            }
+            buildTasks.installBuildTasks(rootTask);
 
             rootTask.addListener('complete', function () {
-                console.log("\n\nAtomic Editor built to " + editorAppFolder + "\n\n");
-
-                if (installDocs) {
-                    jake.Task['build:gendocs'].invoke();
-                }
-
-                if (installExamples) {
-                    jake.Task['build:genexamples'].invoke();
-                }
 
                complete();
+
             });
 
             rootTask.invoke();

+ 19 - 72
Build/Scripts/BuildMac.js

@@ -1,24 +1,20 @@
 var fs = require('fs-extra');
 var path = require("path");
-var spawnSync = require('child_process').spawnSync
 var host = require("./Host");
+var buildTasks = require("./BuildTasks");
+var config = require('./BuildConfig');
 
-var atomicRoot = host.atomicRoot;
-var buildDir = host.artifactsRoot + "Build/Mac/";
-var editorAppFolder = host.artifactsRoot + "/AtomicEditor/AtomicEditor.app/";
-var resourceDest = editorAppFolder + "/Contents/Resources/"
-
-var buildAtomicNET = false;
-var debug = false;
-var config = "Release";
+var atomicRoot = config.atomicRoot;
+var buildDir = config.artifactsRoot + "Build/Mac/";
+var resourceDest = config.editorAppFolder + "/Contents/Resources/"
 
 function copyAtomicNET() {
 
-    if (!buildAtomicNET)
+    if (!config["with-atomicnet"])
         return;
 
-    fs.copySync(atomicRoot + "Artifacts/AtomicNET/" + config,
-    resourceDest + "ToolData/AtomicNET/" + config);
+    fs.copySync(atomicRoot + "Artifacts/AtomicNET/" + config["config"],
+    resourceDest + "ToolData/AtomicNET/" + config["config"]);
 
     fs.copySync(atomicRoot + "Script/AtomicNET/AtomicProject.json",
     resourceDest + "ToolData/AtomicNET/Build/Projects/AtomicProject.json");
@@ -27,7 +23,7 @@ function copyAtomicNET() {
 
 function copyAtomicEditor() {
 
-    fs.copySync(buildDir + "Source/AtomicEditor/" + config + "/AtomicEditor.app", editorAppFolder);
+    fs.copySync(buildDir + "Source/AtomicEditor/" + config["config"] + "/AtomicEditor.app", config.editorAppFolder);
 
     // We need some resources to run
     fs.copySync(atomicRoot + "Resources/CoreData",
@@ -46,13 +42,11 @@ function copyAtomicEditor() {
     resourceDest + "EditorData/AtomicEditor/EditorScripts");
 
     // copy the mac player binary to deployment
-    var playerBinary =  buildDir +  "Source/AtomicPlayer/Application/" + config + "/AtomicPlayer.app/Contents/MacOS/AtomicPlayer";
+    var playerBinary =  buildDir +  "Source/AtomicPlayer/Application/" + config["config"] + "/AtomicPlayer.app/Contents/MacOS/AtomicPlayer";
 
     fs.copySync(playerBinary, resourceDest + "ToolData/Deployment/MacOS/AtomicPlayer.app/Contents/MacOS/AtomicPlayer");
 
-    if (buildAtomicNET) {
-        copyAtomicNET();
-    }
+    copyAtomicNET();
 
 }
 
@@ -65,7 +59,7 @@ namespace('build', function() {
         process.chdir(buildDir);
 
         var cmds = [];
-        cmds.push("xcodebuild -target AtomicEditor -target AtomicPlayer -configuration " + config + " -parallelizeTargets -jobs 4")
+        cmds.push("xcodebuild -target AtomicEditor -target AtomicPlayer -configuration " + config["config"] + " -parallelizeTargets -jobs 4")
 
         jake.exec(cmds, function() {
 
@@ -84,33 +78,11 @@ namespace('build', function() {
         async: true
     }, function() {
 
-        var options = host.options;
-
-        var android = options["with-android"] ? true : false;
-        var ios = options["with-ios"] ? true : false;
-        var cleanBuild = options["noclean"] ? false : true;
-        var installDocs = options["with-docs"] ? true : false;
-        var installExamples = options["with-examples"] ? true : false;
-        debug = options["debug"] ? true : false;
-        config = debug ? "Debug" : "Release";
-
-        var createDirs = [];
-        var removeDirs = [];
-
         // We clean atomicNET here as otherwise platform binaries would be deleted
-        createDirs.push(host.artifactsRoot + "AtomicNET/");
-        createDirs.push(buildDir);
-        createDirs.push(editorAppFolder);
-        createDirs.push(host.getGenScriptRootDir());
-
-        removeDirs.push(host.artifactsRoot + "Build/Android/");
-        removeDirs.push(host.artifactsRoot + "Build/IOS/");
+        var createDirs = [config.artifactsRoot + "AtomicNET/", buildDir, config.editorAppFolder, host.getGenScriptRootDir()];
+        var removeDirs = [config.artifactsRoot + "Build/Android/", config.artifactsRoot + "Build/IOS/"];
 
-        host.setupDirs(cleanBuild, createDirs, removeDirs);
-
-        if (!options["nonet"]) {
-            buildAtomicNET = spawnSync("which", ["xbuild"]).status == 1 ? false : true;
-        }
+        host.setupDirs(!config.noclean, createDirs, removeDirs);
 
         process.chdir(buildDir);
 
@@ -118,42 +90,17 @@ namespace('build', function() {
 
         // Generate XCode project, AtomicTool binary, and script bindings
         cmds.push("cmake ../../../ -DATOMIC_DEV_BUILD=0 -G Xcode");
-        cmds.push("xcodebuild -target GenerateScriptBindings -target AtomicNETNative -configuration " + config + " -parallelizeTargets -jobs 4")
+        cmds.push("xcodebuild -target GenerateScriptBindings -target AtomicNETNative -configuration " + config["config"] + " -parallelizeTargets -jobs 4")
 
         jake.exec(cmds, function() {
 
             var rootTask = jake.Task['build:atomiceditor_phase2'];
-            var task = rootTask;
-
-            // add optional build components in reverse order
-            if (buildAtomicNET) {
-                var netTask = jake.Task['build:atomicnet'];
-                task.prereqs.push("build:atomicnet")
-                task = netTask;
-            }
-
-            if (ios) {
-                var iosTask = jake.Task['build:ios_native'];
-                task.prereqs.push("build:ios_native")
-                task = iosTask;
-            }
-
-            if (android) {
-                var androidTask = jake.Task['build:android_native'];
-                task.prereqs.push("build:android_native")
-                task = androidTask;
-            }
 
-            rootTask.addListener('complete', function () {
-                console.log("\n\nAtomic Editor built to " + editorAppFolder + "\n\n");
+            buildTasks.installBuildTasks(rootTask);
 
-                if (installDocs) {
-                    jake.Task['build:gendocs'].invoke();
-                }
+            rootTask.addListener('complete', function () {
 
-                if (installExamples) {
-                    jake.Task['build:genexamples'].invoke();
-                }
+                console.log("\n\nAtomic Editor built to " + config.editorAppFolder + "\n\n");
 
                 complete();
             });

+ 44 - 0
Build/Scripts/BuildTasks.js

@@ -0,0 +1,44 @@
+
+var host = require("./Host");
+var config = require("./BuildConfig");
+
+// return an object with package name keys and module name lists as values
+function installBuildTasks(rootTask) {
+
+    var task = rootTask;
+
+    // add optional build components in reverse order
+
+    if (config["with-docs"]) {
+        var docTask = jake.Task['build:gendocs'];
+        task.prereqs.push("build:gendocs")
+        task = docTask;
+    }
+
+    if (config["with-examples"]) {
+        var examplesTask = jake.Task['build:genexamples'];
+        task.prereqs.push("build:genexamples")
+        task = examplesTask;
+    }
+
+    if (config["with-atomicnet"]) {
+        var netTask = jake.Task['build:atomicnet'];
+        task.prereqs.push("build:atomicnet")
+        task = netTask;
+    }
+
+    if (config["with-ios"]) {
+        var iosTask = jake.Task['build:ios_native'];
+        task.prereqs.push("build:ios_native")
+        task = iosTask;
+    }
+
+    if (config["with-android"]) {
+        var androidTask = jake.Task['build:android_native'];
+        task.prereqs.push("build:android_native")
+        task = androidTask;
+    }
+
+}
+
+exports.installBuildTasks = installBuildTasks;

+ 4 - 3
Build/Scripts/BuildWeb.js

@@ -2,9 +2,10 @@ var fs = require('fs-extra');
 var path = require("path");
 var host = require("./Host");
 var os = require('os');
-var atomicRoot = host.atomicRoot;
+var config = require("./BuildConfig")
 
-var buildDir = host.artifactsRoot + "Build/Web/AtomicPlayer";
+var atomicRoot = config.atomicRoot;
+var buildDir = config.artifactsRoot + "Build/Web/AtomicPlayer";
 
 // build command:
 // ./Build/Mac/node/node ./Build/node_modules/jake/bin/cli.js -f ./Build/Scripts/Bootstrap.js build:web_player
@@ -46,7 +47,7 @@ namespace('build', function() {
 
     jake.exec(cmds, function() {
 
-      var editorAppFolder = host.artifactsRoot + (os.platform() == "win32" ? "AtomicEditor/" : "AtomicEditor/AtomicEditor.app/");
+      var editorAppFolder = config.artifactsRoot + (os.platform() == "win32" ? "AtomicEditor/" : "AtomicEditor/AtomicEditor.app/");
 
       var webPlayerBinary = buildDir + "/Source/AtomicPlayer/Application/AtomicPlayer.js";
       var webPlayerMemFile = buildDir + "/Source/AtomicPlayer/Application/AtomicPlayer.html.mem";

+ 20 - 58
Build/Scripts/BuildWindows.js

@@ -1,22 +1,20 @@
 var fs = require('fs-extra');
 var path = require("path");
 var host = require("./Host");
+var buildTasks = require("./BuildTasks");
+var config = require("./BuildConfig");
 
-var atomicRoot = host.atomicRoot;
-var buildDir = host.artifactsRoot + "Build/Windows/";
-var editorAppFolder = host.artifactsRoot + "AtomicEditor/";
-
-var buildAtomicNET = true;
-var debug = false;
-var config = "Release";
+var atomicRoot = config.atomicRoot;
+var buildDir = config.artifactsRoot + "Build/Windows/";
+var editorAppFolder = config.editorAppFolder
 
 function copyAtomicNET() {
 
-    if (!buildAtomicNET)
+    if (!config["with-atomicnet"])
         return;
 
-    fs.copySync(atomicRoot + "Artifacts/AtomicNET/" + config,
-    editorAppFolder + "Resources/ToolData/AtomicNET/" + config);
+    fs.copySync(atomicRoot + "Artifacts/AtomicNET/" + config["config"],
+    editorAppFolder + "Resources/ToolData/AtomicNET/" + config["config"]);
 
     fs.copySync(atomicRoot + "Script/AtomicNET/AtomicProject.json",
     editorAppFolder + "Resources/ToolData/AtomicNET/Build/Projects/AtomicProject.json");
@@ -26,8 +24,8 @@ function copyAtomicNET() {
 function copyAtomicEditor() {
 
     // Copy the Editor binaries
-    fs.copySync(buildDir + "Source/AtomicEditor/" + config,
-    host.artifactsRoot + "AtomicEditor");
+    fs.copySync(buildDir + "Source/AtomicEditor/" + config["config"],
+    config.artifactsRoot + "AtomicEditor");
 
     // We need some resources to run
     fs.copySync(atomicRoot + "Resources/CoreData",
@@ -45,15 +43,13 @@ function copyAtomicEditor() {
     fs.copySync(atomicRoot + "Artifacts/Build/Resources/EditorData/AtomicEditor/EditorScripts",
     editorAppFolder + "Resources/EditorData/AtomicEditor/EditorScripts");
 
-    fs.copySync(buildDir +  "Source/AtomicPlayer/Application/" + config +"/AtomicPlayer.exe",
+    fs.copySync(buildDir +  "Source/AtomicPlayer/Application/" + config["config"] +"/AtomicPlayer.exe",
     editorAppFolder + "Resources/ToolData/Deployment/Windows/x64/AtomicPlayer.exe");
 
-    fs.copySync(buildDir +  "Source/AtomicPlayer/Application/" + config + "/D3DCompiler_47.dll",
+    fs.copySync(buildDir +  "Source/AtomicPlayer/Application/" + config["config"] + "/D3DCompiler_47.dll",
     editorAppFolder + "Resources/ToolData/Deployment/Windows/x64/D3DCompiler_47.dll");
 
-    if (buildAtomicNET) {
-        copyAtomicNET();
-    }
+    copyAtomicNET();
 
 }
 
@@ -66,7 +62,7 @@ namespace('build', function() {
         process.chdir(buildDir);
 
         var cmds = [];
-        cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditorPhase2.bat " + config);
+        cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditorPhase2.bat " + config["config"]);
 
         jake.exec(cmds, function() {
 
@@ -84,63 +80,29 @@ namespace('build', function() {
         async: true
     }, function() {
 
-        var options = host.options;
-
-        var android = options["with-android"] ? true : false;
-        var cleanBuild = options["noclean"] ? false : true;
-        var installDocs = options["with-docs"] ? true : false;
-        var installExamples = options["with-examples"] ? true : false;
-        debug = options["debug"] ? true : false;
-        config = debug ? "Debug" : "Release";
-
-        var createDirs = [];
-        var removeDirs = [];
-
         // We clean atomicNET here as otherwise platform binaries would be deleted
-        createDirs.push(host.artifactsRoot + "AtomicNET/");
-        createDirs.push(buildDir);
-        createDirs.push(editorAppFolder);
-        createDirs.push(host.getGenScriptRootDir());
+        var createDirs = [config.artifactsRoot + "AtomicNET/", buildDir, editorAppFolder, host.getGenScriptRootDir()];
 
-        removeDirs.push(host.artifactsRoot + "Build/Android/");
+        var removeDirs = [config.artifactsRoot + "Build/Android/"];
 
-        host.setupDirs(cleanBuild, createDirs, removeDirs);
+        host.setupDirs(!config.noclean, createDirs, removeDirs);
 
         process.chdir(buildDir);
 
         var cmds = [];
 
         // Generate Atomic solution, AtomicTool binary, and script bindings
-        cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditorPhase1.bat " + config);
+        cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditorPhase1.bat " + config["config"]);
 
         jake.exec(cmds, function() {
 
             var rootTask = jake.Task['build:atomiceditor_phase2'];
-            var task = rootTask;
 
-            // add optional build components in reverse order
-            if (buildAtomicNET) {
-                var netTask = jake.Task['build:atomicnet'];
-                task.prereqs.push("build:atomicnet")
-                task = netTask;
-            }
-
-            if (android) {
-                var androidTask = jake.Task['build:android_native'];
-                task.prereqs.push("build:android_native")
-                task = androidTask;
-            }
+            buildTasks.installBuildTasks(rootTask);
 
             rootTask.addListener('complete', function () {
-                console.log("\n\nAtomic Editor built to " + editorAppFolder + "\n\n");
 
-                if (installDocs) {
-                    jake.Task['build:gendocs'].invoke();
-                }
-
-                if (installExamples) {
-                    jake.Task['build:genexamples'].invoke();
-                }
+                console.log("\n\nAtomic Editor built to " + editorAppFolder + "\n\n");
 
                 complete();
             });

+ 1 - 0
Build/Scripts/Host.js

@@ -17,3 +17,4 @@ require("./BuildIOS");
 require("./BuildWeb");
 require("./BuildAtomicNET");
 require("./BuildLint");
+require("./BuildTasks");

+ 16 - 3
Build/Scripts/HostCommon.js

@@ -1,12 +1,24 @@
 var os = require('os');
 var path = require('path');
+var config = require("./BuildConfig");
 
 // get the root folder
-var atomicRoot = path.resolve(__dirname, "../..") + "/";
+var atomicRoot = config.atomicRoot;
+var nodeBinary;
+switch(os.platform()) {
+    case "win32":
+    nodeBinary = atomicRoot + "Build\\Windows\\node\\node.exe";
+    break;
+    case "darwin":
+    nodeBinary = atomicRoot + "Build/Mac/node/node";
+    break;
+    case "linux":
+    nodeBinary = atomicRoot + "Build/Linux/node/node";
+    break;
+}
+
 
 // patch in our local node_modules
-process.env.NODE_PATH = atomicRoot + "Build/node_modules/";
-require('module').Module._initPaths();
 var fs = require('fs-extra');
 
 /// Returns a list of all script packages
@@ -175,6 +187,7 @@ function testRemoveDir(path) {
 
 exports.atomicRoot = atomicRoot;
 exports.artifactsRoot = atomicRoot + "Artifacts/";
+exports.node = nodeBinary;
 exports.cleanCreateDir = cleanCreateDir;
 exports.testCreateDir = testCreateDir;
 exports.testRemoveDir = testRemoveDir;

+ 0 - 0
Build/Scripts/PackageEditor.js