diff options
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakebuildsystem.h')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakebuildsystem.h | 84 |
1 files changed, 64 insertions, 20 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.h b/src/plugins/cmakeprojectmanager/cmakebuildsystem.h index ad119ab4ab..86d77d7a7d 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.h @@ -25,10 +25,17 @@ #pragma once -#include "builddirmanager.h" +#include "builddirparameters.h" +#include "cmakebuildtarget.h" +#include "cmakeprojectnodes.h" +#include "fileapireader.h" +#include "utils/macroexpander.h" #include <projectexplorer/buildsystem.h> +#include <utils/fileutils.h> +#include <utils/temporarydirectory.h> + namespace ProjectExplorer { class ExtraCompiler; } namespace CppTools { @@ -36,10 +43,8 @@ class CppProjectUpdater; } // namespace CppTools namespace CMakeProjectManager { - -class CMakeProject; - namespace Internal { + class CMakeBuildConfiguration; // -------------------------------------------------------------------- @@ -58,43 +63,68 @@ public: bool supportsAction(ProjectExplorer::Node *context, ProjectExplorer::ProjectAction action, - const ProjectExplorer::Node *node) const override; + const ProjectExplorer::Node *node) const final; bool addFiles(ProjectExplorer::Node *context, const QStringList &filePaths, QStringList *) final; QStringList filesGeneratedFrom(const QString &sourceFile) const final; + // Actions: void runCMake(); void runCMakeAndScanProjectTree(); - - // Context menu actions: - void buildCMakeTarget(const QString &buildTarget); - // Treescanner states: - void handleTreeScanningFinished(); + void runCMakeWithExtraArguments(); bool persistCMakeState(); void clearCMakeCache(); - // Parser states: - void handleParsingSuccess(); - void handleParsingError(); - - ProjectExplorer::BuildConfiguration *buildConfiguration() const; - CMakeBuildConfiguration *cmakeBuildConfiguration() const; + // Context menu actions: + void buildCMakeTarget(const QString &buildTarget); + // Queries: const QList<ProjectExplorer::BuildTargetInfo> appTargets() const; QStringList buildTargetTitles() const; const QList<CMakeBuildTarget> &buildTargets() const; ProjectExplorer::DeploymentData deploymentData() const; + CMakeBuildConfiguration *cmakeBuildConfiguration() const; + + // Generic CMake helper functions: + static CMakeConfig parseCMakeCacheDotTxt(const Utils::FilePath &cacheFile, + QString *errorMessage); + private: - std::unique_ptr<CMakeProjectNode> generateProjectTree( - const QList<const ProjectExplorer::FileNode *> &allFiles); + // Actually ask for parsing: + enum ReparseParameters { + 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 + }; + QString reparseParametersString(int reparseFlags); + void setParametersAndRequestParse(const BuildDirParameters ¶meters, + const int reparseParameters); + + bool mustApplyExtraArguments() const; + + // State handling: + // Parser states: + void handleParsingSuccess(); + void handleParsingError(); + + // Treescanner states: + void handleTreeScanningFinished(); // Combining Treescanner and Parser states: void combineScanAndParse(); + std::unique_ptr<CMakeProjectNode> generateProjectTree( + const QList<const ProjectExplorer::FileNode *> &allFiles); + void checkAndReportError(QString &errorMessage); void updateProjectData(); @@ -104,8 +134,14 @@ private: void handleParsingSucceeded(); void handleParsingFailed(const QString &msg); - CMakeBuildConfiguration *m_buildConfiguration = nullptr; - BuildDirManager m_buildDirManager; + void wireUpConnections(const ProjectExplorer::Project *p); + + Utils::FilePath workDirectory(const BuildDirParameters ¶meters); + void stopParsingAndClearState(); + void becameDirty(); + + void updateReparseParameters(const int parameters); + int takeReparseParameters(); ProjectExplorer::TreeScanner m_treeScanner; QHash<QString, bool> m_mimeBinaryCache; @@ -120,6 +156,14 @@ private: CppTools::CppProjectUpdater *m_cppCodeModelUpdater = nullptr; QList<ProjectExplorer::ExtraCompiler *> m_extraCompilers; QList<CMakeBuildTarget> m_buildTargets; + + // Parsing state: + BuildDirParameters m_parameters; + int m_reparseParameters = REPARSE_DEFAULT; + mutable std::unordered_map<Utils::FilePath, std::unique_ptr<Utils::TemporaryDirectory>> + m_buildDirToTempDir; + FileApiReader m_reader; + mutable bool m_isHandlingError = false; }; } // namespace Internal |