Commit 683b9652 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Encapsulate BuildDirManager in CMakeBC

This will make it easier to introduce a new type of BuildDirManager
to accommodate cmake server-mode.

Change-Id: I989aab9df44dff1cfdff226ef97bb30bb092ffdd
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 5481ca6e
......@@ -159,11 +159,6 @@ void CMakeBuildConfiguration::maybeForceReparse()
m_buildDirManager->maybeForceReparse();
}
BuildDirManager *CMakeBuildConfiguration::buildDirManager() const
{
return m_buildDirManager;
}
bool CMakeBuildConfiguration::isParsing() const
{
return m_buildDirManager && m_buildDirManager->isParsing();
......@@ -179,6 +174,37 @@ bool CMakeBuildConfiguration::persistCMakeState()
return m_buildDirManager->persistCMakeState();
}
void CMakeBuildConfiguration::runCMake()
{
if (!m_buildDirManager || m_buildDirManager->isParsing())
return;
m_buildDirManager->checkConfiguration();
m_buildDirManager->forceReparse();
}
void CMakeBuildConfiguration::clearCache()
{
if (m_buildDirManager)
m_buildDirManager->clearCache();
}
QList<CMakeBuildTarget> CMakeBuildConfiguration::buildTargets() const
{
if (!m_buildDirManager || m_buildDirManager->isParsing())
return QList<CMakeBuildTarget>();
return m_buildDirManager->buildTargets();
}
void CMakeBuildConfiguration::generateProjectTree(CMakeProjectNode *root) const
{
if (!m_buildDirManager || m_buildDirManager->isParsing())
return;
return m_buildDirManager->generateProjectTree(root);
}
FileName CMakeBuildConfiguration::shadowBuildDirectory(const FileName &projectFilePath,
const Kit *k,
const QString &bcName,
......@@ -196,7 +222,7 @@ FileName CMakeBuildConfiguration::shadowBuildDirectory(const FileName &projectFi
QList<ConfigModel::DataItem> CMakeBuildConfiguration::completeCMakeConfiguration() const
{
if (!m_buildDirManager && m_buildDirManager->isParsing())
if (!m_buildDirManager || m_buildDirManager->isParsing())
return QList<ConfigModel::DataItem>();
if (m_completeConfigurationCache.isEmpty())
......@@ -234,7 +260,7 @@ QList<ConfigModel::DataItem> CMakeBuildConfiguration::completeCMakeConfiguration
void CMakeBuildConfiguration::setCurrentCMakeConfiguration(const QList<ConfigModel::DataItem> &items)
{
if (m_buildDirManager->isParsing())
if (!m_buildDirManager || m_buildDirManager->isParsing())
return;
const CMakeConfig newConfig = Utils::transform(items, [](const ConfigModel::DataItem &i) {
......
......@@ -26,6 +26,7 @@
#pragma once
#include "cmakeconfigitem.h"
#include "cmakeproject.h"
#include "configmodel.h"
#include <projectexplorer/buildconfiguration.h>
......@@ -70,13 +71,16 @@ public:
QString error() const;
QString warning() const;
BuildDirManager *buildDirManager() const;
bool isParsing() const;
void maybeForceReparse();
void resetData();
bool persistCMakeState();
void runCMake();
void clearCache();
QList<CMakeBuildTarget> buildTargets() const;
void generateProjectTree(CMakeProjectNode *root) const;
static Utils::FileName
shadowBuildDirectory(const Utils::FileName &projectFilePath, const ProjectExplorer::Kit *k,
......
......@@ -25,7 +25,6 @@
#include "cmakeproject.h"
#include "builddirmanager.h"
#include "cmakebuildconfiguration.h"
#include "cmakekitinformation.h"
#include "cmakeprojectconstants.h"
......@@ -201,10 +200,7 @@ void CMakeProject::updateProjectData()
return;
Kit *k = t->kit();
BuildDirManager *bdm = cmakeBc->buildDirManager();
QTC_ASSERT(bdm, return);
bdm->generateProjectTree(static_cast<CMakeProjectNode *>(rootProjectNode()));
cmakeBc->generateProjectTree(static_cast<CMakeProjectNode *>(rootProjectNode()));
updateApplicationAndDeploymentTargets();
updateTargetRunConfigurations(t);
......@@ -338,24 +334,17 @@ void CMakeProject::runCMake()
if (activeTarget())
bc = qobject_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
if (!bc)
return;
BuildDirManager *bdm = bc->buildDirManager();
if (bdm && !bdm->isParsing()) {
bdm->checkConfiguration();
bdm->forceReparse();
}
if (bc)
bc->runCMake();
}
QList<CMakeBuildTarget> CMakeProject::buildTargets() const
{
BuildDirManager *bdm = nullptr;
if (activeTarget() && activeTarget()->activeBuildConfiguration())
bdm = static_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration())->buildDirManager();
if (!bdm)
return QList<CMakeBuildTarget>();
return bdm->buildTargets();
CMakeBuildConfiguration *bc = nullptr;
if (activeTarget())
bc = qobject_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
return bc ? bc->buildTargets() : QList<CMakeBuildTarget>();
}
QStringList CMakeProject::buildTargetTitles(bool runnable) const
......
......@@ -117,7 +117,7 @@ void CMakeManager::clearCMakeCache(Project *project)
if (!bc)
return;
bc->buildDirManager()->clearCache();
bc->clearCache();
}
void CMakeManager::runCMake(Project *project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment