forked from qt-creator/qt-creator
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 <tim.jenssen@qt.io>
This commit is contained in:
@@ -531,25 +531,36 @@ void CMakeProject::createGeneratedCodeModelSupport()
|
|||||||
{
|
{
|
||||||
qDeleteAll(m_extraCompilers);
|
qDeleteAll(m_extraCompilers);
|
||||||
m_extraCompilers.clear();
|
m_extraCompilers.clear();
|
||||||
QList<ExtraCompilerFactory *> factories =
|
const QList<ExtraCompilerFactory *> factories =
|
||||||
ExtraCompilerFactory::extraCompilerFactories();
|
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.
|
// Find all files generated by any of the extra compilers, in a rather crude way.
|
||||||
foreach (const QString &file, files(SourceFiles)) {
|
const QStringList fileList = files(SourceFiles, [&fileExtensions](const FileNode *fn) {
|
||||||
foreach (ExtraCompilerFactory *factory, factories) {
|
const QString fp = fn->filePath().toString();
|
||||||
if (file.endsWith('.' + factory->sourceTag())) {
|
const int pos = fp.lastIndexOf('.');
|
||||||
QStringList generated = filesGeneratedFrom(file);
|
return pos >= 0 && fileExtensions.contains(fp.mid(pos + 1));
|
||||||
if (!generated.isEmpty()) {
|
|
||||||
const FileNameList fileNames = transform(generated,
|
|
||||||
[](const QString &s) {
|
|
||||||
return FileName::fromString(s);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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),
|
m_extraCompilers.append(factory->create(this, FileName::fromString(file),
|
||||||
fileNames));
|
fileNames));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
|
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user