aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/haskell/stackbuildstep.cpp
blob: b7ba35fbb60a141b221753921169e38639dcaae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "stackbuildstep.h"

#include "haskellconstants.h"
#include "haskellsettings.h"
#include "haskelltr.h"

#include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/processparameters.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>

using namespace ProjectExplorer;

namespace Haskell::Internal {

static QString trDisplayName()
{
    return Tr::tr("Stack Build");
}

class StackBuildStep final : public AbstractProcessStep
{
public:
    StackBuildStep(BuildStepList *bsl, Utils::Id id)
        : AbstractProcessStep(bsl, id)
    {
        setDefaultDisplayName(trDisplayName());
    }

    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
{
public:
    StackBuildStepFactory()
    {
        registerStep<StackBuildStep>(Constants::C_STACK_BUILD_STEP_ID);
        setDisplayName(trDisplayName());
        setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
    }
};

void setupHaskellStackBuildStep()
{
    static StackBuildStepFactory theStackBuildStepFactory;
}

} // Haskell::Internal