makestep.cpp 18.2 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
dt's avatar
dt committed
2
**
Eike Ziller's avatar
Eike Ziller committed
3
4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
dt's avatar
dt committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
dt's avatar
dt committed
7
**
hjk's avatar
hjk committed
8
9
10
11
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
Eike Ziller's avatar
Eike Ziller committed
12
13
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
Eike Ziller's avatar
Eike Ziller committed
14
** use the contact form at http://www.qt.io/contact-us.
dt's avatar
dt committed
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18
19
20
21
22
23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
hjk's avatar
hjk committed
24
**
Eike Ziller's avatar
Eike Ziller committed
25
26
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
con's avatar
con committed
27
28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
30

dt's avatar
dt committed
31
#include "makestep.h"
32

33
34
#include "cmakebuildconfiguration.h"
#include "cmakeparser.h"
dt's avatar
dt committed
35
36
37
#include "cmakeprojectconstants.h"
#include "cmakeproject.h"

Tobias Hunger's avatar
Tobias Hunger committed
38
#include <projectexplorer/buildsteplist.h>
Tobias Hunger's avatar
Tobias Hunger committed
39
#include <projectexplorer/deployconfiguration.h>
Tobias Hunger's avatar
Tobias Hunger committed
40
#include <projectexplorer/kitinformation.h>
41
#include <projectexplorer/projectexplorerconstants.h>
42
#include <projectexplorer/projectexplorer.h>
Tobias Hunger's avatar
Tobias Hunger committed
43
44
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
45

46
47
48
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtparser.h>

49
50
#include <coreplugin/find/itemviewfind.h>

51
#include <utils/qtcprocess.h>
52
#include <utils/pathchooser.h>
53

54
55
56
57
58
#include <QFormLayout>
#include <QGroupBox>
#include <QCheckBox>
#include <QLineEdit>
#include <QListWidget>
hjk's avatar
hjk committed
59

dt's avatar
dt committed
60
61
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
62
using namespace ProjectExplorer;
dt's avatar
dt committed
63

64
namespace {
65
66
67
68
const char MS_ID[] = "CMakeProjectManager.MakeStep";
const char CLEAN_KEY[] = "CMakeProjectManager.MakeStep.Clean";
const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets";
const char ADDITIONAL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments";
69
const char MAKE_COMMAND_KEY[] = "CMakeProjectManager.MakeStep.MakeCommand";
70
71
}

Tobias Hunger's avatar
Tobias Hunger committed
72
MakeStep::MakeStep(BuildStepList *bsl) :
73
    AbstractProcessStep(bsl, Core::Id(MS_ID)), m_clean(false)
dt's avatar
dt committed
74
{
75
76
77
    ctor();
}

78
MakeStep::MakeStep(BuildStepList *bsl, Core::Id id) :
79
    AbstractProcessStep(bsl, id), m_clean(false)
80
81
{
    ctor();
dt's avatar
dt committed
82
83
}

Tobias Hunger's avatar
Tobias Hunger committed
84
85
MakeStep::MakeStep(BuildStepList *bsl, MakeStep *bs) :
    AbstractProcessStep(bsl, bs),
86
87
    m_clean(bs->m_clean),
    m_buildTargets(bs->m_buildTargets),
88
89
    m_additionalArguments(bs->m_additionalArguments),
    m_makeCmd(bs->m_makeCmd)
90
{
91
92
    ctor();
}
93

