2016-10-17 14:35:48 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "builddirreader.h"
|
|
|
|
|
#include "servermode.h"
|
2017-06-15 10:48:16 +02:00
|
|
|
#include "cmakeparser.h"
|
2016-10-17 14:35:48 +02:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-03-14 15:35:02 +01:00
|
|
|
class CMakeListsNode;
|
|
|
|
|
|
2016-10-17 14:35:48 +02:00
|
|
|
class ServerModeReader : public BuildDirReader
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ServerModeReader();
|
|
|
|
|
~ServerModeReader() final;
|
|
|
|
|
|
|
|
|
|
void setParameters(const Parameters &p) final;
|
|
|
|
|
|
|
|
|
|
bool isCompatible(const Parameters &p) final;
|
|
|
|
|
void resetData() final;
|
|
|
|
|
void parse(bool force) final;
|
|
|
|
|
void stop() final;
|
|
|
|
|
|
|
|
|
|
bool isReady() const final;
|
|
|
|
|
bool isParsing() const final;
|
|
|
|
|
bool hasData() const final;
|
|
|
|
|
|
|
|
|
|
QList<CMakeBuildTarget> buildTargets() const final;
|
2016-12-01 15:25:32 +01:00
|
|
|
CMakeConfig takeParsedConfiguration() final;
|
2017-03-14 15:35:02 +01:00
|
|
|
void generateProjectTree(CMakeProjectNode *root,
|
2016-12-15 12:53:37 +01:00
|
|
|
const QList<const ProjectExplorer::FileNode *> &allFiles) final;
|
2017-02-06 16:59:53 +01:00
|
|
|
void updateCodeModel(CppTools::RawProjectParts &rpps) final;
|
2016-10-17 14:35:48 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void handleReply(const QVariantMap &data, const QString &inReplyTo);
|
|
|
|
|
void handleError(const QString &message);
|
|
|
|
|
void handleProgress(int min, int cur, int max, const QString &inReplyTo);
|
2017-03-13 14:32:12 +01:00
|
|
|
void handleSignal(const QString &signal, const QVariantMap &data);
|
2016-10-17 14:35:48 +02:00
|
|
|
|
|
|
|
|
struct Target;
|
|
|
|
|
struct Project;
|
|
|
|
|
|
|
|
|
|
struct IncludePath {
|
|
|
|
|
Utils::FileName path;
|
|
|
|
|
bool isSystem;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct FileGroup {
|
|
|
|
|
~FileGroup() { qDeleteAll(includePaths); includePaths.clear(); }
|
|
|
|
|
|
|
|
|
|
Target *target = nullptr;
|
|
|
|
|
QString compileFlags;
|
|
|
|
|
QStringList defines;
|
|
|
|
|
QList<IncludePath *> includePaths;
|
|
|
|
|
QString language;
|
|
|
|
|
QList<Utils::FileName> sources;
|
|
|
|
|
bool isGenerated;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Target {
|
|
|
|
|
~Target() { qDeleteAll(fileGroups); fileGroups.clear(); }
|
|
|
|
|
|
|
|
|
|
Project *project = nullptr;
|
|
|
|
|
QString name;
|
|
|
|
|
QString type;
|
|
|
|
|
QList<Utils::FileName> artifacts;
|
|
|
|
|
Utils::FileName sourceDirectory;
|
|
|
|
|
Utils::FileName buildDirectory;
|
|
|
|
|
QList<FileGroup *> fileGroups;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Project {
|
|
|
|
|
~Project() { qDeleteAll(targets); targets.clear(); }
|
|
|
|
|
QString name;
|
|
|
|
|
Utils::FileName sourceDirectory;
|
|
|
|
|
QList<Target *> targets;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void extractCodeModelData(const QVariantMap &data);
|
|
|
|
|
void extractConfigurationData(const QVariantMap &data);
|
2017-04-07 12:01:41 +02:00
|
|
|
Project *extractProjectData(const QVariantMap &data, QSet<QString> &knownTargets);
|
|
|
|
|
Target *extractTargetData(const QVariantMap &data, Project *p, QSet<QString> &knownTargets);
|
2016-10-17 14:35:48 +02:00
|
|
|
FileGroup *extractFileGroupData(const QVariantMap &data, const QDir &srcDir, Target *t);
|
|
|
|
|
void extractCMakeInputsData(const QVariantMap &data);
|
|
|
|
|
void extractCacheData(const QVariantMap &data);
|
|
|
|
|
|
2017-04-20 15:57:32 +02:00
|
|
|
void fixTarget(Target *target) const;
|
|
|
|
|
|
2017-03-24 18:38:00 +01:00
|
|
|
QHash<Utils::FileName, ProjectExplorer::ProjectNode *>
|
|
|
|
|
addCMakeLists(CMakeProjectNode *root, const QList<ProjectExplorer::FileNode *> &cmakeLists);
|
|
|
|
|
void addProjects(const QHash<Utils::FileName, ProjectExplorer::ProjectNode *> &cmakeListsNodes,
|
|
|
|
|
const QList<Project *> &projects,
|
2017-03-28 16:25:10 +02:00
|
|
|
QList<ProjectExplorer::FileNode *> &knownHeaderNodes);
|
2017-03-24 18:38:00 +01:00
|
|
|
void addTargets(const QHash<Utils::FileName, ProjectExplorer::ProjectNode *> &cmakeListsNodes,
|
|
|
|
|
const QList<Target *> &targets,
|
2017-03-28 16:25:10 +02:00
|
|
|
QList<ProjectExplorer::FileNode *> &knownHeaderNodes);
|
2017-01-26 18:35:49 +01:00
|
|
|
void addFileGroups(ProjectExplorer::ProjectNode *targetRoot,
|
|
|
|
|
const Utils::FileName &sourceDirectory,
|
2017-03-28 16:25:10 +02:00
|
|
|
const Utils::FileName &buildDirectory, const QList<FileGroup *> &fileGroups,
|
|
|
|
|
QList<ProjectExplorer::FileNode *> &knowHeaderNodes);
|
|
|
|
|
|
|
|
|
|
void addHeaderNodes(ProjectExplorer::ProjectNode *root,
|
|
|
|
|
const QList<ProjectExplorer::FileNode *> knownHeaders,
|
|
|
|
|
const QList<const ProjectExplorer::FileNode *> &allFiles);
|
2016-11-07 18:20:47 +01:00
|
|
|
|
2016-10-17 14:35:48 +02:00
|
|
|
bool m_hasData = false;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<ServerMode> m_cmakeServer;
|
2016-11-04 10:56:47 +01:00
|
|
|
std::unique_ptr<QFutureInterface<void>> m_future;
|
2016-10-17 14:35:48 +02:00
|
|
|
|
2016-11-29 13:41:49 +01:00
|
|
|
int m_progressStepMinimum = 0;
|
|
|
|
|
int m_progressStepMaximum = 1000;
|
2016-10-17 14:35:48 +02:00
|
|
|
|
|
|
|
|
CMakeConfig m_cmakeCache;
|
|
|
|
|
|
|
|
|
|
QSet<Utils::FileName> m_cmakeFiles;
|
|
|
|
|
QList<ProjectExplorer::FileNode *> m_cmakeInputsFileNodes;
|
|
|
|
|
|
|
|
|
|
QList<Project *> m_projects;
|
2016-11-30 14:13:59 +01:00
|
|
|
mutable QList<Target *> m_targets;
|
2016-10-17 14:35:48 +02:00
|
|
|
QList<FileGroup *> m_fileGroups;
|
2017-06-15 10:48:16 +02:00
|
|
|
|
|
|
|
|
CMakeParser m_parser;
|
2016-10-17 14:35:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CMakeProjectManager
|