|
|
@@ -12,6 +12,7 @@
|
|
|
#include "../Project/Project.h"
|
|
|
#include "../ToolEnvironment.h"
|
|
|
|
|
|
+#include "BuildSystem.h"
|
|
|
#include "BuildEvents.h"
|
|
|
#include "BuildBase.h"
|
|
|
#include "ResourcePackager.h"
|
|
|
@@ -21,7 +22,8 @@ namespace ToolCore
|
|
|
|
|
|
BuildBase::BuildBase(Context * context, Project* project, PlatformID platform) : Object(context),
|
|
|
platformID_(platform),
|
|
|
- containsMDL_(false)
|
|
|
+ containsMDL_(false),
|
|
|
+ buildFailed_(false)
|
|
|
{
|
|
|
if (UseResourcePackager())
|
|
|
resourcePackager_ = new ResourcePackager(context, this);
|
|
|
@@ -38,28 +40,130 @@ BuildBase::~BuildBase()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void BuildBase::BuildLog(const String& message)
|
|
|
+bool BuildBase::BuildCreateDirectory(const String& path)
|
|
|
+{
|
|
|
+ if (buildFailed_)
|
|
|
+ {
|
|
|
+ LOGERRORF("BuildBase::BuildCreateDirectory - Attempt to create directory of failed build, %s", path.CString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
+
|
|
|
+ if (fileSystem->DirExists(path))
|
|
|
+ return true;
|
|
|
+
|
|
|
+ bool result = fileSystem->CreateDir(path);
|
|
|
+
|
|
|
+ if (!result)
|
|
|
+ {
|
|
|
+ FailBuild(ToString("BuildBase::BuildCreateDirectory: Unable to create directory %s", path.CString()));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+bool BuildBase::BuildCopyFile(const String& srcFileName, const String& destFileName)
|
|
|
+{
|
|
|
+ if (buildFailed_)
|
|
|
+ {
|
|
|
+ LOGERRORF("BuildBase::BuildCopyFile - Attempt to copy file of failed build, %s", srcFileName.CString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
+
|
|
|
+ bool result = fileSystem->Copy(srcFileName, destFileName);
|
|
|
+
|
|
|
+ if (!result)
|
|
|
+ {
|
|
|
+ FailBuild(ToString("BuildBase::BuildCopyFile: Unable to copy file %s -> %s", srcFileName.CString(), destFileName.CString()));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+bool BuildBase::BuildRemoveDirectory(const String& path)
|
|
|
+{
|
|
|
+ if (buildFailed_)
|
|
|
+ {
|
|
|
+ LOGERRORF("BuildBase::BuildRemoveDirectory - Attempt to remove directory of failed build, %s", path.CString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
+ if (!fileSystem->DirExists(path))
|
|
|
+ return true;
|
|
|
+
|
|
|
+ bool result = fileSystem->RemoveDir(path, true);
|
|
|
+
|
|
|
+ if (!result)
|
|
|
+ {
|
|
|
+ FailBuild(ToString("BuildBase::BuildRemoveDirectory: Unable to remove directory %s", path.CString()));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+void BuildBase::BuildLog(const String& message, bool sendEvent)
|
|
|
{
|
|
|
buildLog_.Push(message);
|
|
|
+
|
|
|
+ if (sendEvent)
|
|
|
+ {
|
|
|
+ String colorMsg = ToString("<color #D4FB79>%s</color>\n", message.CString());
|
|
|
+ VariantMap buildOutput;
|
|
|
+ buildOutput[BuildOutput::P_TEXT] = colorMsg;
|
|
|
+ SendEvent(E_BUILDOUTPUT, buildOutput);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-void BuildBase::BuildWarn(const String& warning)
|
|
|
+void BuildBase::BuildWarn(const String& warning, bool sendEvent)
|
|
|
{
|
|
|
buildWarnings_.Push(warning);
|
|
|
+
|
|
|
+ if (sendEvent)
|
|
|
+ {
|
|
|
+ String colorMsg = ToString("<color #FFFF00>%s</color>\n", warning.CString());
|
|
|
+ VariantMap buildOutput;
|
|
|
+ buildOutput[BuildOutput::P_TEXT] = colorMsg;
|
|
|
+ SendEvent(E_BUILDOUTPUT, buildOutput);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-void BuildBase::BuildError(const String& error)
|
|
|
+void BuildBase::BuildError(const String& error, bool sendEvent)
|
|
|
{
|
|
|
buildErrors_.Push(error);
|
|
|
+
|
|
|
+ if (sendEvent)
|
|
|
+ {
|
|
|
+ String colorMsg = ToString("<color #FF0000>%s</color>\n", error.CString());
|
|
|
+ VariantMap buildOutput;
|
|
|
+ buildOutput[BuildOutput::P_TEXT] = colorMsg;
|
|
|
+ SendEvent(E_BUILDOUTPUT, buildOutput);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-void BuildBase::SendBuildFailure(const String& message)
|
|
|
+void BuildBase::FailBuild(const String& message)
|
|
|
{
|
|
|
+ if (buildFailed_)
|
|
|
+ {
|
|
|
+ LOGERRORF("BuildBase::FailBuild - Attempt to fail already failed build: %s", message.CString());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ buildFailed_ = true;
|
|
|
+
|
|
|
+ BuildError(message);
|
|
|
|
|
|
- VariantMap buildError;
|
|
|
- buildError[BuildComplete::P_PLATFORMID] = platformID_;
|
|
|
- buildError[BuildComplete::P_MESSAGE] = message;
|
|
|
- SendEvent(E_BUILDCOMPLETE, buildError);
|
|
|
+ BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
|
|
|
+ buildSystem->BuildComplete(platformID_, buildPath_, false, message);
|
|
|
|
|
|
}
|
|
|
|