aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/haskell/stackbuildstep.cpp
blob: 4006ae9daad176531a58f67fa1f40cb85f2eb75a (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
// 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/buildconfiguration.h>
#include <projectexplorer/processparameters.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>

using namespace ProjectExplorer;

namespace Haskell {
namespace Internal {

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

QWidget *StackBuildStep::createConfigWidget()
{
    return new QWidget;
}

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

bool StackBuildStep::init()
{
    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;
}

StackBuildStepFactory::StackBuildStepFactory()
{
    registerStep<StackBuildStep>(Constants::C_STACK_BUILD_STEP_ID);
    setDisplayName(StackBuildStep::StackBuildStep::trDisplayName());
    setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
}

} // namespace Internal
} // namespace Haskell