94
95
void MakeStep::ctor()
{
96
97
    m_percentProgress = QRegExp(QLatin1String("^\\[\\s*(\\d*)%\\]"));
    m_ninjaProgress = QRegExp(QLatin1String("^\\[\\s*(\\d*)/\\s*(\\d*)"));
98
    m_ninjaProgressString = QLatin1String("[%f/%t "); // ninja: [33/100
99
100
    //: Default display name for the cmake make step.
    setDefaultDisplayName(tr("Make"));
Peter Kümmel's avatar
Peter Kümmel committed
101

102
    CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
Peter Kümmel's avatar
Peter Kümmel committed
103
104
    if (bc) {
        m_activeConfiguration = 0;
105
        connect(bc, &CMakeBuildConfiguration::useNinjaChanged, this, &MakeStep::makeCommandChanged);
Peter Kümmel's avatar
Peter Kümmel committed
106
107
108
109
    } else {
        // That means the step is in the deploylist, so we listen to the active build config
        // changed signal and react to the activeBuildConfigurationChanged() signal of the buildconfiguration
        m_activeConfiguration = targetsActiveBuildConfiguration();
110
        connect(target(), &Target::activeBuildConfigurationChanged, this, &MakeStep::activeBuildConfigurationChanged);
Peter Kümmel's avatar
Peter Kümmel committed
111
112
        activeBuildConfigurationChanged();
    }
113

114
115
    connect(static_cast<CMakeProject *>(project()), &CMakeProject::buildTargetsChanged,
            this, &MakeStep::buildTargetsChanged);
116
117
}

dt's avatar
dt committed
118
119
120
121
MakeStep::~MakeStep()
{
}

dt's avatar
dt committed
122
123
124
125
126
CMakeBuildConfiguration *MakeStep::cmakeBuildConfiguration() const
{
    return static_cast<CMakeBuildConfiguration *>(buildConfiguration());
}

Peter Kümmel's avatar
Peter Kümmel committed
127
128
129
130
131
132
133
134
CMakeBuildConfiguration *MakeStep::targetsActiveBuildConfiguration() const
{
    return static_cast<CMakeBuildConfiguration *>(target()->activeBuildConfiguration());
}

void MakeStep::activeBuildConfigurationChanged()
{
    if (m_activeConfiguration)
135
        disconnect(m_activeConfiguration, &CMakeBuildConfiguration::useNinjaChanged, this, &MakeStep::makeCommandChanged);
Peter Kümmel's avatar
Peter Kümmel committed
136
137
138

    m_activeConfiguration = targetsActiveBuildConfiguration();

139
    if (m_activeConfiguration)
140
        connect(m_activeConfiguration, &CMakeBuildConfiguration::useNinjaChanged, this, &MakeStep::makeCommandChanged);
141
142

    emit makeCommandChanged();
Peter Kümmel's avatar
Peter Kümmel committed
143
144
}

145
146
147
void MakeStep::buildTargetsChanged()
{
    QStringList filteredTargets;
148
    foreach (const QString &t, static_cast<CMakeProject *>(project())->buildTargetTitles()) {
149
150
151
152
153
154
        if (m_buildTargets.contains(t))
            filteredTargets.append(t);
    }
    setBuildTargets(filteredTargets);
}

155
156
157
158
159
void MakeStep::setClean(bool clean)
{
    m_clean = clean;
}

160
QVariantMap MakeStep::toMap() const
161
{
162
163
164
165
    QVariantMap map(AbstractProcessStep::toMap());
    map.insert(QLatin1String(CLEAN_KEY), m_clean);
    map.insert(QLatin1String(BUILD_TARGETS_KEY), m_buildTargets);
    map.insert(QLatin1String(ADDITIONAL_ARGUMENTS_KEY), m_additionalArguments);
166
    map.insert(QLatin1String(MAKE_COMMAND_KEY), m_makeCmd);
167
    return map;
168
169
}

170
bool MakeStep::fromMap(const QVariantMap &map)
171
{
172
173
    m_clean = map.value(QLatin1String(CLEAN_KEY)).toBool();
    m_buildTargets = map.value(QLatin1String(BUILD_TARGETS_KEY)).toStringList();
174
    m_additionalArguments = map.value(QLatin1String(ADDITIONAL_ARGUMENTS_KEY)).toString();
175
    m_makeCmd = map.value(QLatin1String(MAKE_COMMAND_KEY)).toString();
176

177
    return BuildStep::fromMap(map);
178
179
}

180

181
bool MakeStep::init()
dt's avatar
dt committed
182
{
dt's avatar
dt committed
183
    CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
184
    if (!bc)
185
186
        bc = targetsActiveBuildConfiguration();

187
188
    if (!bc)
        emit addTask(Task::buildConfigurationMissingTask());
189

190
    ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
191
192
    if (!tc)
        emit addTask(Task::compilerMissingTask());
193
194

    if (!bc || !tc) {
195
        emitFaultyConfigurationMessage();
Daniel Teske's avatar
Daniel Teske committed
196
        return false;
197
198
    }

199
200
    m_useNinja = bc->useNinja();

201
202
    QString arguments = Utils::QtcProcess::joinArgs(m_buildTargets);
    Utils::QtcProcess::addArgs(&arguments, additionalArguments());
203

204
    setIgnoreReturnValue(m_clean);
205

206
207
    ProcessParameters *pp = processParameters();
    pp->setMacroExpander(bc->macroExpander());
208
209
210
211
212
213
214
    Utils::Environment env = bc->environment();
    // Force output to english for the parsers. Do this here and not in the toolchain's
    // addToEnvironment() to not screw up the users run environment.
    env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
    if (m_useNinja && !env.value(QLatin1String("NINJA_STATUS")).startsWith(m_ninjaProgressString))
        env.set(QLatin1String("NINJA_STATUS"), m_ninjaProgressString + QLatin1String("%o/sec] "));
    pp->setEnvironment(env);
215
    pp->setWorkingDirectory(bc->buildDirectory().toString());
Peter Kümmel's avatar
Peter Kümmel committed
216
    pp->setCommand(makeCommand(tc, bc->environment()));
217
    pp->setArguments(arguments);
218
    pp->resolveAll();
219

220
    setOutputParser(new CMakeParser());
221
222
223
    IOutputParser *parser = target()->kit()->createOutputParser();
    if (parser)
        appendOutputParser(parser);
224
    outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
Tobias Hunger's avatar
Tobias Hunger committed
225
226

    return AbstractProcessStep::init();
dt's avatar
dt committed
227
228
229
230
}

void MakeStep::run(QFutureInterface<bool> &fi)
{
Tobias Hunger's avatar
Tobias Hunger committed
231
    AbstractProcessStep::run(fi);
dt's avatar
dt committed
232
233
}

234
BuildStepConfigWidget *MakeStep::createConfigWidget()
dt's avatar
dt committed
235
{
236
    return new MakeStepConfigWidget(this);
dt's avatar
dt committed
237
238
239
240
}

bool MakeStep::immutable() const
{
241
    return false;
dt's avatar
dt committed
242
243
}

244
void MakeStep::stdOutput(const QString &line)
245
{
246
247
    if (m_percentProgress.indexIn(line) != -1) {
        bool ok = false;
Nikolai Kosjar's avatar
Nikolai Kosjar committed
248
        int percent = m_percentProgress.cap(1).toInt(&ok);
249
        if (ok)
250
            futureInterface()->setProgressValue(percent);
Peter Kümmel's avatar
Peter Kümmel committed
251
252
253
254
255
256
257
    } else if (m_ninjaProgress.indexIn(line) != -1) {
        bool ok = false;
        int done = m_ninjaProgress.cap(1).toInt(&ok);
        if (ok) {
            int all = m_ninjaProgress.cap(2).toInt(&ok);
            if (ok && all != 0) {
                int percent = 100.0 * done/all;
258
                futureInterface()->setProgressValue(percent);
Peter Kümmel's avatar
Peter Kümmel committed
259
260
            }
        }
261
    }
Peter Kümmel's avatar
Peter Kümmel committed
262
263
264
265
    if (m_useNinja)
        AbstractProcessStep::stdError(line);
    else
        AbstractProcessStep::stdOutput(line);
266
267
}

268
269
270
271
272
QStringList MakeStep::buildTargets() const
{
    return m_buildTargets;
}

273
bool MakeStep::buildsBuildTarget(const QString &target) const
274
{
275
    return m_buildTargets.contains(target);
276
277
}

