blob: c1957cc976a5d77ad0d59253a7e87316ead4947f (
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
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
|
// Copyright (C) 2018 Jochen Seemann
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "conaninstallstep.h"
#include "conanconstants.h"
#include "conanplugin.h"
#include "conansettings.h"
#include "conantr.h"
#include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/gnumakeparser.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <projectexplorer/task.h>
#include <projectexplorer/toolchain.h>
using namespace ProjectExplorer;
using namespace Utils;
namespace Conan::Internal {
// ConanInstallStep
class ConanInstallStep final : public AbstractProcessStep
{
public:
ConanInstallStep(BuildStepList *bsl, Id id);
private:
bool init() final;
void setupOutputFormatter(OutputFormatter *formatter) final;
};
ConanInstallStep::ConanInstallStep(BuildStepList *bsl, Id id)
: AbstractProcessStep(bsl, id)
{
setUseEnglishOutput();
setDisplayName(Tr::tr("Conan install"));
auto conanFile = addAspect<StringAspect>();
conanFile->setSettingsKey("ConanPackageManager.InstallStep.ConanFile");
conanFile->setFilePath(ConanPlugin::conanFilePath(project(),
project()->projectDirectory() / "conanfile.txt"));
conanFile->setLabelText(Tr::tr("Conan file:"));
conanFile->setToolTip(Tr::tr("Enter location of conanfile.txt or conanfile.py."));
conanFile->setDisplayStyle(StringAspect::PathChooserDisplay);
conanFile->setExpectedKind(PathChooser::File);
auto additionalArguments = addAspect<StringAspect>();
additionalArguments->setSettingsKey("ConanPackageManager.InstallStep.AdditionalArguments");
additionalArguments->setLabelText(Tr::tr("Additional arguments:"));
additionalArguments->setDisplayStyle(StringAspect::LineEditDisplay);
auto buildMissing = addAspect<BoolAspect>();
buildMissing->setSettingsKey("ConanPackageManager.InstallStep.BuildMissing");
buildMissing->setLabel("Build missing:", BoolAspect::LabelPlacement::InExtraLabel);
buildMissing->setDefaultValue(true);
buildMissing->setValue(true);
setCommandLineProvider([=] {
BuildConfiguration::BuildType bt = buildConfiguration()->buildType();
const QString buildType = bt == BuildConfiguration::Release ? QString("Release")
: QString("Debug");
CommandLine cmd(ConanPlugin::conanSettings()->conanFilePath());
cmd.addArgs({"install", "-s", "build_type=" + buildType});
if (buildMissing->value())
cmd.addArg("--build=missing");
cmd.addArg(conanFile->value());
cmd.addArgs(additionalArguments->value(), CommandLine::Raw);
return cmd;
});
setSummaryUpdater([this]() -> QString {
QList<ToolChain *> tcList = ToolChainKitAspect::toolChains(target()->kit());
if (tcList.isEmpty())
return "<b>" + ToolChainKitAspect::msgNoToolChainInTarget() + "</b>";
ProcessParameters param;
setupProcessParameters(¶m);
return param.summary(displayName());
});
}
bool ConanInstallStep::init()
{
if (!AbstractProcessStep::init())
return false;
const QList<ToolChain *> tcList = ToolChainKitAspect::toolChains(target()->kit());
if (tcList.isEmpty()) {
emit addTask(Task::compilerMissingTask());
emitFaultyConfigurationMessage();
return false;
}
return true;
}
void ConanInstallStep::setupOutputFormatter(OutputFormatter *formatter)
{
formatter->addLineParser(new GnuMakeParser());
formatter->addLineParsers(kit()->createOutputParsers());
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
AbstractProcessStep::setupOutputFormatter(formatter);
}
// ConanInstallStepFactory
ConanInstallStepFactory::ConanInstallStepFactory()
{
registerStep<ConanInstallStep>(Constants::INSTALL_STEP);
setDisplayName(Tr::tr("Run conan install"));
}
} // Conan::Internal
|