CMakePM: Scan files only on CMake configuration failure

The file tree scanner will only be started on CMake configuration
failure to generate the <File System> fall back project node.

Change-Id: I873ef1189fd43dc9bffa03aeafabb00bb3b8b6af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2021-09-27 17:26:40 +02:00
parent b8609be931
commit 0665a9151c
6 changed files with 83 additions and 123 deletions

View File

@@ -27,7 +27,6 @@
#include "fileapidataextractor.h"
#include "fileapiparser.h"
#include "projecttreehelper.h"
#include <coreplugin/messagemanager.h>
@@ -214,15 +213,6 @@ bool FileApiReader::usesAllCapsTargets() const
return m_usesAllCapsTargets;
}
std::unique_ptr<CMakeProjectNode> FileApiReader::generateProjectTree(
const ProjectExplorer::TreeScanner::Result &allFiles, bool failedToParse)
{
if (failedToParse)
addFileSystemNodes(m_rootProjectNode.get(), allFiles.folderNode);
return std::exchange(m_rootProjectNode, {});
}
RawProjectParts FileApiReader::createRawProjectParts(QString &errorMessage)
{
Q_UNUSED(errorMessage)
@@ -250,37 +240,29 @@ void FileApiReader::endState(const FilePath &replyFilePath, bool restoredFromBac
const FilePath sourceDirectory = m_parameters.sourceDirectory;
const FilePath buildDirectory = m_parameters.buildDirectory;
const FilePath topCmakeFile = m_cmakeFiles.size() == 1 ? (*m_cmakeFiles.begin()).path : FilePath{};
const QString cmakeBuildType = m_parameters.cmakeBuildType == "Build" ? "" : m_parameters.cmakeBuildType;
QTC_CHECK(!replyFilePath.needsDevice());
m_lastReplyTimestamp = replyFilePath.lastModified();
m_future = runAsync(ProjectExplorerPlugin::sharedThreadPool(),
[replyFilePath, sourceDirectory, buildDirectory, topCmakeFile, cmakeBuildType](
[replyFilePath, sourceDirectory, buildDirectory, cmakeBuildType](
QFutureInterface<std::shared_ptr<FileApiQtcData>> &fi) {
auto result = std::make_shared<FileApiQtcData>();
FileApiData data = FileApiParser::parseData(fi,
replyFilePath,
cmakeBuildType,
result->errorMessage);
if (!result->errorMessage.isEmpty()) {
*result = generateFallbackData(topCmakeFile,
sourceDirectory,
buildDirectory,
result->errorMessage);
} else {
if (result->errorMessage.isEmpty())
*result = extractData(data, sourceDirectory, buildDirectory);
}
if (!result->errorMessage.isEmpty()) {
else
qWarning() << result->errorMessage;
}
fi.reportResult(result);
});
onResultReady(m_future.value(),
this,
[this, topCmakeFile, sourceDirectory, buildDirectory, restoredFromBackup](
[this, sourceDirectory, buildDirectory, restoredFromBackup](
const std::shared_ptr<FileApiQtcData> &value) {
m_isParsing = false;
m_cache = std::move(value->cache);
@@ -348,6 +330,16 @@ void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &conf
QTC_CHECK(settingsFile.writeFileContents(contents));
}
std::unique_ptr<CMakeProjectNode> FileApiReader::rootProjectNode()
{
return std::exchange(m_rootProjectNode, {});
}
FilePath FileApiReader::topCmakeFile() const
{
return m_cmakeFiles.size() == 1 ? (*m_cmakeFiles.begin()).path : FilePath{};
}
int FileApiReader::lastCMakeExitCode() const
{
return m_lastCMakeExitCode;