278
void MakeStep::setBuildTarget(const QString &buildTarget, bool on)
279
{
280
    QStringList old = m_buildTargets;
281
282
    if (on && !old.contains(buildTarget))
        old << buildTarget;
tomdeblauwe's avatar
tomdeblauwe committed
283
    else if (!on && old.contains(buildTarget))
284
        old.removeOne(buildTarget);
285
    setBuildTargets(old);
286
287
}

288
289
void MakeStep::setBuildTargets(const QStringList &targets)
{
290
291
292
293
    if (targets != m_buildTargets) {
        m_buildTargets = targets;
        emit targetsToBuildChanged();
    }
294
295
296
297
298
299
300
}

void MakeStep::clearBuildTargets()
{
    m_buildTargets.clear();
}

301
QString MakeStep::additionalArguments() const
302
{
303
    return m_additionalArguments;
304
305
}

306
void MakeStep::setAdditionalArguments(const QString &list)
307
{
308
    m_additionalArguments = list;
309
310
}

Peter Kümmel's avatar
Peter Kümmel committed
311
312
QString MakeStep::makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const
{
313
314
    if (!m_makeCmd.isEmpty())
        return m_makeCmd;
315
316
317
318
    CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
    if (!bc)
        bc = targetsActiveBuildConfiguration();
    if (bc && bc->useNinja())
Peter Kümmel's avatar
Peter Kümmel committed
319
        return QLatin1String("ninja");
320

Peter Kümmel's avatar
Peter Kümmel committed
321
322
323
324
325
326
    if (tc)
        return tc->makeCommand(env);

    return QLatin1String("make");
}

327
328
329
330
331
332
333
334
335
336
void MakeStep::setUserMakeCommand(const QString &make)
{
    m_makeCmd = make;
}

QString MakeStep::userMakeCommand() const
{
    return m_makeCmd;
}

dt's avatar
dt committed
337
//
338
// MakeStepConfigWidget
dt's avatar
dt committed
339
//
340

341
MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
342
343
344
    : m_makeStep(makeStep)
{
    QFormLayout *fl = new QFormLayout(this);
345
346
    fl->setMargin(0);
    fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
347
348
    setLayout(fl);

349
350
351
352
353
354
355
356
    m_makePathChooser = new Utils::PathChooser(this);
    m_makePathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
    m_makePathChooser->setBaseDirectory(Utils::PathChooser::homePath());
    m_makePathChooser->setHistoryCompleter(QLatin1String("PE.MakeCommand.History"));
    m_makePathChooser->setPath(m_makeStep->userMakeCommand());

    fl->addRow(tr("Override command:"), m_makePathChooser);

357
    m_additionalArguments = new QLineEdit(this);
358
    fl->addRow(tr("Additional arguments:"), m_additionalArguments);
dt_'s avatar
dt_ committed
359
    m_additionalArguments->setText(m_makeStep->additionalArguments());
360

361
    m_buildTargetsList = new QListWidget;
362
    m_buildTargetsList->setFrameStyle(QFrame::NoFrame);
363
    m_buildTargetsList->setMinimumHeight(200);
364
365
366
367
368

    QFrame *frame = new QFrame(this);
    frame->setFrameStyle(QFrame::StyledPanel);
    QVBoxLayout *frameLayout = new QVBoxLayout(frame);
    frameLayout->setMargin(0);
369
370
    frameLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_buildTargetsList,
                                                                       Core::ItemViewFind::LightColored));
371
372

    fl->addRow(tr("Targets:"), frame);
373

374
    CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->project());
375
    QStringList targetList = pro->buildTargetTitles();
Aurindam Jana's avatar
Aurindam Jana committed
376
    targetList.sort();
377
    foreach (const QString &buildTarget, targetList) {
378
        QListWidgetItem *item = new QListWidgetItem(buildTarget, m_buildTargetsList);
379
        item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
dt_'s avatar
dt_ committed
380
        item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
381
    }
382

dt_'s avatar
dt_ committed
383
384
    updateDetails();

385
    connect(m_makePathChooser, &Utils::PathChooser::rawPathChanged, this, &MakeStepConfigWidget::makeEdited);
