Browse Source

Adding build command

Josh Engebretson 10 years ago
parent
commit
39439a0341

+ 15 - 0
CLI/cli.js

@@ -54,6 +54,21 @@ cmd.setDefaults({action: function (args) {
     });
     });
 }});
 }});
 
 
+var cmd = commands.addParser("build", {help: "Builds the project",
+    description: "Builds the platform"});
+cmd.addArgument(["platform"], {help: "The platform to build (windows|mac|ios|android|ios)"});
+cmd.setDefaults({action: function (args) {
+    cli.build(args.platform)
+    .then(function () {
+        console.log("Project built " + path.resolve(args.path));
+    })
+    .catch(function (error) {
+        console.error("Error: Could not build " + path.resolve(args.path));
+        process.exit(1);
+    });
+}});
+
+
 // GO!
 // GO!
 if (process.argv.length > 2) {
 if (process.argv.length > 2) {
     var args = parser.parseArgs();
     var args = parser.parseArgs();

+ 4 - 0
CLI/index.js

@@ -54,4 +54,8 @@ exports.atomictool = atomictool
 
 
 exports.newProject = function (output) {
 exports.newProject = function (output) {
   return atomictool(["new", output], {output:true});
   return atomictool(["new", output], {output:true});
+};
+
+exports.build = function (platform) {
+  return atomictool(["build", platform], {output:true});
 };;
 };;

+ 54 - 0
Source/ToolCore/Command/BuildCmd.cpp

@@ -0,0 +1,54 @@
+
+#include <Atomic/Core/StringUtils.h>
+#include <Atomic/IO/Log.h>
+#include <Atomic/IO/File.h>
+
+#include "../ToolSystem.h"
+
+#include "BuildCmd.h"
+
+#include <Poco/File.h>
+
+namespace ToolCore
+{
+
+BuildCmd::BuildCmd(Context* context) : Command(context)
+{
+
+}
+
+BuildCmd::~BuildCmd()
+{
+
+}
+
+bool BuildCmd::Parse(const Vector<String>& arguments, unsigned startIndex, String& errorMsg)
+{
+    String argument = arguments[startIndex].ToLower();
+    String value = startIndex + 1 < arguments.Size() ? arguments[startIndex + 1] : String::EMPTY;
+
+    if (argument != "build")
+    {
+        errorMsg = "Unable to parse build command";
+        return false;
+    }
+
+    if (!value.Length())
+    {
+        errorMsg = "Unable to parse build platform";
+        return false;
+    }
+
+    buildPlatform_ = value;
+
+    return true;
+}
+
+void BuildCmd::Run()
+{
+    LOGINFOF("Building project for: %s", buildPlatform_.CString());
+
+    Finished();
+}
+
+}

+ 30 - 0
Source/ToolCore/Command/BuildCmd.h

@@ -0,0 +1,30 @@
+
+#pragma once
+
+#include "Command.h"
+
+using namespace Atomic;
+
+namespace ToolCore
+{
+
+class BuildCmd: public Command
+{
+    OBJECT(BuildCmd);
+
+public:
+
+    BuildCmd(Context* context);
+    virtual ~BuildCmd();
+
+    bool Parse(const Vector<String>& arguments, unsigned startIndex, String& errorMsg);
+
+    void Run();
+
+private:
+
+    String buildPlatform_;
+
+};
+
+}

+ 8 - 0
Source/ToolCore/Command/CommandParser.cpp

@@ -2,6 +2,7 @@
 #include "CommandParser.h"
 #include "CommandParser.h"
 
 
 #include "NewProjectCmd.h"
 #include "NewProjectCmd.h"
+#include "BuildCmd.h"
 
 
 namespace ToolCore
 namespace ToolCore
 {
 {
@@ -30,12 +31,19 @@ Command* CommandParser::Parse(const Vector<String>& arguments)
             {
             {
                 cmd = new NewProjectCmd(context_);
                 cmd = new NewProjectCmd(context_);
             }
             }
+            else if (argument == "build")
+            {
+                cmd = new BuildCmd(context_);
+            }
         }
         }
 
 
         if (cmd)
         if (cmd)
         {
         {
             if (cmd->Parse(arguments, i, errorMsg_))
             if (cmd->Parse(arguments, i, errorMsg_))
                 return cmd;
                 return cmd;
+
+            cmd->ReleaseRef();
+            break;
         }
         }
 
 
     }
     }