ProjectExplorer: Add a central ToolChainFactory::createToolChain(type)

This is meant to be the only function directly creating tool chain
objects in the long run (and also the only one setting ids, removing
the need to spell them out in the individual constructors).

Change-Id: Idef242612a5a3f7012628b4080a03d6ee70e5ba0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-06-14 12:06:26 +02:00
parent 67b33a0662
commit bf83926372
3 changed files with 17 additions and 2 deletions

View File

@@ -575,7 +575,7 @@ ProvisioningProfilePtr IosConfigurations::provisioningProfile(const QString &pro
Utils::equal(&ProvisioningProfile::identifier, profileID));
}
static ClangToolChain *createToolChain(const XcodePlatform &platform,
static ClangToolChain *createIosToolChain(const XcodePlatform &platform,
const XcodePlatform::ToolchainTarget &target,
Core::Id l)
{
@@ -616,7 +616,7 @@ QList<ToolChain *> IosToolChainFactory::autoDetect(const QList<ToolChain *> &exi
existingClangToolChains);
auto createOrAdd = [&](ClangToolChain* toolChain, Core::Id l) {
if (!toolChain) {
toolChain = createToolChain(platform, target, l);
toolChain = createIosToolChain(platform, target, l);
existingClangToolChains.append(toolChain);
}
toolChains.append(toolChain);

View File

@@ -486,6 +486,19 @@ void ToolChainFactory::autoDetectionToMap(QVariantMap &data, bool detected)
data.insert(QLatin1String(AUTODETECT_KEY), detected);
}
ToolChain *ToolChainFactory::createToolChain(Core::Id toolChainType)
{
for (ToolChainFactory *factory : qAsConst(Internal::g_toolChainFactories)) {
if (factory->m_supportedToolChainType == toolChainType) {
if (ToolChain *tc = factory->create()) {
tc->d->m_typeId = toolChainType;
return tc;
}
}
}
return nullptr;
}
QSet<Core::Id> ToolChainFactory::supportedLanguages() const
{
return m_supportsAllLanguages ? ToolChainManager::allLanguages() : m_supportedLanguages;

View File

@@ -206,6 +206,8 @@ public:
static Core::Id typeIdFromMap(const QVariantMap &data);
static void autoDetectionToMap(QVariantMap &data, bool detected);
static ToolChain *createToolChain(Core::Id toolChainType);
QSet<Core::Id> supportedLanguages() const;
void setUserCreatable(bool userCreatable);