386
387
388
389
    connect(m_additionalArguments, &QLineEdit::textEdited, this, &MakeStepConfigWidget::additionalArgumentsEdited);
    connect(m_buildTargetsList, &QListWidget::itemChanged, this, &MakeStepConfigWidget::itemChanged);
    connect(ProjectExplorer::ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
            this, &MakeStepConfigWidget::updateDetails);
dt_'s avatar
dt_ committed
390

391
392
393
394
    connect(pro, &CMakeProject::buildTargetsChanged, this, &MakeStepConfigWidget::buildTargetsChanged);
    connect(m_makeStep, &MakeStep::targetsToBuildChanged, this, &MakeStepConfigWidget::selectedBuildTargetsChanged);
    connect(pro, &CMakeProject::environmentChanged, this, &MakeStepConfigWidget::updateDetails);
    connect(m_makeStep, &MakeStep::makeCommandChanged, this, &MakeStepConfigWidget::updateDetails);
395
396
}

397
398
399
400
401
402
void MakeStepConfigWidget::makeEdited()
{
    m_makeStep->setUserMakeCommand(m_makePathChooser->rawPath());
    updateDetails();
}

403
void MakeStepConfigWidget::additionalArgumentsEdited()
404
{
405
    m_makeStep->setAdditionalArguments(m_additionalArguments->text());
406
    updateDetails();
407
408
}

409
void MakeStepConfigWidget::itemChanged(QListWidgetItem *item)
410
{
411
    m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked);
412
    updateDetails();
413
}
dt's avatar
dt committed
414

415
QString MakeStepConfigWidget::displayName() const
dt's avatar
dt committed
416
{
417
    return tr("Make", "CMakeProjectManager::MakeStepConfigWidget display name.");
dt's avatar
dt committed
418
419
}

420
void MakeStepConfigWidget::buildTargetsChanged()
421
{
422
    disconnect(m_buildTargetsList, &QListWidget::itemChanged, this, &MakeStepConfigWidget::itemChanged);
423
    m_buildTargetsList->clear();
424
    CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->target()->project());
tomdeblauwe's avatar
tomdeblauwe committed
425
    foreach (const QString& buildTarget, pro->buildTargetTitles()) {
426
        QListWidgetItem *item = new QListWidgetItem(buildTarget, m_buildTargetsList);
427
        item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
428
        item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
429
    }
430
    connect(m_buildTargetsList, &QListWidget::itemChanged, this, &MakeStepConfigWidget::itemChanged);
431
    updateSummary();
432
433
}

434
435
void MakeStepConfigWidget::selectedBuildTargetsChanged()
{
436
    disconnect(m_buildTargetsList, &QListWidget::itemChanged, this, &MakeStepConfigWidget::itemChanged);
437
    for (int y = 0; y < m_buildTargetsList->count(); ++y) {
438
        QListWidgetItem *item = m_buildTargetsList->item(y);
439
440
        item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
    }
441
    connect(m_buildTargetsList, &QListWidget::itemChanged, this, &MakeStepConfigWidget::itemChanged);
442
443
444
    updateSummary();
}

445
446
void MakeStepConfigWidget::updateDetails()
{
447
    BuildConfiguration *bc = m_makeStep->buildConfiguration();
448
    if (!bc)
449
        bc = m_makeStep->target()->activeBuildConfiguration();
Tobias Hunger's avatar
Tobias Hunger committed
450
    if (!bc) {
451
        m_summaryText = tr("<b>No build configuration found on this kit.</b>");
Tobias Hunger's avatar
Tobias Hunger committed
452
453
454
455
        updateSummary();
        return;
    }

Tobias Hunger's avatar
Tobias Hunger committed
456
    ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_makeStep->target()->kit());
