forked from qt-creator/qt-creator
CMakePM: Do not treat generated files as project files
This would trigger an infinite loop. Fixes: QTCREATORBUG-26207 Fixes: QTCREATORBUG-26204 Fixes: QTCREATORBUG-25346 Fixes: QTCREATORBUG-25995 Fixes: QTCREATORBUG-25183 Fixes: QTCREATORBUG-25512 Change-Id: Iaf081a00dcf318a0ec2708e839e0ab6535e0ef4d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -53,7 +53,7 @@ using namespace CMakeProjectManager::Internal::FileApiDetails;
|
|||||||
class CMakeFileResult
|
class CMakeFileResult
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QSet<FilePath> cmakeFiles;
|
QSet<CMakeFileInfo> cmakeFiles;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeNodesSource;
|
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeNodesSource;
|
||||||
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeNodesBuild;
|
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeNodesBuild;
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeListNodes;
|
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeListNodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
CMakeFileResult extractCMakeFilesData(const std::vector<FileApiDetails::CMakeFileInfo> &cmakefiles,
|
CMakeFileResult extractCMakeFilesData(const std::vector<CMakeFileInfo> &cmakefiles,
|
||||||
const FilePath &sourceDirectory,
|
const FilePath &sourceDirectory,
|
||||||
const FilePath &buildDirectory)
|
const FilePath &buildDirectory)
|
||||||
{
|
{
|
||||||
@@ -72,9 +72,11 @@ CMakeFileResult extractCMakeFilesData(const std::vector<FileApiDetails::CMakeFil
|
|||||||
|
|
||||||
for (const CMakeFileInfo &info : cmakefiles) {
|
for (const CMakeFileInfo &info : cmakefiles) {
|
||||||
const FilePath sfn = FilePath::fromString(
|
const FilePath sfn = FilePath::fromString(
|
||||||
QDir::cleanPath(sourceDir.absoluteFilePath(info.path)));
|
QDir::cleanPath(sourceDir.absoluteFilePath(info.path.toString())));
|
||||||
const int oldCount = result.cmakeFiles.count();
|
const int oldCount = result.cmakeFiles.count();
|
||||||
result.cmakeFiles.insert(sfn);
|
CMakeFileInfo absolute(info);
|
||||||
|
absolute.path = sfn;
|
||||||
|
result.cmakeFiles.insert(absolute);
|
||||||
if (oldCount < result.cmakeFiles.count()) {
|
if (oldCount < result.cmakeFiles.count()) {
|
||||||
if (info.isCMake && !info.isCMakeListsDotTxt) {
|
if (info.isCMake && !info.isCMakeListsDotTxt) {
|
||||||
// Skip files that cmake considers to be part of the installation -- but include
|
// Skip files that cmake considers to be part of the installation -- but include
|
||||||
@@ -109,7 +111,7 @@ class PreprocessedData
|
|||||||
public:
|
public:
|
||||||
CMakeProjectManager::CMakeConfig cache;
|
CMakeProjectManager::CMakeConfig cache;
|
||||||
|
|
||||||
QSet<FilePath> cmakeFiles;
|
QSet<CMakeFileInfo> cmakeFiles;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeNodesSource;
|
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeNodesSource;
|
||||||
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeNodesBuild;
|
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> cmakeNodesBuild;
|
||||||
|
|||||||
@@ -44,12 +44,26 @@ namespace Internal {
|
|||||||
|
|
||||||
class FileApiData;
|
class FileApiData;
|
||||||
|
|
||||||
|
class CMakeFileInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool operator==(const CMakeFileInfo& other) const { return path == other.path; }
|
||||||
|
|
||||||
|
Utils::FilePath path;
|
||||||
|
bool isCMake = false;
|
||||||
|
bool isCMakeListsDotTxt = false;
|
||||||
|
bool isExternal = false;
|
||||||
|
bool isGenerated = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline uint qHash(const CMakeFileInfo &info, uint seed = 0) { return info.path.hash(seed); }
|
||||||
|
|
||||||
class FileApiQtcData
|
class FileApiQtcData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
CMakeConfig cache;
|
CMakeConfig cache;
|
||||||
QSet<Utils::FilePath> cmakeFiles;
|
QSet<CMakeFileInfo> cmakeFiles;
|
||||||
QList<CMakeBuildTarget> buildTargets;
|
QList<CMakeBuildTarget> buildTargets;
|
||||||
ProjectExplorer::RawProjectParts projectParts;
|
ProjectExplorer::RawProjectParts projectParts;
|
||||||
std::unique_ptr<CMakeProjectNode> rootProjectNode;
|
std::unique_ptr<CMakeProjectNode> rootProjectNode;
|
||||||
|
|||||||
@@ -249,10 +249,10 @@ static std::vector<CMakeFileInfo> readCMakeFilesFile(const FilePath &cmakeFilesF
|
|||||||
for (const QJsonValue &v : inputs) {
|
for (const QJsonValue &v : inputs) {
|
||||||
CMakeFileInfo info;
|
CMakeFileInfo info;
|
||||||
const QJsonObject input = v.toObject();
|
const QJsonObject input = v.toObject();
|
||||||
info.path = input.value("path").toString();
|
info.path = FilePath::fromString(input.value("path").toString());
|
||||||
|
|
||||||
info.isCMake = input.value("isCMake").toBool();
|
info.isCMake = input.value("isCMake").toBool();
|
||||||
const QString filename = FilePath::fromString(info.path).fileName();
|
const QString filename = info.path.fileName();
|
||||||
info.isCMakeListsDotTxt = (filename.compare("CMakeLists.txt",
|
info.isCMakeListsDotTxt = (filename.compare("CMakeLists.txt",
|
||||||
HostOsInfo::fileNameCaseSensitivity())
|
HostOsInfo::fileNameCaseSensitivity())
|
||||||
== 0);
|
== 0);
|
||||||
|
|||||||
@@ -71,16 +71,6 @@ public:
|
|||||||
Utils::FilePath jsonFile(const QString &kind, const Utils::FilePath &replyDir) const;
|
Utils::FilePath jsonFile(const QString &kind, const Utils::FilePath &replyDir) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMakeFileInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QString path;
|
|
||||||
bool isCMake = false;
|
|
||||||
bool isCMakeListsDotTxt = false;
|
|
||||||
bool isExternal = false;
|
|
||||||
bool isGenerated = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Directory
|
class Directory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -243,7 +233,7 @@ class FileApiData
|
|||||||
public:
|
public:
|
||||||
FileApiDetails::ReplyFileContents replyFile;
|
FileApiDetails::ReplyFileContents replyFile;
|
||||||
CMakeConfig cache;
|
CMakeConfig cache;
|
||||||
std::vector<FileApiDetails::CMakeFileInfo> cmakeFiles;
|
std::vector<CMakeFileInfo> cmakeFiles;
|
||||||
FileApiDetails::Configuration codemodel;
|
FileApiDetails::Configuration codemodel;
|
||||||
std::vector<FileApiDetails::TargetDetails> targetDetails;
|
std::vector<FileApiDetails::TargetDetails> targetDetails;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -88,8 +88,12 @@ void FileApiReader::setParameters(const BuildDirParameters &p)
|
|||||||
void FileApiReader::resetData()
|
void FileApiReader::resetData()
|
||||||
{
|
{
|
||||||
m_cmakeFiles.clear();
|
m_cmakeFiles.clear();
|
||||||
if (!m_parameters.sourceDirectory.isEmpty())
|
if (!m_parameters.sourceDirectory.isEmpty()) {
|
||||||
m_cmakeFiles.insert(m_parameters.sourceDirectory.pathAppended("CMakeLists.txt"));
|
CMakeFileInfo cmakeListsTxt;
|
||||||
|
cmakeListsTxt.path = m_parameters.sourceDirectory.pathAppended("CMakeLists.txt");
|
||||||
|
cmakeListsTxt.isCMakeListsDotTxt = true;
|
||||||
|
m_cmakeFiles.insert(cmakeListsTxt);
|
||||||
|
}
|
||||||
|
|
||||||
m_cache.clear();
|
m_cache.clear();
|
||||||
m_buildTargets.clear();
|
m_buildTargets.clear();
|
||||||
@@ -124,8 +128,9 @@ void FileApiReader::parse(bool forceCMakeRun,
|
|||||||
const bool hasArguments = !args.isEmpty();
|
const bool hasArguments = !args.isEmpty();
|
||||||
const bool replyFileMissing = !replyFile.exists();
|
const bool replyFileMissing = !replyFile.exists();
|
||||||
const bool cmakeFilesChanged = m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun()
|
const bool cmakeFilesChanged = m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun()
|
||||||
&& anyOf(m_cmakeFiles, [&replyFile](const FilePath &f) {
|
&& anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) {
|
||||||
return f.lastModified() > replyFile.lastModified();
|
return !info.isGenerated
|
||||||
|
&& info.path.lastModified() > replyFile.lastModified();
|
||||||
});
|
});
|
||||||
const bool queryFileChanged = anyOf(FileApiParser::cmakeQueryFilePaths(m_parameters.buildDirectory),
|
const bool queryFileChanged = anyOf(FileApiParser::cmakeQueryFilePaths(m_parameters.buildDirectory),
|
||||||
[&replyFile](const FilePath &qf) {
|
[&replyFile](const FilePath &qf) {
|
||||||
@@ -175,7 +180,10 @@ bool FileApiReader::isParsing() const
|
|||||||
|
|
||||||
QSet<FilePath> FileApiReader::projectFilesToWatch() const
|
QSet<FilePath> FileApiReader::projectFilesToWatch() const
|
||||||
{
|
{
|
||||||
return m_cmakeFiles;
|
return Utils::transform(
|
||||||
|
Utils::filtered(m_cmakeFiles,
|
||||||
|
[](const CMakeFileInfo &info) { return !info.isGenerated; }),
|
||||||
|
[](const CMakeFileInfo &info) { return info.path;});
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CMakeBuildTarget> FileApiReader::takeBuildTargets(QString &errorMessage){
|
QList<CMakeBuildTarget> FileApiReader::takeBuildTargets(QString &errorMessage){
|
||||||
@@ -249,7 +257,7 @@ void FileApiReader::endState(const FilePath &replyFilePath)
|
|||||||
|
|
||||||
const FilePath sourceDirectory = m_parameters.sourceDirectory;
|
const FilePath sourceDirectory = m_parameters.sourceDirectory;
|
||||||
const FilePath buildDirectory = m_parameters.buildDirectory;
|
const FilePath buildDirectory = m_parameters.buildDirectory;
|
||||||
const FilePath topCmakeFile = m_cmakeFiles.size() == 1 ? *m_cmakeFiles.begin() : FilePath{};
|
const FilePath topCmakeFile = m_cmakeFiles.size() == 1 ? (*m_cmakeFiles.begin()).path : FilePath{};
|
||||||
const QString cmakeBuildType = m_parameters.cmakeBuildType == "Build" ? "" : m_parameters.cmakeBuildType;
|
const QString cmakeBuildType = m_parameters.cmakeBuildType == "Build" ? "" : m_parameters.cmakeBuildType;
|
||||||
|
|
||||||
QTC_CHECK(!replyFilePath.needsDevice());
|
QTC_CHECK(!replyFilePath.needsDevice());
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "cmakebuildtarget.h"
|
#include "cmakebuildtarget.h"
|
||||||
#include "cmakeprocess.h"
|
#include "cmakeprocess.h"
|
||||||
#include "cmakeprojectnodes.h"
|
#include "cmakeprojectnodes.h"
|
||||||
|
#include "fileapidataextractor.h"
|
||||||
|
|
||||||
#include <projectexplorer/rawprojectpart.h>
|
#include <projectexplorer/rawprojectpart.h>
|
||||||
#include <projectexplorer/treescanner.h>
|
#include <projectexplorer/treescanner.h>
|
||||||
@@ -100,7 +101,7 @@ private:
|
|||||||
|
|
||||||
// cmake data:
|
// cmake data:
|
||||||
CMakeConfig m_cache;
|
CMakeConfig m_cache;
|
||||||
QSet<Utils::FilePath> m_cmakeFiles;
|
QSet<CMakeFileInfo> m_cmakeFiles;
|
||||||
QList<CMakeBuildTarget> m_buildTargets;
|
QList<CMakeBuildTarget> m_buildTargets;
|
||||||
ProjectExplorer::RawProjectParts m_projectParts;
|
ProjectExplorer::RawProjectParts m_projectParts;
|
||||||
std::unique_ptr<CMakeProjectNode> m_rootProjectNode;
|
std::unique_ptr<CMakeProjectNode> m_rootProjectNode;
|
||||||
|
|||||||
Reference in New Issue
Block a user