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:
Jarek Kobus
2023-07-13 00:23:15 +02:00
parent b1f1624b6e
commit 7fb8cd01dd

View File

@@ -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()
{ {
if (!m_buildDir.exists()) { const auto onSetup = [this] {
emit addOutput(Tr::tr("Build directory \"%1\" does not exist.").arg(m_buildDir.toUserOutput()), OutputFormat::ErrorMessage); if (!m_buildDir.exists()) {
emit finished(false); emit addOutput(Tr::tr("Build directory \"%1\" does not exist.")
return; .arg(m_buildDir.toUserOutput()), OutputFormat::ErrorMessage);
} 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); return false;
emit finished(false); }
return; emit addOutput(Tr::tr("Clean step completed successfully."), OutputFormat::NormalMessage);
} return true;
};
emit addOutput(Tr::tr("Clean step completed successfully."), OutputFormat::NormalMessage); return Sync(onSetup);
emit finished(true);
} }
bool NimCompilerCleanStep::removeCacheDirectory() bool NimCompilerCleanStep::removeCacheDirectory()