Commit 88bbf4d1 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

ToolChains: Check typeId first before doing expensive checks



This should speed up toolchain auto-detection a lot.

Change-Id: Id732ed359a4c9de1d49cb658cc91c2e7c9d1b7a6
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 30cdff71
......@@ -356,8 +356,8 @@ static AndroidToolChain *findToolChain(Utils::FileName &compilerPath, const QLis
{
return static_cast<AndroidToolChain *>(
Utils::findOrDefault(alreadyKnown, [compilerPath](ToolChain *tc) {
return tc->compilerCommand() == compilerPath
&& tc->typeId() == Constants::ANDROID_TOOLCHAIN_ID;
return tc->typeId() == Constants::ANDROID_TOOLCHAIN_ID
&& tc->compilerCommand() == compilerPath;
}));
}
......
......@@ -779,10 +779,13 @@ QList<ToolChain *> GccToolChainFactory::autoDetect(const QList<ToolChain *> &alr
QList<ToolChain *> tcs;
if (HostOsInfo::isMacHost()) {
// Old mac compilers needed to support macx-gccXY mkspecs:
tcs.append(autoDetectToolchains(QLatin1String("g++-4.0"), Abi::hostAbi(), alreadyKnown));
tcs.append(autoDetectToolchains(QLatin1String("g++-4.2"), Abi::hostAbi(), alreadyKnown));
tcs.append(autoDetectToolchains(QLatin1String("g++-4.0"), Abi::hostAbi(),
Constants::GCC_TOOLCHAIN_TYPEID, alreadyKnown));
tcs.append(autoDetectToolchains(QLatin1String("g++-4.2"), Abi::hostAbi(),
Constants::GCC_TOOLCHAIN_TYPEID, alreadyKnown));
}
tcs.append(autoDetectToolchains(QLatin1String("g++"), Abi::hostAbi(), alreadyKnown));
tcs.append(autoDetectToolchains(QLatin1String("g++"), Abi::hostAbi(),
Constants::GCC_TOOLCHAIN_TYPEID,alreadyKnown));
return tcs;
}
......@@ -810,6 +813,7 @@ GccToolChain *GccToolChainFactory::createToolChain(bool autoDetect)
QList<ToolChain *> GccToolChainFactory::autoDetectToolchains(const QString &compiler,
const Abi &requiredAbi,
const Core::Id requiredTypeId,
const QList<ToolChain *> &alreadyKnown)
{
QList<ToolChain *> result;
......@@ -819,7 +823,10 @@ QList<ToolChain *> GccToolChainFactory::autoDetectToolchains(const QString &comp
if (compilerPath.isEmpty())
return result;
result = Utils::filtered(alreadyKnown, Utils::equal(&ToolChain::compilerCommand, compilerPath));
result = Utils::filtered(alreadyKnown, [requiredTypeId, compilerPath](ToolChain *tc) {
return tc->typeId() == requiredTypeId
&& tc->compilerCommand() == compilerPath;
});
if (!result.isEmpty())
return result;
......@@ -1114,7 +1121,8 @@ ClangToolChainFactory::ClangToolChainFactory()
QList<ToolChain *> ClangToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
{
return autoDetectToolchains(QLatin1String("clang++"), Abi::hostAbi(), alreadyKnown);
return autoDetectToolchains(QLatin1String("clang++"), Abi::hostAbi(),
Constants::CLANG_TOOLCHAIN_TYPEID, alreadyKnown);
}
bool ClangToolChainFactory::canRestore(const QVariantMap &data)
......@@ -1194,7 +1202,8 @@ QList<ToolChain *> MingwToolChainFactory::autoDetect(const QList<ToolChain *> &a
{
Abi ha = Abi::hostAbi();
ha = Abi(ha.architecture(), Abi::WindowsOS, Abi::WindowsMSysFlavor, Abi::PEFormat, ha.wordWidth());
return autoDetectToolchains(QLatin1String("g++"), ha, alreadyKnown);
return autoDetectToolchains(QLatin1String("g++"), ha,
Constants::MINGW_TOOLCHAIN_TYPEID, alreadyKnown);
}
bool MingwToolChainFactory::canRestore(const QVariantMap &data)
......@@ -1269,7 +1278,8 @@ LinuxIccToolChainFactory::LinuxIccToolChainFactory()
QList<ToolChain *> LinuxIccToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
{
return autoDetectToolchains(QLatin1String("icpc"), Abi::hostAbi(), alreadyKnown);
return autoDetectToolchains(QLatin1String("icpc"), Abi::hostAbi(),
Constants::LINUXICC_TOOLCHAIN_TYPEID, alreadyKnown);
}
bool LinuxIccToolChainFactory::canRestore(const QVariantMap &data)
......
......@@ -66,8 +66,8 @@ public:
protected:
virtual GccToolChain *createToolChain(bool autoDetect);
QList<ToolChain *> autoDetectToolchains(const QString &compiler,
const Abi &,
QList<ToolChain *> autoDetectToolchains(const QString &compiler, const Abi &requiredAbi,
const Core::Id requiredTypeId,
const QList<ToolChain *> &alreadyKnown);
};
......
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