2019-08-06 12:41:46 +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
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
#include "builddirmanager.h"
|
|
|
|
|
|
2019-08-09 11:22:49 +02:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
namespace ProjectExplorer { class ExtraCompiler; }
|
|
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
namespace CppTools {
|
|
|
|
|
class CppProjectUpdater;
|
|
|
|
|
} // namespace CppTools
|
|
|
|
|
|
|
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
|
|
|
|
|
class CMakeProject;
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
class CMakeBuildConfiguration;
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// CMakeBuildSystem:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2019-08-09 11:22:49 +02:00
|
|
|
class CMakeBuildSystem : public ProjectExplorer::BuildSystem
|
2019-08-06 12:41:46 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2019-10-25 09:55:32 +02:00
|
|
|
explicit CMakeBuildSystem(CMakeBuildConfiguration *bc);
|
2019-08-06 12:41:46 +02:00
|
|
|
~CMakeBuildSystem() final;
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
void triggerParsing() final;
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2019-10-22 14:55:51 +02:00
|
|
|
bool supportsAction(ProjectExplorer::Node *context,
|
|
|
|
|
ProjectExplorer::ProjectAction action,
|
|
|
|
|
const ProjectExplorer::Node *node) const override;
|
|
|
|
|
|
|
|
|
|
bool addFiles(ProjectExplorer::Node *context,
|
|
|
|
|
const QStringList &filePaths, QStringList *) final;
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
QStringList filesGeneratedFrom(const QString &sourceFile) const final;
|
|
|
|
|
|
|
|
|
|
void runCMake();
|
|
|
|
|
void runCMakeAndScanProjectTree();
|
|
|
|
|
|
|
|
|
|
// Context menu actions:
|
|
|
|
|
void buildCMakeTarget(const QString &buildTarget);
|
2019-08-06 12:41:46 +02:00
|
|
|
// Treescanner states:
|
|
|
|
|
void handleTreeScanningFinished();
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
bool persistCMakeState();
|
|
|
|
|
void clearCMakeCache();
|
|
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
// Parser states:
|
2019-10-25 09:55:32 +02:00
|
|
|
void handleParsingSuccess();
|
|
|
|
|
void handleParsingError();
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::BuildConfiguration *buildConfiguration() const;
|
|
|
|
|
CMakeBuildConfiguration *cmakeBuildConfiguration() const;
|
|
|
|
|
|
|
|
|
|
const QList<ProjectExplorer::BuildTargetInfo> appTargets() const;
|
|
|
|
|
QStringList buildTargetTitles() const;
|
|
|
|
|
const QList<CMakeBuildTarget> &buildTargets() const;
|
|
|
|
|
ProjectExplorer::DeploymentData deploymentData() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::unique_ptr<CMakeProjectNode> generateProjectTree(
|
|
|
|
|
const QList<const ProjectExplorer::FileNode *> &allFiles);
|
2019-08-06 12:41:46 +02:00
|
|
|
|
|
|
|
|
// Combining Treescanner and Parser states:
|
|
|
|
|
void combineScanAndParse();
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
void checkAndReportError(QString &errorMessage);
|
|
|
|
|
|
|
|
|
|
void updateProjectData();
|
|
|
|
|
QList<ProjectExplorer::ExtraCompiler *> findExtraCompilers();
|
|
|
|
|
void updateQmlJSCodeModel();
|
|
|
|
|
|
|
|
|
|
void handleParsingSucceeded();
|
|
|
|
|
void handleParsingFailed(const QString &msg);
|
|
|
|
|
|
|
|
|
|
CMakeBuildConfiguration *m_buildConfiguration = nullptr;
|
|
|
|
|
BuildDirManager m_buildDirManager;
|
2019-08-06 12:41:46 +02:00
|
|
|
|
|
|
|
|
ProjectExplorer::TreeScanner m_treeScanner;
|
|
|
|
|
QHash<QString, bool> m_mimeBinaryCache;
|
|
|
|
|
QList<const ProjectExplorer::FileNode *> m_allFiles;
|
|
|
|
|
|
|
|
|
|
bool m_waitingForScan = false;
|
|
|
|
|
bool m_waitingForParse = false;
|
|
|
|
|
bool m_combinedScanAndParseResult = false;
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
ParseGuard m_currentGuard;
|
2019-08-06 12:41:46 +02:00
|
|
|
|
|
|
|
|
CppTools::CppProjectUpdater *m_cppCodeModelUpdater = nullptr;
|
|
|
|
|
QList<ProjectExplorer::ExtraCompiler *> m_extraCompilers;
|
2019-10-25 09:55:32 +02:00
|
|
|
QList<CMakeBuildTarget> m_buildTargets;
|
2019-08-06 12:41:46 +02:00
|
|
|
};
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
} // namespace Internal
|
2019-08-06 12:41:46 +02:00
|
|
|
} // namespace CMakeProjectManager
|