forked from qt-creator/qt-creator
CMake: Update code to decide whether to run cmake in fileapi mode
Change-Id: Iea841bb49876a580abc80cc7ea21a88b153cc224 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -858,7 +858,7 @@ void FileApiParser::setupCMakeFileApi() const
|
||||
QTC_ASSERT(queryDir.exists(), );
|
||||
|
||||
bool failedBefore = false;
|
||||
for (const QString &fileName : QStringList({"cache-v2", "codemodel-v2", "cmakeFiles-v1"})) {
|
||||
for (const QString &fileName : cmakeQueryFileNames()) {
|
||||
const QString filePath = queryDir.filePath(fileName);
|
||||
|
||||
QFile f(filePath);
|
||||
@@ -933,6 +933,19 @@ QFileInfo FileApiParser::scanForCMakeReplyFile() const
|
||||
return fis.isEmpty() ? QFileInfo() : fis.last();
|
||||
}
|
||||
|
||||
QStringList FileApiParser::cmakeQueryFileNames() const
|
||||
{
|
||||
return {"cache-v2", "codemodel-v2", "cmakeFiles-v1"};
|
||||
}
|
||||
|
||||
QStringList FileApiParser::cmakeQueryFilePaths() const
|
||||
{
|
||||
QDir queryDir(QDir::cleanPath(m_sourceDirectory.toString() + "/"
|
||||
+ QString::fromLatin1(CMAKE_RELATIVE_QUERY_PATH)));
|
||||
return transform(cmakeQueryFileNames(),
|
||||
[&queryDir](const QString &name) { return queryDir.absoluteFilePath(name); });
|
||||
}
|
||||
|
||||
void FileApiParser::replyDirectoryHasChanged(const QString &directory) const
|
||||
{
|
||||
if (directory == cmakeReplyDirectory().toString()) {
|
||||
|
||||
@@ -248,6 +248,9 @@ public:
|
||||
Utils::FilePath cmakeReplyDirectory() const;
|
||||
QFileInfo scanForCMakeReplyFile() const;
|
||||
|
||||
QStringList cmakeQueryFileNames() const;
|
||||
QStringList cmakeQueryFilePaths() const;
|
||||
|
||||
static FileApiData parseData(const QFileInfo &replyFileInfo, QString &errorMessage);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -69,8 +69,7 @@ FileApiReader::FileApiReader()
|
||||
&Core::EditorManager::aboutToSave,
|
||||
this,
|
||||
[this](const Core::IDocument *document) {
|
||||
if (m_cmakeFiles.contains(document->filePath()) || !m_parameters.cmakeTool()
|
||||
|| !m_parameters.cmakeTool()->isAutoRun()) {
|
||||
if (m_cmakeFiles.contains(document->filePath())) {
|
||||
qCDebug(cmakeFileApiMode) << "FileApiReader: DIRTY SIGNAL";
|
||||
emit dirty();
|
||||
}
|
||||
@@ -139,9 +138,21 @@ void FileApiReader::parse(bool forceCMakeRun, bool forceConfiguration)
|
||||
}
|
||||
|
||||
const QFileInfo replyFi = m_fileApi->scanForCMakeReplyFile();
|
||||
const bool mustUpdate = forceCMakeRun || !replyFi.exists() || m_cmakeFiles.isEmpty()
|
||||
|| anyOf(m_cmakeFiles, [&replyFi](const FilePath &f) {
|
||||
return f.toFileInfo().lastModified() > replyFi.lastModified();
|
||||
// Only need to update when one of the following conditions is met:
|
||||
// * The user forces the update,
|
||||
// * There is no reply file,
|
||||
// * One of the cmakefiles is newer than the replyFile and the user asked
|
||||
// for creator to run CMake as needed,
|
||||
// * A query files are newer than the reply file
|
||||
const bool mustUpdate = forceCMakeRun || !replyFi.exists()
|
||||
|| (m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun()
|
||||
&& anyOf(m_cmakeFiles,
|
||||
[&replyFi](const FilePath &f) {
|
||||
return f.toFileInfo().lastModified()
|
||||
> replyFi.lastModified();
|
||||
}))
|
||||
|| anyOf(m_fileApi->cmakeQueryFilePaths(), [&replyFi](const QString &qf) {
|
||||
return QFileInfo(qf).lastModified() > replyFi.lastModified();
|
||||
});
|
||||
|
||||
if (mustUpdate) {
|
||||
|
||||
Reference in New Issue
Block a user