qmakeproject.h 8.09 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
Eike Ziller's avatar
Eike Ziller committed
3 4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con 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.
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.
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
****************************************************************************/
hjk's avatar
hjk committed
30

31 32
#ifndef QMAKEPROJECT_H
#define QMAKEPROJECT_H
con's avatar
con committed
33

34
#include "qmakeprojectmanager_global.h"
35
#include "qmakenodes.h"
con's avatar
con committed
36

37
#include <projectexplorer/project.h>
con's avatar
con committed
38 39
#include <projectexplorer/projectnodes.h>

40 41 42 43
#include <QStringList>
#include <QFutureInterface>
#include <QTimer>
#include <QFuture>
con's avatar
con committed
44 45

QT_BEGIN_NAMESPACE
46
class ProFileGlobals;
47
class QMakeVfs;
con's avatar
con committed
48 49
QT_END_NAMESPACE

50
namespace ProjectExplorer { class DeploymentData; }
Tobias Hunger's avatar
Tobias Hunger committed
51
namespace QtSupport { class ProFileReader; }
52

53
namespace QmakeProjectManager {
54
class QmakeBuildConfiguration;
55
class QmakeManager;
56 57
class QmakePriFileNode;
class QmakeProFileNode;
con's avatar
con committed
58

59
namespace Internal {
60
class CentralizedFolderWatcher;
61
class QmakeProjectFiles;
62
class QmakeProjectConfigWidget;
63
class QmakeProjectFile;
64 65
}

66
class  QMAKEPROJECTMANAGER_EXPORT QmakeProject : public ProjectExplorer::Project
con's avatar
con committed
67 68 69 70
{
    Q_OBJECT

public:
71
    QmakeProject(QmakeManager *manager, const QString &proFile);
72
    virtual ~QmakeProject();
con's avatar
con committed
73

74
    QString displayName() const;
75
    Core::IDocument *document() const;
con's avatar
con committed
76
    ProjectExplorer::IProjectManager *projectManager() const;
77
    QmakeManager *qmakeProjectManager() const;
con's avatar
con committed
78

79
    bool supportsKit(ProjectExplorer::Kit *k, QString *errorMesage) const;
80

81
    ProjectExplorer::ProjectNode *rootProjectNode() const;
82
    QmakeProFileNode *rootQmakeProjectNode() const;
83 84
    bool validParse(const Utils::FileName &proFilePath) const;
    bool parseInProgress(const Utils::FileName &proFilePath) const;
con's avatar
con committed
85 86

    virtual QStringList files(FilesMode fileMode) const;
87
    virtual QString generatedUiHeader(const Utils::FileName &formFile) const;
con's avatar
con committed
88

89
    enum Parsing {ExactParse, ExactAndCumulativeParse };
90 91
    QList<QmakeProFileNode *> allProFiles(const QList<QmakeProjectType> &projectTypes = QList<QmakeProjectType>(),
                                          Parsing parse = ExactParse) const;
92
    QList<QmakeProFileNode *> applicationProFiles(Parsing parse = ExactParse) const;
93
    bool hasApplicationProFile(const Utils::FileName &path) const;
94

95
    static QList<QmakeProFileNode *> nodesWithQtcRunnable(QList<QmakeProFileNode *> nodes);
96
    static QList<Core::Id> idsForNodes(Core::Id base, const QList<QmakeProFileNode *> &nodes);
con's avatar
con committed
97

98
    void notifyChanged(const Utils::FileName &name);
dt's avatar
dt committed
99

dt's avatar
dt committed
100
    /// \internal
101
    QtSupport::ProFileReader *createProFileReader(const QmakeProFileNode *qmakeProFileNode, QmakeBuildConfiguration *bc = 0);
dt's avatar
dt committed
102
    /// \internal
103
    ProFileGlobals *qmakeGlobals();
104
    /// \internal
105 106
    QMakeVfs *qmakeVfs();
    /// \internal
107
    void destroyProFileReader(QtSupport::ProFileReader *reader);
108

dt's avatar
dt committed
109
    /// \internal
110 111
    void scheduleAsyncUpdate(QmakeProjectManager::QmakeProFileNode *node,
                             QmakeProFileNode::AsyncUpdateDelay delay = QmakeProFileNode::ParseLater);
dt's avatar
dt committed
112 113 114 115 116 117 118
    /// \internal
    void incrementPendingEvaluateFutures();
    /// \internal
    void decrementPendingEvaluateFutures();
    /// \internal
    bool wasEvaluateCanceled();

119
    // For QmakeProFileNode after a on disk change
120
    void updateFileList();
121
    void updateCodeModels();
122

123 124
    void watchFolders(const QStringList &l, QmakePriFileNode *node);
    void unwatchFolders(const QStringList &l, QmakePriFileNode *node);
125

126 127
    bool needsConfiguration() const;

128
    void configureAsExampleProject(const QSet<Core::Id> &platforms);
129

130
    bool requiresTargetPanel() const;
131

132
    /// \internal
133
    QString disabledReasonForRunConfiguration(const Utils::FileName &proFilePath);
134

Tobias Hunger's avatar
Tobias Hunger committed
135
    /// used by the default implementation of shadowBuildDirectory
136
    static QString buildNameFor(const ProjectExplorer::Kit *k);
Tobias Hunger's avatar
Tobias Hunger committed
137

138
    void emitBuildDirectoryInitialized();
139
    static void proFileParseError(const QString &errorMessage);
140

141 142
    ProjectExplorer::ProjectImporter *createProjectImporter() const;

143 144 145
    enum AsyncUpdateState { Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown };
    AsyncUpdateState asyncUpdateState() const;

146
signals:
147
    void proFileUpdated(QmakeProjectManager::QmakeProFileNode *node, bool, bool);
148
    void buildDirectoryInitialized();
149
    void proFilesEvaluated();
150

con's avatar
con committed
151
public slots:
152
    void scheduleAsyncUpdate(QmakeProFileNode::AsyncUpdateDelay delay = QmakeProFileNode::ParseLater);
153
    void scheduleAsyncUpdateLater() { scheduleAsyncUpdate(); }
dt's avatar
dt committed
154 155

protected:
156
    RestoreResult fromMap(const QVariantMap &map, QString *errorMessage);
con's avatar
con committed
157

158
private:
dt's avatar
dt committed
159
    void asyncUpdate();
160
    void buildFinished(bool success);
dt's avatar
dt committed
161 162
    void activeTargetWasChanged();

163
    QString executableFor(const QmakeProFileNode *node);
164
    void updateRunConfigurations();
con's avatar
con committed
165

166 167
    void updateCppCodeModel();
    void updateQmlJSCodeModel();
168

169 170
    static void collectAllProFiles(QList<QmakeProFileNode *> &list, QmakeProFileNode *node, Parsing parse,
                                   const QList<QmakeProjectManager::QmakeProjectType> &projectTypes);
171 172
    static void findProFile(const Utils::FileName &fileName, QmakeProFileNode *root, QList<QmakeProFileNode *> &list);
    static bool hasSubNode(QmakePriFileNode *root, const Utils::FileName &path);
con's avatar
con committed
173

dt's avatar
dt committed
174
    static bool equalFileList(const QStringList &a, const QStringList &b);
con's avatar
con committed
175

176
    void updateBuildSystemData();
177 178
    void collectData(const QmakeProFileNode *node, ProjectExplorer::DeploymentData &deploymentData);
    void collectApplicationData(const QmakeProFileNode *node,
179
                                ProjectExplorer::DeploymentData &deploymentData);
180
    void collectLibraryData(const QmakeProFileNode *node,
181
            ProjectExplorer::DeploymentData &deploymentData);
182
    void startAsyncTimer(QmakeProFileNode::AsyncUpdateDelay delay);
183
    bool matchesKit(const ProjectExplorer::Kit *kit);
184

185
    QmakeManager *m_manager;
186
    QmakeProFileNode *m_rootProjectNode = 0;
con's avatar
con committed
187

188
    Internal::QmakeProjectFile *m_fileInfo = nullptr;
con's avatar
con committed
189 190 191 192 193 194

    // Current configuration
    QString m_oldQtIncludePath;
    QString m_oldQtLibsPath;

    // cached lists of all of files
195
    Internal::QmakeProjectFiles *m_projectFiles = nullptr;
con's avatar
con committed
196

197
    QMakeVfs *m_qmakeVfs = nullptr;
198

dt's avatar
dt committed
199
    // cached data during project rescan
200 201
    ProFileGlobals *m_qmakeGlobals = nullptr;
    int m_qmakeGlobalsRefCnt = 0;
dt's avatar
dt committed
202 203

    QTimer m_asyncUpdateTimer;
204 205 206 207
    QFutureInterface<void> *m_asyncUpdateFutureInterface = nullptr;
    int m_pendingEvaluateFuturesCount = 0;
    AsyncUpdateState m_asyncUpdateState = Base;
    bool m_cancelEvaluate = false;
208
    QList<QmakeProFileNode *> m_partialEvaluate;
209

dt's avatar
dt committed
210
    QFuture<void> m_codeModelFuture;
211

212
    Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher = nullptr;
213

214
    ProjectExplorer::Target *m_activeTarget = nullptr;
215

216
    friend class Internal::QmakeProjectFile;
217 218
    friend class Internal::QmakeProjectConfigWidget;
    friend class QmakeManager; // to schedule a async update if the unconfigured settings change
con's avatar
con committed
219 220
};

221
} // namespace QmakeProjectManager
con's avatar
con committed
222

223

224
#endif // QMAKEPROJECT_H