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,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);
|
||||
|
Reference in New Issue
Block a user