소스 검색

Add autologging flag to build command. Fix build command not exiting on error.

Matt Benic 9 년 전
부모
커밋
0b842efd72

+ 9 - 0
Source/ToolCore/Build/BuildBase.cpp

@@ -239,6 +239,9 @@ void BuildBase::BuildLog(const String& message, bool sendEvent)
 {
     buildLog_.Push(message);
 
+    if (autoLog_)
+        ATOMIC_LOGINFO(message);
+    
     if (sendEvent)
     {
         String colorMsg = ToString("<color #D4FB79>%s</color>\n", message.CString());
@@ -253,6 +256,9 @@ void BuildBase::BuildWarn(const String& warning, bool sendEvent)
 {
     buildWarnings_.Push(warning);
 
+    if (autoLog_)
+        ATOMIC_LOGWARNING(warning);
+
     if (sendEvent)
     {
         String colorMsg = ToString("<color #FFFF00>%s</color>\n", warning.CString());
@@ -267,6 +273,9 @@ void BuildBase::BuildError(const String& error, bool sendEvent)
 {
     buildErrors_.Push(error);
 
+    if (autoLog_)
+        ATOMIC_LOGERROR(error);
+
     if (sendEvent)
     {
         String colorMsg = ToString("<color #FF0000>%s</color>\n", error.CString());

+ 3 - 0
Source/ToolCore/Build/BuildBase.h

@@ -84,6 +84,8 @@ public:
     bool GetBuildFailed() const { return buildFailed_; }
     const Vector<String>& GetBuildErrors() const { return buildErrors_; }
 
+    void SetAutoLog(bool autoLog) { autoLog_ = autoLog; }
+
 protected:
 
     bool BuildClean(const String& path);
@@ -118,6 +120,7 @@ protected:
 
     bool resourcesOnly_;
     bool verbose_;
+    bool autoLog_;
 
 private:
     void BuildFilteredProjectResourceEntries();

+ 1 - 1
Source/ToolCore/Build/BuildWindows.cpp

@@ -113,7 +113,7 @@ bool BuildWindows::BuildManaged(const String& buildPath)
 
     if (!fileSystem->FileExists(managedExe))
     {
-        BuildError(ToString("Error building managed project, please compile the %s binary %s before building", config.CString(), managedExe.CString()));
+        FailBuild(ToString("Error building managed project, please compile the %s binary %s before building", config.CString(), managedExe.CString()));
         return false;
     }
 

+ 27 - 1
Source/ToolCore/Command/BuildCmd.cpp

@@ -50,7 +50,6 @@ bool BuildCmd::Parse(const Vector<String>& arguments, unsigned startIndex, Strin
 {
     String argument = arguments[startIndex].ToLower();
     String value = startIndex + 1 < arguments.Size() ? arguments[startIndex + 1] : String::EMPTY;
-    String tag = startIndex + 2 < arguments.Size() ? arguments[startIndex + 2] : String::EMPTY;
 
     if (argument != "build")
     {
@@ -65,6 +64,32 @@ bool BuildCmd::Parse(const Vector<String>& arguments, unsigned startIndex, Strin
     }
 
     buildPlatform_ = value.ToLower();
+
+    for (int i = startIndex + 2; i < arguments.Size(); ++i)
+    {
+        String option = arguments[i].ToLower();
+        
+        if (option == "-tag")
+        {
+            if (arguments.Size() == i + 1)
+            {
+                errorMsg = "Missing tag";
+                return false;
+            }
+        }
+        else if (option == "-autolog")
+        {
+            autoLog_ = true;
+        }
+        else
+        {
+            errorMsg = "Invalid option: " + option;
+            return false;
+        }
+    }
+
+    String tag = startIndex + 2 < arguments.Size() ? arguments[startIndex + 2] : String::EMPTY;
+
     assetsBuildTag_ = tag.ToLower();
 
     return true;
@@ -106,6 +131,7 @@ void BuildCmd::Run()
     {
         buildBase->SetAssetBuildTag(assetsBuildTag_);
     }
+    buildBase->SetAutoLog(autoLog_);
 
     // add it to the build system
     BuildSystem* buildSystem = GetSubsystem<BuildSystem>();

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

@@ -49,6 +49,7 @@ private:
 
     String buildPlatform_;
     String assetsBuildTag_;
+    bool autoLog_;
 
 };