457
    if (tc) {
458
        QString arguments = Utils::QtcProcess::joinArgs(m_makeStep->buildTargets());
459
460
461
462
463
        Utils::QtcProcess::addArgs(&arguments, m_makeStep->additionalArguments());

        ProcessParameters param;
        param.setMacroExpander(bc->macroExpander());
        param.setEnvironment(bc->environment());
464
        param.setWorkingDirectory(bc->buildDirectory().toString());
Peter Kümmel's avatar
Peter Kümmel committed
465
        param.setCommand(m_makeStep->makeCommand(tc, bc->environment()));
466
467
468
        param.setArguments(arguments);
        m_summaryText = param.summary(displayName());
    } else {
Tobias Hunger's avatar
Tobias Hunger committed
469
        m_summaryText = QLatin1String("<b>") + ProjectExplorer::ToolChainKitInformation::msgNoToolChainInTarget() + QLatin1String("</b>");
470
    }
471
    emit updateSummary();
dt's avatar
dt committed
472
473
}

dt's avatar
dt committed
474
475
QString MakeStepConfigWidget::summaryText() const
{
476
    return m_summaryText;
dt's avatar
dt committed
477
478
}

dt's avatar
dt committed
479
//
480
// MakeStepFactory
dt's avatar
dt committed
481
482
//

483
484
MakeStepFactory::MakeStepFactory(QObject *parent) :
    ProjectExplorer::IBuildStepFactory(parent)
dt's avatar
dt committed
485
486
487
{
}

488
MakeStepFactory::~MakeStepFactory()
dt's avatar
dt committed
489
{
490
491
}

492
bool MakeStepFactory::canCreate(BuildStepList *parent, Core::Id id) const
493
{
494
495
496
    if (parent->target()->project()->id() == Constants::CMAKEPROJECT_ID)
        return id == MS_ID;
    return false;
dt's avatar
dt committed
497
498
}

499
BuildStep *MakeStepFactory::create(BuildStepList *parent, Core::Id id)
dt's avatar
dt committed
500
{
Tobias Hunger's avatar
Tobias Hunger committed
501
    if (!canCreate(parent, id))
502
        return 0;
503
    MakeStep *step = new MakeStep(parent);
504
    if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) {
505
        step->setClean(true);
506
        step->setAdditionalArguments(QLatin1String("clean"));
507
508
    }
    return step;
dt's avatar
dt committed
509
510
}

Tobias Hunger's avatar
Tobias Hunger committed
511
bool MakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const
512
{
Tobias Hunger's avatar
Tobias Hunger committed
513
    return canCreate(parent, source->id());
514
515
}

Tobias Hunger's avatar
Tobias Hunger committed
516
BuildStep *MakeStepFactory::clone(BuildStepList *parent, BuildStep *source)
517
{
Tobias Hunger's avatar
Tobias Hunger committed
518
    if (!canClone(parent, source))
519
520
521
522
        return 0;
    return new MakeStep(parent, static_cast<MakeStep *>(source));
}

Tobias Hunger's avatar
Tobias Hunger committed
523
bool MakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
dt's avatar
dt committed
524
{
525
    return canCreate(parent, idFromMap(map));
dt's avatar
dt committed
526
527
}

Tobias Hunger's avatar
Tobias Hunger committed
528
BuildStep *MakeStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
529
{
Tobias Hunger's avatar
Tobias Hunger committed
530
    if (!canRestore(parent, map))
531
532
533
534
535
536
537
538
        return 0;
    MakeStep *bs(new MakeStep(parent));
    if (bs->fromMap(map))
        return bs;
    delete bs;
    return 0;
}

539
QList<Core::Id> MakeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
540
{
541
    if (parent->target()->project()->id() == Constants::CMAKEPROJECT_ID)
542
543
        return QList<Core::Id>() << Core::Id(MS_ID);
    return QList<Core::Id>();
544
545
}

546
QString MakeStepFactory::displayNameForId(Core::Id id) const
547
{
548
    if (id == MS_ID)
549
550
551
        return tr("Make", "Display name for CMakeProjectManager::MakeStep id.");
    return QString();
}
552
553
554
555
556
557
558
559
560

void MakeStep::processStarted()
{
    futureInterface()->setProgressRange(0, 100);
    AbstractProcessStep::processStarted();
}

void MakeStep::processFinished(int exitCode, QProcess::ExitStatus status)
{
561
    AbstractProcessStep::processFinished(exitCode, status);
562
563
    futureInterface()->setProgressValue(100);
}