forked from qt-creator/qt-creator
CMake: Trigger cmake run *before* build when files changed
Make sure to run cmake *before* cmake --build when cmake files just got saved. This helps e.g. when editing CMakeLists.txt files and the hitting "Built" and "Save all" (or "Always save before build"). Task-number: QTCREATORBUG-16187 Change-Id: I16b1d02eb342a447003380946ce7a9d785476a0e Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/project.h>
|
||||
@@ -106,8 +107,10 @@ BuildDirManager::BuildDirManager(CMakeBuildConfiguration *bc) :
|
||||
m_projectName = sourceDirectory().fileName();
|
||||
|
||||
m_reparseTimer.setSingleShot(true);
|
||||
m_reparseTimer.setInterval(2000);
|
||||
|
||||
connect(&m_reparseTimer, &QTimer::timeout, this, &BuildDirManager::parse);
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::aboutToSave,
|
||||
this, &BuildDirManager::handleDocumentSaves);
|
||||
}
|
||||
|
||||
BuildDirManager::~BuildDirManager()
|
||||
@@ -164,7 +167,7 @@ void BuildDirManager::cmakeFilesChanged()
|
||||
if (!tool->isAutoRun())
|
||||
return;
|
||||
|
||||
m_reparseTimer.start();
|
||||
m_reparseTimer.start(1000);
|
||||
}
|
||||
|
||||
void BuildDirManager::forceReparse()
|
||||
@@ -191,6 +194,11 @@ void BuildDirManager::resetData()
|
||||
m_files.clear();
|
||||
}
|
||||
|
||||
bool BuildDirManager::updateCMakeStateBeforeBuild()
|
||||
{
|
||||
return m_reparseTimer.isActive();
|
||||
}
|
||||
|
||||
bool BuildDirManager::persistCMakeState()
|
||||
{
|
||||
if (!m_tempDir)
|
||||
@@ -592,6 +600,14 @@ void BuildDirManager::checkConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
void BuildDirManager::handleDocumentSaves(Core::IDocument *document)
|
||||
{
|
||||
if (!m_cmakeFiles.contains(document->filePath()))
|
||||
return;
|
||||
|
||||
m_reparseTimer.start(100);
|
||||
}
|
||||
|
||||
static QByteArray trimCMakeCacheLine(const QByteArray &in) {
|
||||
int start = 0;
|
||||
while (start < in.count() && (in.at(start) == ' ' || in.at(start) == '\t'))
|
||||
|
||||
Reference in New Issue
Block a user