diff options
author | hjk <[email protected]> | 2023-11-20 12:13:01 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2023-11-20 15:06:49 +0000 |
commit | e28110f6fd9cce572972a4ec7d26d0c51a7c4b32 (patch) | |
tree | 27913df88949850be566932f52dba325780034b7 /src/plugins/haskell/stackbuildstep.cpp | |
parent | 2b88b514daecae262d45e3639a16a2b3faa8d707 (diff) |
Haskell: Use new setup pattern for StackBuildStep
Change-Id: Id78047e755a3419499d804ada3edb7ec75fa61d1
Reviewed-by: Jarek Kobus <[email protected]>
Diffstat (limited to 'src/plugins/haskell/stackbuildstep.cpp')
-rw-r--r-- | src/plugins/haskell/stackbuildstep.cpp | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/src/plugins/haskell/stackbuildstep.cpp b/src/plugins/haskell/stackbuildstep.cpp index 4006ae9daad..b7ba35fbb60 100644 --- a/src/plugins/haskell/stackbuildstep.cpp +++ b/src/plugins/haskell/stackbuildstep.cpp @@ -7,6 +7,7 @@ #include "haskellsettings.h" #include "haskelltr.h" +#include <projectexplorer/abstractprocessstep.h> #include <projectexplorer/buildconfiguration.h> #include <projectexplorer/processparameters.h> #include <projectexplorer/project.h> @@ -14,43 +15,54 @@ using namespace ProjectExplorer; -namespace Haskell { -namespace Internal { +namespace Haskell::Internal { -StackBuildStep::StackBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id) - : AbstractProcessStep(bsl, id) +static QString trDisplayName() { - setDefaultDisplayName(trDisplayName()); + return Tr::tr("Stack Build"); } -QWidget *StackBuildStep::createConfigWidget() +class StackBuildStep final : public AbstractProcessStep { - return new QWidget; -} +public: + StackBuildStep(BuildStepList *bsl, Utils::Id id) + : AbstractProcessStep(bsl, id) + { + setDefaultDisplayName(trDisplayName()); + } -QString StackBuildStep::trDisplayName() -{ - return Tr::tr("Stack Build"); -} + QWidget *createConfigWidget() final + { + return new QWidget; + } -bool StackBuildStep::init() + bool init() final + { + if (AbstractProcessStep::init()) { + const auto projectDir = QDir(project()->projectDirectory().toString()); + processParameters()->setCommandLine( + {settings().stackPath(), + {"build", "--work-dir", projectDir.relativeFilePath(buildDirectory().toString())}}); + processParameters()->setEnvironment(buildEnvironment()); + } + return true; + } +}; + +class StackBuildStepFactory final : public BuildStepFactory { - if (AbstractProcessStep::init()) { - const auto projectDir = QDir(project()->projectDirectory().toString()); - processParameters()->setCommandLine( - {settings().stackPath(), - {"build", "--work-dir", projectDir.relativeFilePath(buildDirectory().toString())}}); - processParameters()->setEnvironment(buildEnvironment()); +public: + StackBuildStepFactory() + { + registerStep<StackBuildStep>(Constants::C_STACK_BUILD_STEP_ID); + setDisplayName(trDisplayName()); + setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); } - return true; -} +}; -StackBuildStepFactory::StackBuildStepFactory() +void setupHaskellStackBuildStep() { - registerStep<StackBuildStep>(Constants::C_STACK_BUILD_STEP_ID); - setDisplayName(StackBuildStep::StackBuildStep::trDisplayName()); - setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + static StackBuildStepFactory theStackBuildStepFactory; } -} // namespace Internal -} // namespace Haskell +} // Haskell::Internal |