cmakebuildstep.h 5.3 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
****************************************************************************/
dt's avatar
dt committed
30

31 32
#ifndef CMAKEBUILDSTEP_H
#define CMAKEBUILDSTEP_H
dt's avatar
dt committed
33

Tobias Hunger's avatar
Tobias Hunger committed
34
#include <projectexplorer/abstractprocessstep.h>
dt's avatar
dt committed
35

36
QT_BEGIN_NAMESPACE
37 38 39
class QLineEdit;
class QListWidget;
class QListWidgetItem;
40
QT_END_NAMESPACE
41

42 43
namespace Utils { class PathChooser; }

44
namespace ProjectExplorer { class ToolChain; }
Peter Kümmel's avatar
Peter Kümmel committed
45

dt's avatar
dt committed
46 47 48
namespace CMakeProjectManager {
namespace Internal {

dt's avatar
dt committed
49
class CMakeBuildConfiguration;
50
class CMakeRunConfiguration;
51
class CMakeBuildStepFactory;
dt's avatar
dt committed
52

53
class CMakeBuildStep : public ProjectExplorer::AbstractProcessStep
dt's avatar
dt committed
54
{
55
    Q_OBJECT
56
    friend class CMakeBuildStepFactory;
57

dt's avatar
dt committed
58
public:
59
    explicit CMakeBuildStep(ProjectExplorer::BuildStepList *bsl);
dt's avatar
dt committed
60 61

    CMakeBuildConfiguration *cmakeBuildConfiguration() const;
62
    CMakeBuildConfiguration *targetsActiveBuildConfiguration() const;
dt's avatar
dt committed
63

64
    bool init(QList<const BuildStep *> &earlierSteps) override;
dt's avatar
dt committed
65

66 67
    ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
    bool immutable() const override;
68 69

    QStringList buildTargets() const;
70
    bool buildsBuildTarget(const QString &target) const;
71
    void setBuildTarget(const QString &target, bool on);
72 73 74
    void setBuildTargets(const QStringList &targets);
    void clearBuildTargets();

75 76 77 78
    QString toolArguments() const;
    void setToolArguments(const QString &list);

    QString allArguments(const CMakeRunConfiguration *rc) const;
79

80 81 82
    bool addRunConfigurationArgument() const;
    void setAddRunConfigurationArgument(bool add);

83
    QString cmakeCommand() const;
Peter Kümmel's avatar
Peter Kümmel committed
84

85
    QVariantMap toMap() const override;
86

Tobias Hunger's avatar
Tobias Hunger committed
87 88
    static QString cleanTarget();

89
private:
90 91
    void buildTargetsChanged();

Peter Kümmel's avatar
Peter Kümmel committed
92
signals:
93
    void cmakeCommandChanged();
94
    void targetsToBuildChanged();
95

96
protected:
97 98
    void processStarted() override;
    void processFinished(int exitCode, QProcess::ExitStatus status) override;
99

100 101
    CMakeBuildStep(ProjectExplorer::BuildStepList *bsl, CMakeBuildStep *bs);
    CMakeBuildStep(ProjectExplorer::BuildStepList *bsl, Core::Id id);
102

103
    bool fromMap(const QVariantMap &map) override;
104

105
    // For parsing [ 76%]
106
    virtual void stdOutput(const QString &line) override;
107

dt's avatar
dt committed
108
private:
109
    void ctor();
110
    CMakeRunConfiguration *targetsActiveRunConfiguration() const;
111

112
    QRegExp m_percentProgress;
Peter Kümmel's avatar
Peter Kümmel committed
113 114
    QRegExp m_ninjaProgress;
    QString m_ninjaProgressString;
115
    QStringList m_buildTargets;
116
    QString m_toolArguments;
117
    bool m_addRunConfigurationArgument;
Peter Kümmel's avatar
Peter Kümmel committed
118
    bool m_useNinja;
dt's avatar
dt committed
119 120
};

121
class CMakeBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
dt's avatar
dt committed
122
{
123
    Q_OBJECT
dt's avatar
dt committed
124
public:
125
    CMakeBuildStepConfigWidget(CMakeBuildStep *buildStep);
dt's avatar
dt committed
126
    virtual QString displayName() const;
dt's avatar
dt committed
127
    virtual QString summaryText() const;
128 129

private:
130
    void itemChanged(QListWidgetItem*);
131
    void toolArgumentsEdited();
132
    void updateDetails();
133
    void buildTargetsChanged();
134 135
    void selectedBuildTargetsChanged();

136
private:
137
    CMakeBuildStep *m_buildStep;
138
    QListWidget *m_buildTargetsList;
139
    QLineEdit *m_toolArguments;
140
    QString m_summaryText;
dt's avatar
dt committed
141 142
};

143
class CMakeBuildStepFactory : public ProjectExplorer::IBuildStepFactory
dt's avatar
dt committed
144
{
145 146 147
    Q_OBJECT

public:
148
    explicit CMakeBuildStepFactory(QObject *parent = 0);
149

150 151
    bool canCreate(ProjectExplorer::BuildStepList *parent, Core::Id id) const;
    ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, Core::Id id);
152 153 154 155
    bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const;
    ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source);
    bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const;
    ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map);
156

157
    QList<Core::Id> availableCreationIds(ProjectExplorer::BuildStepList *bc) const;
158
    QString displayNameForId(Core::Id id) const;
dt's avatar
dt committed
159 160
};

161 162
} // namespace Internal
} // namespace CMakeProjectManager
dt's avatar
dt committed
163

164
#endif // CMAKEBUILDSTEP_H