qbsbuildstep.h 5.94 KB
Newer Older
1 2
/****************************************************************************
**
3 4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
5 6 7 8 9 10 11
**
** This file is part of Qt Creator.
**
** 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
12 13 14
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
15
**
16 17 18 19 20 21 22
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 24 25
**
****************************************************************************/

hjk's avatar
hjk committed
26
#pragma once
27 28 29 30

#include "qbsbuildconfiguration.h"

#include <projectexplorer/buildstep.h>
31
#include <projectexplorer/task.h>
32 33 34

#include <qbs.h>

35 36
namespace Utils { class FancyLineEdit; }

37 38
namespace QbsProjectManager {
namespace Internal {
39
class QbsProject;
40 41 42 43 44 45 46 47

class QbsBuildStepConfigWidget;

class QbsBuildStep : public ProjectExplorer::BuildStep
{
    Q_OBJECT

public:
48
    explicit QbsBuildStep(ProjectExplorer::BuildStepList *bsl);
49
    QbsBuildStep(ProjectExplorer::BuildStepList *bsl, const QbsBuildStep *other);
50
    ~QbsBuildStep() override;
51

52
    bool init(QList<const BuildStep *> &earlierSteps) override;
53

54
    void run(QFutureInterface<bool> &fi) override;
55

56
    ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
57

58 59
    bool runInGuiThread() const override;
    void cancel() override;
60 61 62 63 64

    QVariantMap qbsConfiguration() const;
    void setQbsConfiguration(const QVariantMap &config);

    bool keepGoing() const;
65
    bool showCommandLines() const;
66 67
    bool install() const;
    bool cleanInstallRoot() const;
68 69 70
    int maxJobs() const;
    QString buildVariant() const;

71 72
    bool isQmlDebuggingEnabled() const;

73 74
    bool fromMap(const QVariantMap &map) override;
    QVariantMap toMap() const override;
75 76 77 78 79 80 81

signals:
    void qbsConfigurationChanged();
    void qbsBuildOptionsChanged();

private slots:
    void buildingDone(bool success);
82
    void reparsingDone(bool success);
83 84 85 86 87 88 89 90 91 92 93 94 95 96
    void handleTaskStarted(const QString &desciption, int max);
    void handleProgress(int value);
    void handleCommandDescriptionReport(const QString &highlight, const QString &message);
    void handleProcessResultReport(const qbs::ProcessResult &result);

private:
    void createTaskAndOutput(ProjectExplorer::Task::TaskType type,
                             const QString &message, const QString &file, int line);

    void setBuildVariant(const QString &variant);
    QString profile() const;

    void setKeepGoing(bool kg);
    void setMaxJobs(int jobcount);
97
    void setShowCommandLines(bool show);
98 99
    void setInstall(bool install);
    void setCleanInstallRoot(bool clean);
100

101 102
    void parseProject();
    void build();
103 104
    void finish();

105 106
    QbsProject *qbsProject() const;

107 108
    QVariantMap m_qbsConfiguration;
    qbs::BuildOptions m_qbsBuildOptions;
109 110

    // Temporary data:
111
    QStringList m_changedFiles;
112
    QStringList m_activeFileTags;
113
    QStringList m_products;
114 115 116 117

    QFutureInterface<bool> *m_fi;
    qbs::BuildJob *m_job;
    int m_progressBase;
118
    bool m_lastWasSuccess;
119
    ProjectExplorer::IOutputParser *m_parser;
120
    bool m_parsingProject;
121 122 123 124 125 126 127 128 129 130 131

    friend class QbsBuildStepConfigWidget;
};

namespace Ui { class QbsBuildStepConfigWidget; }

class QbsBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
{
    Q_OBJECT
public:
    QbsBuildStepConfigWidget(QbsBuildStep *step);
Orgad Shaneh's avatar
Orgad Shaneh committed
132
    ~QbsBuildStepConfigWidget();
133 134 135 136 137
    QString summaryText() const;
    QString displayName() const;

private slots:
    void updateState();
138
    void updateQmlDebuggingOption();
139
    void updatePropertyEdit(const QVariantMap &data);
140 141

    void changeBuildVariant(int);
142
    void changeShowCommandLines(bool show);
143 144
    void changeKeepGoing(bool kg);
    void changeJobCount(int count);
145 146
    void changeInstall(bool install);
    void changeCleanInstallRoot(bool clean);
147
    void applyCachedProperties();
148

149 150 151
    // QML debugging:
    void linkQmlDebuggingLibraryChecked(bool checked);

152
private:
153 154
    bool validateProperties(Utils::FancyLineEdit *edit, QString *errorMessage);

155 156
    Ui::QbsBuildStepConfigWidget *m_ui;

157
    QList<QPair<QString, QString> > m_propertyCache;
158 159
    QbsBuildStep *m_step;
    QString m_summary;
160
    bool m_ignoreChange;
161 162 163 164 165 166 167 168 169 170
};

class QbsBuildStepFactory : public ProjectExplorer::IBuildStepFactory
{
    Q_OBJECT

public:
    explicit QbsBuildStepFactory(QObject *parent = 0);

    // used to show the list of possible additons to a target, returns a list of types
171
    QList<Core::Id> availableCreationIds(ProjectExplorer::BuildStepList *parent) const override;
172
    // used to translate the types to names to display to the user
173
    QString displayNameForId(Core::Id id) const override;
174

175 176
    bool canCreate(ProjectExplorer::BuildStepList *parent, Core::Id id) const override;
    ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, Core::Id id) override;
177
    // used to recreate the runConfigurations when restoring settings
178 179 180 181
    bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const override;
    ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) override;
    bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const override;
    ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) override;
182 183 184 185
};

} // namespace Internal
} // namespace QbsProjectManager