forked from qt-creator/qt-creator
Haskell: Use new setup pattern for StackBuildStep
Change-Id: Id78047e755a3419499d804ada3edb7ec75fa61d1 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -31,7 +31,6 @@ class HaskellPluginPrivate
|
|||||||
public:
|
public:
|
||||||
HaskellEditorFactory editorFactory;
|
HaskellEditorFactory editorFactory;
|
||||||
HaskellBuildConfigurationFactory buildConfigFactory;
|
HaskellBuildConfigurationFactory buildConfigFactory;
|
||||||
StackBuildStepFactory stackBuildStepFactory;
|
|
||||||
HaskellRunConfigurationFactory runConfigFactory;
|
HaskellRunConfigurationFactory runConfigFactory;
|
||||||
ProjectExplorer::SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
|
ProjectExplorer::SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
|
||||||
};
|
};
|
||||||
@@ -59,6 +58,8 @@ private:
|
|||||||
{
|
{
|
||||||
d = new HaskellPluginPrivate;
|
d = new HaskellPluginPrivate;
|
||||||
|
|
||||||
|
setupHaskellStackBuildStep();
|
||||||
|
|
||||||
ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>(
|
ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>(
|
||||||
Constants::C_HASKELL_PROJECT_MIMETYPE);
|
Constants::C_HASKELL_PROJECT_MIMETYPE);
|
||||||
TextEditor::SnippetProvider::registerGroup(Constants::C_HASKELLSNIPPETSGROUP_ID,
|
TextEditor::SnippetProvider::registerGroup(Constants::C_HASKELLSNIPPETSGROUP_ID,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "haskellsettings.h"
|
#include "haskellsettings.h"
|
||||||
#include "haskelltr.h"
|
#include "haskelltr.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/abstractprocessstep.h>
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/processparameters.h>
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -14,43 +15,54 @@
|
|||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
namespace Haskell {
|
namespace Haskell::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
StackBuildStep::StackBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id)
|
static QString trDisplayName()
|
||||||
: AbstractProcessStep(bsl, id)
|
|
||||||
{
|
|
||||||
setDefaultDisplayName(trDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *StackBuildStep::createConfigWidget()
|
|
||||||
{
|
|
||||||
return new QWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString StackBuildStep::trDisplayName()
|
|
||||||
{
|
{
|
||||||
return Tr::tr("Stack Build");
|
return Tr::tr("Stack Build");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StackBuildStep::init()
|
class StackBuildStep final : public AbstractProcessStep
|
||||||
{
|
{
|
||||||
if (AbstractProcessStep::init()) {
|
public:
|
||||||
const auto projectDir = QDir(project()->projectDirectory().toString());
|
StackBuildStep(BuildStepList *bsl, Utils::Id id)
|
||||||
processParameters()->setCommandLine(
|
: AbstractProcessStep(bsl, id)
|
||||||
{settings().stackPath(),
|
{
|
||||||
{"build", "--work-dir", projectDir.relativeFilePath(buildDirectory().toString())}});
|
setDefaultDisplayName(trDisplayName());
|
||||||
processParameters()->setEnvironment(buildEnvironment());
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
StackBuildStepFactory::StackBuildStepFactory()
|
QWidget *createConfigWidget() final
|
||||||
|
{
|
||||||
|
return new QWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
registerStep<StackBuildStep>(Constants::C_STACK_BUILD_STEP_ID);
|
public:
|
||||||
setDisplayName(StackBuildStep::StackBuildStep::trDisplayName());
|
StackBuildStepFactory()
|
||||||
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
{
|
||||||
|
registerStep<StackBuildStep>(Constants::C_STACK_BUILD_STEP_ID);
|
||||||
|
setDisplayName(trDisplayName());
|
||||||
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void setupHaskellStackBuildStep()
|
||||||
|
{
|
||||||
|
static StackBuildStepFactory theStackBuildStepFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Haskell::Internal
|
||||||
} // namespace Haskell
|
|
||||||
|
|||||||
@@ -3,31 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/abstractprocessstep.h>
|
namespace Haskell::Internal {
|
||||||
|
|
||||||
namespace Haskell {
|
void setupHaskellStackBuildStep();
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class StackBuildStep : public ProjectExplorer::AbstractProcessStep
|
} // Haskell::Internal
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
StackBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id);
|
|
||||||
|
|
||||||
QWidget *createConfigWidget() override;
|
|
||||||
|
|
||||||
static QString trDisplayName();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool init() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class StackBuildStepFactory : public ProjectExplorer::BuildStepFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
StackBuildStepFactory();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Haskell
|
|
||||||
|
|||||||
Reference in New Issue
Block a user