aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2019-06-14 12:06:26 +0200
committerhjk <hjk@qt.io>2019-06-14 13:44:05 +0000
commitbf8392637215b4eb7d34a3c0c84008c43faf81ae (patch)
tree7ca9085ddea1c9612b68cfa3688b8c9890e3befb
parent67b33a06628ef4df68c402fc1b2907a556a8d44c (diff)
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>
-rw-r--r--src/plugins/ios/iosconfigurations.cpp4
-rw-r--r--src/plugins/projectexplorer/toolchain.cpp13
-rw-r--r--src/plugins/projectexplorer/toolchain.h2
3 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/ios/iosconfigurations.cpp b/src/plugins/ios/iosconfigurations.cpp
index 6f9e134cc9..928a6ec8c2 100644
--- a/src/plugins/ios/iosconfigurations.cpp
+++ b/src/plugins/ios/iosconfigurations.cpp
@@ -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);
diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp
index ccc47381d8..76041a38d8 100644
--- a/src/plugins/projectexplorer/toolchain.cpp
+++ b/src/plugins/projectexplorer/toolchain.cpp
@@ -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;
diff --git a/src/plugins/projectexplorer/toolchain.h b/src/plugins/projectexplorer/toolchain.h
index a6399a310e..cbac188278 100644
--- a/src/plugins/projectexplorer/toolchain.h
+++ b/src/plugins/projectexplorer/toolchain.h
@@ -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);