Commit 75538aa0 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

CMake: Speed up extra compiler processing a bit



Makes extra compiler selection 30% faster on my test project.

Change-Id: If78084ce4a5a93140598dd19e8448295ca122863
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent d0ee8376
......@@ -531,24 +531,35 @@ void CMakeProject::createGeneratedCodeModelSupport()
{
qDeleteAll(m_extraCompilers);
m_extraCompilers.clear();
QList<ExtraCompilerFactory *> factories =
const QList<ExtraCompilerFactory *> factories =
ExtraCompilerFactory::extraCompilerFactories();
const QSet<QString> fileExtensions
= Utils::transform<QSet>(factories, [](const ExtraCompilerFactory *f) { return f->sourceTag(); });
// Find all files generated by any of the extra compilers, in a rather crude way.
foreach (const QString &file, files(SourceFiles)) {
foreach (ExtraCompilerFactory *factory, factories) {
if (file.endsWith('.' + factory->sourceTag())) {
QStringList generated = filesGeneratedFrom(file);
if (!generated.isEmpty()) {
const FileNameList fileNames = transform(generated,
[](const QString &s) {
return FileName::fromString(s);
});
m_extraCompilers.append(factory->create(this, FileName::fromString(file),
fileNames));
}
}
}
const QStringList fileList = files(SourceFiles, [&fileExtensions](const FileNode *fn) {
const QString fp = fn->filePath().toString();
const int pos = fp.lastIndexOf('.');
return pos >= 0 && fileExtensions.contains(fp.mid(pos + 1));
});
// Generate the necessary information:
for (const QString &file : fileList) {
ExtraCompilerFactory *factory = Utils::findOrDefault(factories, [&file](const ExtraCompilerFactory *f) {
return file.endsWith('.' + f->sourceTag());
});
QTC_ASSERT(factory, continue);
QStringList generated = filesGeneratedFrom(file);
if (generated.isEmpty())
continue;
const FileNameList fileNames
= transform(generated,
[](const QString &s) { return FileName::fromString(s); });
m_extraCompilers.append(factory->create(this, FileName::fromString(file),
fileNames));
}
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment