forked from qt-creator/qt-creator
NimCompilerCleanStep: Employ task tree for running
Task-number: QTCREATORBUG-29168 Change-Id: I9f7b0d6c00fcfdc62baa5e17dc337ccc75d2e4bd Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
|
#include <solutions/tasking/tasktree.h>
|
||||||
|
|
||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -16,6 +18,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Nim {
|
namespace Nim {
|
||||||
@@ -37,8 +40,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool init() final;
|
bool init() final;
|
||||||
void doRun() final;
|
GroupItem runRecipe() final;
|
||||||
void doCancel() final {} // Can be left empty. The run() function hardly does anything.
|
|
||||||
|
|
||||||
bool removeCacheDirectory();
|
bool removeCacheDirectory();
|
||||||
bool removeOutFilePath();
|
bool removeOutFilePath();
|
||||||
@@ -49,35 +51,36 @@ private:
|
|||||||
|
|
||||||
bool NimCompilerCleanStep::init()
|
bool NimCompilerCleanStep::init()
|
||||||
{
|
{
|
||||||
FilePath buildDir = buildDirectory();
|
if (!BuildStep::init())
|
||||||
bool result = buildDir.exists();
|
return false;
|
||||||
if (result)
|
const FilePath buildDir = buildDirectory();
|
||||||
|
const bool exists = buildDir.exists();
|
||||||
|
if (exists)
|
||||||
m_buildDir = buildDir;
|
m_buildDir = buildDir;
|
||||||
return result;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimCompilerCleanStep::doRun()
|
GroupItem NimCompilerCleanStep::runRecipe()
|
||||||
{
|
{
|
||||||
|
const auto onSetup = [this] {
|
||||||
if (!m_buildDir.exists()) {
|
if (!m_buildDir.exists()) {
|
||||||
emit addOutput(Tr::tr("Build directory \"%1\" does not exist.").arg(m_buildDir.toUserOutput()), OutputFormat::ErrorMessage);
|
emit addOutput(Tr::tr("Build directory \"%1\" does not exist.")
|
||||||
emit finished(false);
|
.arg(m_buildDir.toUserOutput()), OutputFormat::ErrorMessage);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!removeCacheDirectory()) {
|
if (!removeCacheDirectory()) {
|
||||||
emit addOutput(Tr::tr("Failed to delete the cache directory."), OutputFormat::ErrorMessage);
|
emit addOutput(Tr::tr("Failed to delete the cache directory."),
|
||||||
emit finished(false);
|
OutputFormat::ErrorMessage);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!removeOutFilePath()) {
|
if (!removeOutFilePath()) {
|
||||||
emit addOutput(Tr::tr("Failed to delete the out file."), OutputFormat::ErrorMessage);
|
emit addOutput(Tr::tr("Failed to delete the out file."), OutputFormat::ErrorMessage);
|
||||||
emit finished(false);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit addOutput(Tr::tr("Clean step completed successfully."), OutputFormat::NormalMessage);
|
emit addOutput(Tr::tr("Clean step completed successfully."), OutputFormat::NormalMessage);
|
||||||
emit finished(true);
|
return true;
|
||||||
|
};
|
||||||
|
return Sync(onSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NimCompilerCleanStep::removeCacheDirectory()
|
bool NimCompilerCleanStep::removeCacheDirectory()
|
||||||
|
Reference in New Issue
Block a user