forked from qt-creator/qt-creator
CMake: cancel file api parsing
Change-Id: Ie59370fa4329f92dd28bf3e147b2828cbd75330b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Cristian Adam
parent
392bda1160
commit
58d03f3f2f
@@ -870,7 +870,9 @@ static QStringList uniqueTargetFiles(const Configuration &config)
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileApiData FileApiParser::parseData(const QFileInfo &replyFileInfo, const QString &cmakeBuildType,
|
FileApiData FileApiParser::parseData(QFutureInterface<std::shared_ptr<FileApiQtcData>> &fi,
|
||||||
|
const QFileInfo &replyFileInfo,
|
||||||
|
const QString &cmakeBuildType,
|
||||||
QString &errorMessage)
|
QString &errorMessage)
|
||||||
{
|
{
|
||||||
QTC_CHECK(errorMessage.isEmpty());
|
QTC_CHECK(errorMessage.isEmpty());
|
||||||
@@ -878,16 +880,29 @@ FileApiData FileApiParser::parseData(const QFileInfo &replyFileInfo, const QStri
|
|||||||
|
|
||||||
FileApiData result;
|
FileApiData result;
|
||||||
|
|
||||||
|
const auto cancelCheck = [&fi, &errorMessage]() -> bool {
|
||||||
|
if (fi.isCanceled()) {
|
||||||
|
errorMessage = FileApiParser::tr("CMake parsing was cancelled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
result.replyFile = readReplyFile(replyFileInfo, errorMessage);
|
result.replyFile = readReplyFile(replyFileInfo, errorMessage);
|
||||||
|
if (cancelCheck())
|
||||||
|
return {};
|
||||||
result.cache = readCacheFile(result.replyFile.jsonFile("cache", replyDir), errorMessage);
|
result.cache = readCacheFile(result.replyFile.jsonFile("cache", replyDir), errorMessage);
|
||||||
|
if (cancelCheck())
|
||||||
|
return {};
|
||||||
result.cmakeFiles = readCMakeFilesFile(result.replyFile.jsonFile("cmakeFiles", replyDir),
|
result.cmakeFiles = readCMakeFilesFile(result.replyFile.jsonFile("cmakeFiles", replyDir),
|
||||||
errorMessage);
|
errorMessage);
|
||||||
|
if (cancelCheck())
|
||||||
|
return {};
|
||||||
auto codeModels = readCodemodelFile(result.replyFile.jsonFile("codemodel", replyDir),
|
auto codeModels = readCodemodelFile(result.replyFile.jsonFile("codemodel", replyDir),
|
||||||
errorMessage);
|
errorMessage);
|
||||||
|
|
||||||
if (codeModels.size() == 0) {
|
if (codeModels.size() == 0) {
|
||||||
errorMessage = "No CMake configuration found!";
|
errorMessage = "No CMake configuration found!";
|
||||||
qWarning() << errorMessage;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,14 +926,17 @@ FileApiData FileApiParser::parseData(const QFileInfo &replyFileInfo, const QStri
|
|||||||
.arg(cmakeBuildType)
|
.arg(cmakeBuildType)
|
||||||
.arg(buildTypes.join(", "));
|
.arg(buildTypes.join(", "));
|
||||||
}
|
}
|
||||||
qWarning() << errorMessage;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result.codemodel = std::move(*it);
|
result.codemodel = std::move(*it);
|
||||||
|
if (cancelCheck())
|
||||||
|
return {};
|
||||||
|
|
||||||
const QStringList targetFiles = uniqueTargetFiles(result.codemodel);
|
const QStringList targetFiles = uniqueTargetFiles(result.codemodel);
|
||||||
|
|
||||||
for (const QString &targetFile : targetFiles) {
|
for (const QString &targetFile : targetFiles) {
|
||||||
|
if (cancelCheck())
|
||||||
|
return {};
|
||||||
QString targetErrorMessage;
|
QString targetErrorMessage;
|
||||||
TargetDetails td = readTargetFile(replyDir.absoluteFilePath(targetFile), targetErrorMessage);
|
TargetDetails td = readTargetFile(replyDir.absoluteFilePath(targetFile), targetErrorMessage);
|
||||||
if (targetErrorMessage.isEmpty()) {
|
if (targetErrorMessage.isEmpty()) {
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "cmakeconfigitem.h"
|
#include "cmakeconfigitem.h"
|
||||||
|
|
||||||
|
#include "fileapidataextractor.h"
|
||||||
|
|
||||||
#include <projectexplorer/headerpath.h>
|
#include <projectexplorer/headerpath.h>
|
||||||
#include <projectexplorer/projectmacro.h>
|
#include <projectexplorer/projectmacro.h>
|
||||||
|
|
||||||
@@ -34,6 +36,7 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QFutureInterface>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
@@ -247,7 +250,9 @@ class FileApiParser
|
|||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(FileApiParser)
|
Q_DECLARE_TR_FUNCTIONS(FileApiParser)
|
||||||
public:
|
public:
|
||||||
static FileApiData parseData(const QFileInfo &replyFileInfo, const QString& cmakeBuildType,
|
static FileApiData parseData(QFutureInterface<std::shared_ptr<FileApiQtcData>> &fi,
|
||||||
|
const QFileInfo &replyFileInfo,
|
||||||
|
const QString &cmakeBuildType,
|
||||||
QString &errorMessage);
|
QString &errorMessage);
|
||||||
|
|
||||||
static bool setupCMakeFileApi(const Utils::FilePath &buildDirectory,
|
static bool setupCMakeFileApi(const Utils::FilePath &buildDirectory,
|
||||||
|
@@ -265,11 +265,14 @@ void FileApiReader::endState(const QFileInfo &replyFi)
|
|||||||
m_lastReplyTimestamp = replyFi.lastModified();
|
m_lastReplyTimestamp = replyFi.lastModified();
|
||||||
|
|
||||||
m_future = runAsync(ProjectExplorerPlugin::sharedThreadPool(),
|
m_future = runAsync(ProjectExplorerPlugin::sharedThreadPool(),
|
||||||
[replyFi, sourceDirectory, buildDirectory, topCmakeFile, cmakeBuildType]() {
|
[replyFi, sourceDirectory, buildDirectory, topCmakeFile, cmakeBuildType](
|
||||||
|
QFutureInterface<std::shared_ptr<FileApiQtcData>> &fi) {
|
||||||
auto result = std::make_shared<FileApiQtcData>();
|
auto result = std::make_shared<FileApiQtcData>();
|
||||||
FileApiData data = FileApiParser::parseData(replyFi, cmakeBuildType, result->errorMessage);
|
FileApiData data = FileApiParser::parseData(fi,
|
||||||
|
replyFi,
|
||||||
|
cmakeBuildType,
|
||||||
|
result->errorMessage);
|
||||||
if (!result->errorMessage.isEmpty()) {
|
if (!result->errorMessage.isEmpty()) {
|
||||||
qWarning() << result->errorMessage;
|
|
||||||
*result = generateFallbackData(topCmakeFile,
|
*result = generateFallbackData(topCmakeFile,
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
buildDirectory,
|
buildDirectory,
|
||||||
@@ -281,7 +284,7 @@ void FileApiReader::endState(const QFileInfo &replyFi)
|
|||||||
qWarning() << result->errorMessage;
|
qWarning() << result->errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
fi.reportResult(result);
|
||||||
});
|
});
|
||||||
onResultReady(m_future.value(),
|
onResultReady(m_future.value(),
|
||||||
this,
|
this,
|
||||||
|
Reference in New Issue
Block a user