diff options
Diffstat (limited to 'src/plugins/nim/project/nimcompilercleanstep.cpp')
-rw-r--r-- | src/plugins/nim/project/nimcompilercleanstep.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/plugins/nim/project/nimcompilercleanstep.cpp b/src/plugins/nim/project/nimcompilercleanstep.cpp index 570df83e58..ca5626776a 100644 --- a/src/plugins/nim/project/nimcompilercleanstep.cpp +++ b/src/plugins/nim/project/nimcompilercleanstep.cpp @@ -40,7 +40,25 @@ using namespace Utils; namespace Nim { -NimCompilerCleanStep::NimCompilerCleanStep(BuildStepList *parentList, Core::Id id) +class NimCompilerCleanStep final : public BuildStep +{ + Q_DECLARE_TR_FUNCTIONS(Nim::NimCompilerCleanStep) + +public: + NimCompilerCleanStep(BuildStepList *parentList, Utils::Id id); + +private: + bool init() final; + void doRun() final; + void doCancel() final {} // Can be left empty. The run() function hardly does anything. + + bool removeCacheDirectory(); + bool removeOutFilePath(); + + Utils::FilePath m_buildDir; +}; + +NimCompilerCleanStep::NimCompilerCleanStep(BuildStepList *parentList, Utils::Id id) : BuildStep(parentList, id) { setDefaultDisplayName(tr("Nim Clean Step")); @@ -51,14 +69,14 @@ NimCompilerCleanStep::NimCompilerCleanStep(BuildStepList *parentList, Core::Id i workingDirectory->setDisplayStyle(BaseStringAspect::LineEditDisplay); setSummaryUpdater([this, workingDirectory] { - workingDirectory->setFilePath(buildConfiguration()->buildDirectory()); + workingDirectory->setFilePath(buildDirectory()); return displayName(); }); } bool NimCompilerCleanStep::init() { - FilePath buildDir = buildConfiguration()->buildDirectory(); + FilePath buildDir = buildDirectory(); bool result = buildDir.exists(); if (result) m_buildDir = buildDir; @@ -68,32 +86,27 @@ bool NimCompilerCleanStep::init() void NimCompilerCleanStep::doRun() { if (!m_buildDir.exists()) { - emit addOutput(tr("Build directory \"%1\" does not exist.").arg(m_buildDir.toUserOutput()), BuildStep::OutputFormat::ErrorMessage); + emit addOutput(tr("Build directory \"%1\" does not exist.").arg(m_buildDir.toUserOutput()), OutputFormat::ErrorMessage); emit finished(false); return; } if (!removeCacheDirectory()) { - emit addOutput(tr("Failed to delete the cache directory."), BuildStep::OutputFormat::ErrorMessage); + emit addOutput(tr("Failed to delete the cache directory."), OutputFormat::ErrorMessage); emit finished(false); return; } if (!removeOutFilePath()) { - emit addOutput(tr("Failed to delete the out file."), BuildStep::OutputFormat::ErrorMessage); + emit addOutput(tr("Failed to delete the out file."), OutputFormat::ErrorMessage); emit finished(false); return; } - emit addOutput(tr("Clean step completed successfully."), BuildStep::OutputFormat::NormalMessage); + emit addOutput(tr("Clean step completed successfully."), OutputFormat::NormalMessage); emit finished(true); } -void NimCompilerCleanStep::doCancel() -{ - // Can be left empty. The run() function hardly does anything. -} - bool NimCompilerCleanStep::removeCacheDirectory() { auto bc = qobject_cast<NimBuildConfiguration*>(buildConfiguration()); |