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
|
|
|
|
|
|
2020-04-24 10:29:43 +02:00
|
|
|
#include "builddirparameters.h"
|
|
|
|
|
#include "cmakebuildtarget.h"
|
|
|
|
|
#include "cmakeprojectnodes.h"
|
|
|
|
|
#include "fileapireader.h"
|
2019-10-25 09:55:32 +02:00
|
|
|
|
2019-08-09 11:22:49 +02:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2020-04-24 10:29:43 +02:00
|
|
|
#include <utils/fileutils.h>
|
2021-05-12 15:12:48 +02:00
|
|
|
#include <utils/futuresynchronizer.h>
|
2020-04-24 10:29:43 +02:00
|
|
|
#include <utils/temporarydirectory.h>
|
|
|
|
|
|
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 {
|
2020-03-19 18:36:22 +01:00
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
class CMakeBuildConfiguration;
|
|
|
|
|
|
2021-02-04 14:53:42 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// CMakeBuildSystem:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2020-01-29 04:15:25 +03:00
|
|
|
class CMakeBuildSystem final : 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,
|
2020-04-02 14:49:05 +02:00
|
|
|
const ProjectExplorer::Node *node) const final;
|
2019-10-22 14:55:51 +02:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
// Actions:
|
2019-10-25 09:55:32 +02:00
|
|
|
void runCMake();
|
|
|
|
|
void runCMakeAndScanProjectTree();
|
2020-04-02 14:49:05 +02:00
|
|
|
void runCMakeWithExtraArguments();
|
2019-10-25 09:55:32 +02:00
|
|
|
|
|
|
|
|
bool persistCMakeState();
|
|
|
|
|
void clearCMakeCache();
|
|
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
// Context menu actions:
|
|
|
|
|
void buildCMakeTarget(const QString &buildTarget);
|
2019-10-25 09:55:32 +02:00
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
// Queries:
|
2019-10-25 09:55:32 +02:00
|
|
|
const QList<ProjectExplorer::BuildTargetInfo> appTargets() const;
|
|
|
|
|
QStringList buildTargetTitles() const;
|
|
|
|
|
const QList<CMakeBuildTarget> &buildTargets() const;
|
|
|
|
|
ProjectExplorer::DeploymentData deploymentData() const;
|
|
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
CMakeBuildConfiguration *cmakeBuildConfiguration() const;
|
|
|
|
|
|
2020-09-28 15:10:04 +02:00
|
|
|
QList<ProjectExplorer::TestCaseInfo> const testcasesInfo() const final;
|
|
|
|
|
Utils::CommandLine commandLineForTests(const QList<QString> &tests,
|
|
|
|
|
const QStringList &options) const final;
|
|
|
|
|
|
2020-04-24 10:29:43 +02:00
|
|
|
// Generic CMake helper functions:
|
|
|
|
|
static CMakeConfig parseCMakeCacheDotTxt(const Utils::FilePath &cacheFile,
|
|
|
|
|
QString *errorMessage);
|
|
|
|
|
|
2021-05-19 17:22:29 +02:00
|
|
|
static bool filteredOutTarget(const CMakeBuildTarget &target);
|
|
|
|
|
|
2021-01-14 16:38:55 +01:00
|
|
|
bool isMultiConfig() const;
|
|
|
|
|
bool usesAllCapsTargets() const;
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
private:
|
2020-04-24 10:29:43 +02:00
|
|
|
// Actually ask for parsing:
|
|
|
|
|
enum ReparseParameters {
|
2020-04-02 14:49:05 +02:00
|
|
|
REPARSE_DEFAULT = 0, // Nothing special:-)
|
|
|
|
|
REPARSE_FORCE_CMAKE_RUN
|
|
|
|
|
= (1 << 0), // Force cmake to run, apply extraCMakeArguments if non-empty
|
|
|
|
|
REPARSE_FORCE_INITIAL_CONFIGURATION
|
|
|
|
|
= (1 << 1), // Force initial configuration arguments to cmake
|
|
|
|
|
REPARSE_FORCE_EXTRA_CONFIGURATION = (1 << 2), // Force extra configuration arguments to cmake
|
|
|
|
|
REPARSE_SCAN = (1 << 3), // Run filesystem scan
|
|
|
|
|
REPARSE_URGENT = (1 << 4), // Do not delay the parser run by 1s
|
2020-04-24 10:29:43 +02:00
|
|
|
};
|
|
|
|
|
QString reparseParametersString(int reparseFlags);
|
|
|
|
|
void setParametersAndRequestParse(const BuildDirParameters ¶meters,
|
|
|
|
|
const int reparseParameters);
|
|
|
|
|
|
2021-03-02 13:08:29 +01:00
|
|
|
bool mustApplyExtraArguments(const BuildDirParameters ¶meters) const;
|
2020-04-24 10:29:43 +02:00
|
|
|
|
|
|
|
|
// State handling:
|
2020-04-23 18:29:27 +02:00
|
|
|
// Parser states:
|
|
|
|
|
void handleParsingSuccess();
|
|
|
|
|
void handleParsingError();
|
|
|
|
|
|
|
|
|
|
// Treescanner states:
|
|
|
|
|
void handleTreeScanningFinished();
|
2019-08-06 12:41:46 +02:00
|
|
|
|
|
|
|
|
// Combining Treescanner and Parser states:
|
|
|
|
|
void combineScanAndParse();
|
|
|
|
|
|
2020-04-23 18:29:27 +02:00
|
|
|
std::unique_ptr<CMakeProjectNode> generateProjectTree(
|
2021-06-16 11:33:35 +02:00
|
|
|
const ProjectExplorer::TreeScanner::Result &allFiles, bool includeHeadersNode);
|
2019-10-25 09:55:32 +02:00
|
|
|
void checkAndReportError(QString &errorMessage);
|
|
|
|
|
|
2021-02-04 16:22:40 +01:00
|
|
|
void updateCMakeConfiguration(QString &errorMessage);
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
void updateProjectData();
|
2020-10-26 15:36:59 +01:00
|
|
|
void updateFallbackProjectData();
|
2019-10-25 09:55:32 +02:00
|
|
|
QList<ProjectExplorer::ExtraCompiler *> findExtraCompilers();
|
2021-03-17 11:38:33 +01:00
|
|
|
void updateQmlJSCodeModel(const QStringList &extraHeaderPaths,
|
|
|
|
|
const QList<QByteArray> &moduleMappings);
|
2019-10-25 09:55:32 +02:00
|
|
|
|
|
|
|
|
void handleParsingSucceeded();
|
|
|
|
|
void handleParsingFailed(const QString &msg);
|
|
|
|
|
|
2020-08-11 16:36:24 +02:00
|
|
|
void wireUpConnections();
|
2020-04-20 17:33:36 +02:00
|
|
|
|
2021-06-09 15:08:13 +02:00
|
|
|
Utils::FilePath buildDirectory(const BuildDirParameters ¶meters);
|
2020-04-24 10:29:43 +02:00
|
|
|
void stopParsingAndClearState();
|
|
|
|
|
void becameDirty();
|
|
|
|
|
|
|
|
|
|
void updateReparseParameters(const int parameters);
|
|
|
|
|
int takeReparseParameters();
|
2019-08-06 12:41:46 +02:00
|
|
|
|
2020-09-28 15:10:04 +02:00
|
|
|
void runCTest();
|
|
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
ProjectExplorer::TreeScanner m_treeScanner;
|
2021-06-16 11:33:35 +02:00
|
|
|
ProjectExplorer::TreeScanner::Result m_allFiles;
|
2019-08-06 12:41:46 +02:00
|
|
|
QHash<QString, bool> m_mimeBinaryCache;
|
|
|
|
|
|
|
|
|
|
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;
|
2020-04-24 10:29:43 +02:00
|
|
|
|
|
|
|
|
// Parsing state:
|
|
|
|
|
BuildDirParameters m_parameters;
|
2020-04-02 14:49:05 +02:00
|
|
|
int m_reparseParameters = REPARSE_DEFAULT;
|
2020-04-24 10:29:43 +02:00
|
|
|
FileApiReader m_reader;
|
|
|
|
|
mutable bool m_isHandlingError = false;
|
2020-09-28 15:10:04 +02:00
|
|
|
|
|
|
|
|
// CTest integration
|
|
|
|
|
QString m_ctestPath;
|
|
|
|
|
QList<ProjectExplorer::TestCaseInfo> m_testNames;
|
2021-05-12 15:12:48 +02:00
|
|
|
Utils::FutureSynchronizer m_futureSynchronizer;
|
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
|