-
Notifications
You must be signed in to change notification settings - Fork 9
/
cmakeinstallstep.cpp
125 lines (94 loc) · 3.71 KB
/
cmakeinstallstep.cpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cmakeinstallstep.h"
#include "cmakeabstractprocessstep.h"
#include "cmakebuildsystem.h"
#include "cmakekitaspect.h"
#include "cmakeparser.h"
#include "cmakeprojectconstants.h"
#include "cmakeprojectmanagertr.h"
#include "cmaketool.h"
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/processparameters.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/layoutbuilder.h>
using namespace Core;
using namespace ProjectExplorer;
using namespace Utils;
namespace CMakeProjectManager::Internal {
// CMakeInstallStep
class CMakeInstallStep : public CMakeAbstractProcessStep
{
public:
CMakeInstallStep(BuildStepList *bsl, Id id)
: CMakeAbstractProcessStep(bsl, id)
{
cmakeArguments.setSettingsKey("CMakeProjectManager.InstallStep.CMakeArguments");
cmakeArguments.setLabelText(Tr::tr("CMake arguments:"));
cmakeArguments.setDisplayStyle(StringAspect::LineEditDisplay);
setCommandLineProvider([this] { return cmakeCommand(); });
}
private:
CommandLine cmakeCommand() const;
void setupOutputFormatter(OutputFormatter *formatter) override;
QWidget *createConfigWidget() override;
StringAspect cmakeArguments{this};
};
void CMakeInstallStep::setupOutputFormatter(OutputFormatter *formatter)
{
CMakeParser *cmakeParser = new CMakeParser;
cmakeParser->setSourceDirectory(project()->projectDirectory());
formatter->addLineParsers({cmakeParser});
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
CMakeAbstractProcessStep::setupOutputFormatter(formatter);
}
CommandLine CMakeInstallStep::cmakeCommand() const
{
CommandLine cmd;
if (CMakeTool *tool = CMakeKitAspect::cmakeTool(kit()))
cmd.setExecutable(tool->cmakeExecutable());
FilePath buildDirectory = ".";
if (buildConfiguration())
buildDirectory = buildConfiguration()->buildDirectory();
cmd.addArgs({"--install", buildDirectory.path()});
auto bs = qobject_cast<CMakeBuildSystem *>(buildSystem());
if (bs && bs->isMultiConfigReader()) {
cmd.addArg("--config");
cmd.addArg(bs->cmakeBuildType());
}
cmd.addArgs(cmakeArguments(), CommandLine::Raw);
return cmd;
}
QWidget *CMakeInstallStep::createConfigWidget()
{
auto updateDetails = [this] {
ProcessParameters param;
setupProcessParameters(¶m);
param.setCommandLine(cmakeCommand());
setSummaryText(param.summary(displayName()));
};
setDisplayName(Tr::tr("Install", "ConfigWidget display name."));
using namespace Layouting;
auto widget = Form { cmakeArguments, noMargin }.emerge();
updateDetails();
connect(&cmakeArguments, &StringAspect::changed, this, updateDetails);
connect(ProjectExplorerPlugin::instance(),
&ProjectExplorerPlugin::settingsChanged,
this,
updateDetails);
connect(buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, this, updateDetails);
connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged, this, updateDetails);
return widget;
}
// CMakeInstallStepFactory
CMakeInstallStepFactory::CMakeInstallStepFactory()
{
registerStep<CMakeInstallStep>(Constants::CMAKE_INSTALL_STEP_ID);
setDisplayName(
Tr::tr("CMake Install", "Display name for CMakeProjectManager::CMakeInstallStep id."));
setSupportedProjectType(Constants::CMAKE_PROJECT_ID);
setSupportedStepLists({ProjectExplorer::Constants::BUILDSTEPS_DEPLOY});
}
} // CMakeProjectManager::Internal