forked from qt-creator/qt-creator
CMake: Reduce number of FilePath conversions in fileapidataextractor.cpp
Change-Id: If143843782b0bfdbdd68ab1a387d0feabfb60a33 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -420,21 +420,13 @@ static RawProjectParts generateRawProjectParts(const QFuture<void> &cancelFuture
|
|||||||
QStringList fragments = splitFragments(ci.fragments);
|
QStringList fragments = splitFragments(ci.fragments);
|
||||||
|
|
||||||
// Get all sources from the compiler group, except generated sources
|
// Get all sources from the compiler group, except generated sources
|
||||||
QStringList sources;
|
FilePaths sources;
|
||||||
auto addToSources = [sourceDirectory, &sources](const QString &source) {
|
|
||||||
const FilePath sourcePath = FilePath::fromString(source);
|
|
||||||
if (sourcePath.isAbsolutePath())
|
|
||||||
sources.push_back(source);
|
|
||||||
else
|
|
||||||
sources.push_back(
|
|
||||||
sourceDirectory.pathAppended(source).absoluteFilePath().path());
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto idx: ci.sources) {
|
for (auto idx: ci.sources) {
|
||||||
SourceInfo si = t.sources.at(idx);
|
SourceInfo si = t.sources.at(idx);
|
||||||
if (si.isGenerated)
|
if (si.isGenerated)
|
||||||
continue;
|
continue;
|
||||||
addToSources(si.path);
|
sources.append(sourceDirectory.resolvePath(si.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip groups with only generated source files e.g. <build-dir>/.rcc/qrc_<target>.cpp
|
// Skip groups with only generated source files e.g. <build-dir>/.rcc/qrc_<target>.cpp
|
||||||
@@ -442,12 +434,12 @@ static RawProjectParts generateRawProjectParts(const QFuture<void> &cancelFuture
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If we are not in a pch compiler group, add all the headers that are not generated
|
// If we are not in a pch compiler group, add all the headers that are not generated
|
||||||
const bool hasPchSource = anyOf(sources, [buildDirectory](const QString &path) {
|
const bool hasPchSource = anyOf(sources, [buildDirectory](const FilePath &path) {
|
||||||
return isPchFile(buildDirectory, FilePath::fromString(path));
|
return isPchFile(buildDirectory, path);
|
||||||
});
|
});
|
||||||
|
|
||||||
const bool hasUnitySources = allOf(sources, [buildDirectory](const QString &path) {
|
const bool hasUnitySources = allOf(sources, [buildDirectory](const FilePath &path) {
|
||||||
return isUnityFile(buildDirectory, FilePath::fromString(path));
|
return isUnityFile(buildDirectory, path);
|
||||||
});
|
});
|
||||||
|
|
||||||
QString headerMimeType;
|
QString headerMimeType;
|
||||||
@@ -469,19 +461,20 @@ static RawProjectParts generateRawProjectParts(const QFuture<void> &cancelFuture
|
|||||||
const bool sourceUnityType = hasUnitySources ? mime.inherits(sourceMimeType)
|
const bool sourceUnityType = hasUnitySources ? mime.inherits(sourceMimeType)
|
||||||
: false;
|
: false;
|
||||||
if (headerType || sourceUnityType)
|
if (headerType || sourceUnityType)
|
||||||
addToSources(si.path);
|
sources.append(sourceDirectory.resolvePath(si.path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sources.removeDuplicates();
|
FilePath::removeDuplicates(sources);
|
||||||
|
|
||||||
// Set project files except pch / unity files
|
// Set project files except pch / unity files
|
||||||
rpp.setFiles(Utils::filtered(sources,
|
const FilePaths filtered = Utils::filtered(sources,
|
||||||
[buildDirectory](const QString &path) {
|
[buildDirectory](const FilePath &filePath) {
|
||||||
const FilePath filePath = FilePath::fromString(path);
|
|
||||||
return !isPchFile(buildDirectory, filePath)
|
return !isPchFile(buildDirectory, filePath)
|
||||||
&& !isUnityFile(buildDirectory, filePath);
|
&& !isUnityFile(buildDirectory, filePath);
|
||||||
}),
|
});
|
||||||
|
|
||||||
|
rpp.setFiles(Utils::transform(filtered, &FilePath::toFSPathString),
|
||||||
{},
|
{},
|
||||||
[headerMimeType](const QString &path) {
|
[headerMimeType](const QString &path) {
|
||||||
// Similar to ProjectFile::classify but classify headers with language
|
// Similar to ProjectFile::classify but classify headers with language
|
||||||
|
|||||||
Reference in New Issue
Block a user