forked from qt-creator/qt-creator
ProjectExplorer: Move BuildSystem owership to BuildConfiguration
... or Target. This patch moves build system from conceptually "one per project" to "one per target (i.e. per project-and-kit)" or "per BuildConfigurations" for targets where the builds differ significantly. Building requires usually items from the kit (Qt version, compiler, ...) so a target-agnostic build is practically almost always wrong. Moving the build system to the target also has the potential to solve issues caused by switching targets while parsing, that used Project::activeTarget() regularly, with potentially different results before and after the switch. This patch might create performance/size regressions when several targets are set up per project as the build system implementation's internal data are duplicated in this case. The idea is to fix that by sharing per-project pieces again in the project implementation once these problems occur. Change-Id: I87f640ce418b93175b5029124eaa55f3b8721dca Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -25,8 +25,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "builddirmanager.h"
|
||||
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
|
||||
namespace ProjectExplorer { class ExtraCompiler; }
|
||||
|
||||
namespace CppTools {
|
||||
class CppProjectUpdater;
|
||||
} // namespace CppTools
|
||||
@@ -37,7 +41,6 @@ class CMakeProject;
|
||||
|
||||
namespace Internal {
|
||||
class CMakeBuildConfiguration;
|
||||
} // namespace Internal
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// CMakeBuildSystem:
|
||||
@@ -48,12 +51,10 @@ class CMakeBuildSystem : public ProjectExplorer::BuildSystem
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CMakeBuildSystem(ProjectExplorer::Project *project);
|
||||
explicit CMakeBuildSystem(CMakeBuildConfiguration *bc);
|
||||
~CMakeBuildSystem() final;
|
||||
|
||||
protected:
|
||||
bool validateParsingContext(const ParsingContext &ctx) final;
|
||||
void parseProject(ParsingContext &&ctx) final;
|
||||
void triggerParsing() final;
|
||||
|
||||
bool supportsAction(ProjectExplorer::Node *context,
|
||||
ProjectExplorer::ProjectAction action,
|
||||
@@ -62,20 +63,49 @@ protected:
|
||||
bool addFiles(ProjectExplorer::Node *context,
|
||||
const QStringList &filePaths, QStringList *) final;
|
||||
|
||||
private:
|
||||
QStringList filesGeneratedFrom(const QString &sourceFile) const final;
|
||||
|
||||
void runCMake();
|
||||
void runCMakeAndScanProjectTree();
|
||||
|
||||
// Context menu actions:
|
||||
void buildCMakeTarget(const QString &buildTarget);
|
||||
// Treescanner states:
|
||||
void handleTreeScanningFinished();
|
||||
|
||||
bool persistCMakeState();
|
||||
void clearCMakeCache();
|
||||
|
||||
// Parser states:
|
||||
void handleParsingSuccess(Internal::CMakeBuildConfiguration *bc);
|
||||
void handleParsingError(Internal::CMakeBuildConfiguration *bc);
|
||||
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);
|
||||
|
||||
// Combining Treescanner and Parser states:
|
||||
void combineScanAndParse();
|
||||
|
||||
void updateProjectData(CMakeProject *p, Internal::CMakeBuildConfiguration *bc);
|
||||
QList<ProjectExplorer::ExtraCompiler *> findExtraCompilers(CMakeProject *p);
|
||||
void updateQmlJSCodeModel(CMakeProject *p, Internal::CMakeBuildConfiguration *bc);
|
||||
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;
|
||||
|
||||
ProjectExplorer::TreeScanner m_treeScanner;
|
||||
QHash<QString, bool> m_mimeBinaryCache;
|
||||
@@ -85,12 +115,12 @@ private:
|
||||
bool m_waitingForParse = false;
|
||||
bool m_combinedScanAndParseResult = false;
|
||||
|
||||
ParsingContext m_currentContext;
|
||||
ParseGuard m_currentGuard;
|
||||
|
||||
CppTools::CppProjectUpdater *m_cppCodeModelUpdater = nullptr;
|
||||
QList<ProjectExplorer::ExtraCompiler *> m_extraCompilers;
|
||||
|
||||
friend class Internal::CMakeBuildConfiguration; // For handleParsing* callbacks
|
||||
QList<CMakeBuildTarget> m_buildTargets;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
Reference in New Issue
Block a user