forked from qt-creator/qt-creator
ProjectExplorer: Add BuildSystem class
Add a class to abstract out the BuildSystem from the Project. Thie idea is to make a Project have-a BuildSystem, so that it can stop being one. The Projects in the different ProjectManagers will get much simpler that way (and many will only consist of a constructor with some setter calls) and handles all the interactions between the rest of Qt Creator and the project. The complex code to interact with the build systems is then separate from that. Change-Id: I3bbb000bb1aed91f0b547ac493f743ede8afb8cd Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include <QDir>
|
||||
#include <QLoggingCategory>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QPushButton>
|
||||
#include <QSet>
|
||||
|
||||
@@ -95,6 +96,18 @@ Utils::FilePath BuildDirManager::workDirectory(const BuildDirParameters ¶met
|
||||
return Utils::FilePath::fromString(tmpDirIt->second->path());
|
||||
}
|
||||
|
||||
void BuildDirManager::updateReparseParameters(const int parameters)
|
||||
{
|
||||
m_reparseParameters |= parameters;
|
||||
}
|
||||
|
||||
int BuildDirManager::takeReparseParameters()
|
||||
{
|
||||
int result = m_reparseParameters;
|
||||
m_reparseParameters = REPARSE_DEFAULT;
|
||||
return result;
|
||||
}
|
||||
|
||||
void BuildDirManager::emitDataAvailable()
|
||||
{
|
||||
if (!isParsing())
|
||||
@@ -108,6 +121,14 @@ void BuildDirManager::emitErrorOccured(const QString &message) const
|
||||
m_isHandlingError = false;
|
||||
}
|
||||
|
||||
void BuildDirManager::emitReparseRequest() const
|
||||
{
|
||||
if (m_reparseParameters & REPARSE_URGENT)
|
||||
emit requestReparse();
|
||||
else
|
||||
emit requestDelayedReparse();
|
||||
}
|
||||
|
||||
void BuildDirManager::updateReaderType(const BuildDirParameters &p,
|
||||
std::function<void()> todo)
|
||||
{
|
||||
@@ -208,7 +229,7 @@ void BuildDirManager::stopParsingAndClearState()
|
||||
}
|
||||
|
||||
void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters ¶meters,
|
||||
int reparseOptions)
|
||||
const int reparseParameters)
|
||||
{
|
||||
if (!parameters.cmakeTool()) {
|
||||
TaskHub::addTask(Task::Error,
|
||||
@@ -222,9 +243,9 @@ void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters &par
|
||||
|
||||
m_parameters = parameters;
|
||||
m_parameters.workDirectory = workDirectory(parameters);
|
||||
updateReparseParameters(reparseParameters);
|
||||
|
||||
updateReaderType(m_parameters,
|
||||
[this, reparseOptions]() { emit requestReparse(reparseOptions); });
|
||||
updateReaderType(m_parameters, [this]() { emitReparseRequest(); });
|
||||
}
|
||||
|
||||
CMakeBuildConfiguration *BuildDirManager::buildConfiguration() const
|
||||
@@ -248,7 +269,8 @@ void BuildDirManager::becameDirty()
|
||||
if (!tool->isAutoRun())
|
||||
return;
|
||||
|
||||
emit requestReparse(REPARSE_CHECK_CONFIGURATION | REPARSE_SCAN);
|
||||
updateReparseParameters(REPARSE_CHECK_CONFIGURATION | REPARSE_SCAN);
|
||||
emit requestReparse();
|
||||
}
|
||||
|
||||
void BuildDirManager::resetData()
|
||||
@@ -276,19 +298,30 @@ bool BuildDirManager::persistCMakeState()
|
||||
return true;
|
||||
}
|
||||
|
||||
void BuildDirManager::parse(int reparseParameters)
|
||||
void BuildDirManager::requestFilesystemScan()
|
||||
{
|
||||
qCDebug(cmakeBuildDirManagerLog)
|
||||
<< "Parse called with flags:" << flagsString(reparseParameters);
|
||||
updateReparseParameters(REPARSE_SCAN);
|
||||
}
|
||||
|
||||
bool BuildDirManager::isFilesystemScanRequested() const
|
||||
{
|
||||
return m_reparseParameters & REPARSE_SCAN;
|
||||
}
|
||||
|
||||
void BuildDirManager::parse()
|
||||
{
|
||||
QTC_ASSERT(m_parameters.isValid(), return );
|
||||
QTC_ASSERT(m_reader, return);
|
||||
QTC_ASSERT((reparseParameters & REPARSE_IGNORE) == 0, return);
|
||||
|
||||
m_reader->stop();
|
||||
|
||||
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
||||
|
||||
int reparseParameters = takeReparseParameters();
|
||||
|
||||
qCDebug(cmakeBuildDirManagerLog)
|
||||
<< "Parse called with flags:" << flagsString(reparseParameters);
|
||||
|
||||
const QString cache = m_parameters.workDirectory.pathAppended("CMakeCache.txt").toString();
|
||||
if (!QFileInfo::exists(cache)) {
|
||||
reparseParameters |= REPARSE_FORCE_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN;
|
||||
@@ -323,8 +356,10 @@ QVector<FilePath> BuildDirManager::takeProjectFilesToWatch()
|
||||
|
||||
if (!toWatch.isEmpty()) {
|
||||
connect(project(), &Project::projectFileIsDirty, this, [this]() {
|
||||
if (m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun())
|
||||
requestReparse(REPARSE_DEFAULT);
|
||||
if (m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun()) {
|
||||
updateReparseParameters(REPARSE_DEFAULT);
|
||||
emit requestReparse();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
disconnect(project(), nullptr, this, nullptr);
|
||||
@@ -452,8 +487,6 @@ QString BuildDirManager::flagsString(int reparseFlags)
|
||||
result += " CHECK_CONFIG";
|
||||
if (reparseFlags & REPARSE_SCAN)
|
||||
result += " SCAN";
|
||||
if (reparseFlags & REPARSE_IGNORE)
|
||||
result += " IGNORE";
|
||||
}
|
||||
return result.trimmed();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user