| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2014-01-07 13:27:11 +01:00
										 |  |  | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | ** Contact: http://www.qt-project.org/legal
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and Digia.  For licensing terms and | 
					
						
							|  |  |  | ** conditions see http://qt.digia.com/licensing.  For further information
 | 
					
						
							|  |  |  | ** use the contact form at http://qt.digia.com/contact-us.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							|  |  |  | ** General Public License version 2.1 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
					
						
							|  |  |  | ** packaging of this file.  Please review the following information to | 
					
						
							|  |  |  | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
					
						
							|  |  |  | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** In addition, as a special exception, Digia gives you certain additional | 
					
						
							|  |  |  | ** rights.  These rights are described in the Digia Qt LGPL Exception | 
					
						
							|  |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "iosconfigurations.h"
 | 
					
						
							|  |  |  | #include "iosconstants.h"
 | 
					
						
							|  |  |  | #include "iosdevice.h"
 | 
					
						
							|  |  |  | #include "iossimulator.h"
 | 
					
						
							|  |  |  | #include "iosprobe.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <coreplugin/icore.h>
 | 
					
						
							|  |  |  | #include <utils/qtcassert.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/kitmanager.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/kitinformation.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/devicesupport/devicemanager.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/toolchainmanager.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/toolchain.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/gcctoolchain.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/projectexplorerconstants.h>
 | 
					
						
							| 
									
										
										
										
											2013-10-25 13:47:08 +02:00
										 |  |  | #include <debugger/debuggeritemmanager.h>
 | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | #include <debugger/debuggerkitinformation.h>
 | 
					
						
							|  |  |  | #include <qtsupport/baseqtversion.h>
 | 
					
						
							|  |  |  | #include <qtsupport/qtkitinformation.h>
 | 
					
						
							|  |  |  | #include <qtsupport/qtversionmanager.h>
 | 
					
						
							|  |  |  | #include <qtsupport/qtversionfactory.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QFileInfo>
 | 
					
						
							|  |  |  | #include <QList>
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  | #include <QMap>
 | 
					
						
							|  |  |  | #include <QSettings>
 | 
					
						
							|  |  |  | #include <QStringList>
 | 
					
						
							|  |  |  | #include <QTimer>
 | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | using namespace ProjectExplorer; | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  | using namespace QtSupport; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | using namespace Utils; | 
					
						
							| 
									
										
										
										
											2013-11-05 11:32:47 +01:00
										 |  |  | using namespace Debugger; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  | const bool debugProbe = false; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Ios { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  | const QLatin1String SettingsGroup("IosConfigurations"); | 
					
						
							|  |  |  | const QLatin1String ignoreAllDevicesKey("IgnoreAllDevices"); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void IosConfigurations::updateAutomaticKitList() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |     QMap<QString, Platform> platforms = IosProbe::detectPlatforms(); | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QMapIterator<QString, Platform> iter(platforms); | 
					
						
							|  |  |  |         while (iter.hasNext()) { | 
					
						
							|  |  |  |             iter.next(); | 
					
						
							|  |  |  |             const Platform &p = iter.value(); | 
					
						
							|  |  |  |             setDeveloperPath(p.developerPath); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-11-05 19:21:16 +01:00
										 |  |  |     // filter out all non iphone, non base, non clang or cxx11 platforms, as we don't set up kits for those
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QMap<QString, Platform>::iterator iter(platforms.begin()); | 
					
						
							|  |  |  |         while (iter != platforms.end()) { | 
					
						
							|  |  |  |             const Platform &p = iter.value(); | 
					
						
							|  |  |  |             if (!p.name.startsWith(QLatin1String("iphone")) || (p.platformKind & Platform::BasePlatform) == 0 | 
					
						
							|  |  |  |                     || (p.platformKind & Platform::Cxx11Support) != 0 | 
					
						
							|  |  |  |                     || !p.compilerPath.toString().contains(QLatin1String("clang"))) | 
					
						
							|  |  |  |                 iter = platforms.erase(iter); | 
					
						
							|  |  |  |             else { | 
					
						
							|  |  |  |                 if (debugProbe) | 
					
						
							|  |  |  |                     qDebug() << "keeping" << p.name << " " << p.compilerPath.toString() << " " | 
					
						
							|  |  |  |                              << p.backendFlags; | 
					
						
							|  |  |  |                 ++iter; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QMap<QString, GccToolChain *> platformToolchainMap; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |     // check existing toolchains (and remove old ones)
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     foreach (ToolChain *tc, ToolChainManager::toolChains()) { | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |         if (!tc->isAutoDetected()) // use also user toolchains?
 | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         if (tc->type() != QLatin1String("clang") && tc->type() != QLatin1String("gcc")) | 
					
						
							|  |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |         GccToolChain *toolchain = static_cast<GccToolChain *>(tc); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |         QMapIterator<QString, Platform> iter(platforms); | 
					
						
							|  |  |  |         bool found = false; | 
					
						
							|  |  |  |         while (iter.hasNext()) { | 
					
						
							|  |  |  |             iter.next(); | 
					
						
							|  |  |  |             const Platform &p = iter.value(); | 
					
						
							|  |  |  |             if (p.compilerPath == toolchain->compilerCommand() | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                     && p.backendFlags == toolchain->platformCodeGenFlags() | 
					
						
							|  |  |  |                     && !platformToolchainMap.contains(p.name)) { | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                 platformToolchainMap[p.name] = toolchain; | 
					
						
							|  |  |  |                 found = true; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         iter.toFront(); | 
					
						
							|  |  |  |         while (iter.hasNext()) { | 
					
						
							|  |  |  |             iter.next(); | 
					
						
							|  |  |  |             const Platform &p = iter.value(); | 
					
						
							|  |  |  |             if (p.platformKind) | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             if (p.compilerPath == toolchain->compilerCommand() | 
					
						
							|  |  |  |                     && p.backendFlags == toolchain->platformCodeGenFlags()) { | 
					
						
							|  |  |  |                 found = true; | 
					
						
							| 
									
										
										
										
											2013-10-31 17:46:52 +01:00
										 |  |  |                 if (p.architecture == QLatin1String("i386") | 
					
						
							|  |  |  |                         && toolchain->targetAbi().wordWidth() != 32) { | 
					
						
							|  |  |  |                     if (debugProbe) | 
					
						
							|  |  |  |                         qDebug() << "resetting api of " << toolchain->displayName(); | 
					
						
							|  |  |  |                     toolchain->setTargetAbi(Abi(Abi::X86Architecture, | 
					
						
							|  |  |  |                                                 Abi::MacOS, Abi::GenericMacFlavor, | 
					
						
							|  |  |  |                                                 Abi::MachOFormat, 32)); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 platformToolchainMap[p.name] = toolchain; | 
					
						
							|  |  |  |                 if (debugProbe) | 
					
						
							|  |  |  |                     qDebug() << p.name << " -> " << toolchain->displayName(); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!found && (tc->displayName().startsWith(QLatin1String("iphone")) | 
					
						
							|  |  |  |                        || tc->displayName().startsWith(QLatin1String("mac")))) { | 
					
						
							|  |  |  |             qDebug() << "removing toolchain" << tc->displayName(); | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |             ToolChainManager::deregisterToolChain(tc); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     // add missing toolchains
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QMapIterator<QString, Platform> iter(platforms); | 
					
						
							|  |  |  |         while (iter.hasNext()) { | 
					
						
							|  |  |  |             iter.next(); | 
					
						
							|  |  |  |             const Platform &p = iter.value(); | 
					
						
							| 
									
										
										
										
											2013-11-05 19:21:16 +01:00
										 |  |  |             if (platformToolchainMap.contains(p.name)) | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                 continue; | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |             GccToolChain *toolchain; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             if (p.compilerPath.toFileInfo().baseName().startsWith(QLatin1String("clang"))) | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                 toolchain = new ClangToolChain(ToolChain::AutoDetection); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             else | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                 toolchain = new GccToolChain( | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                             QLatin1String(ProjectExplorer::Constants::GCC_TOOLCHAIN_ID), | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                             ToolChain::AutoDetection); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             QString baseDisplayName = p.name; | 
					
						
							|  |  |  |             QString displayName = baseDisplayName; | 
					
						
							|  |  |  |             for (int iVers = 1; iVers < 100; ++iVers) { | 
					
						
							|  |  |  |                 bool unique = true; | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                 foreach (ToolChain *existingTC, ToolChainManager::toolChains()) { | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                     if (existingTC->displayName() == displayName) { | 
					
						
							|  |  |  |                         unique = false; | 
					
						
							|  |  |  |                         break; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (unique) break; | 
					
						
							|  |  |  |                 displayName = baseDisplayName + QLatin1String("-") + QString::number(iVers); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             toolchain->setDisplayName(displayName); | 
					
						
							|  |  |  |             toolchain->setPlatformCodeGenFlags(p.backendFlags); | 
					
						
							|  |  |  |             toolchain->setPlatformLinkerFlags(p.backendFlags); | 
					
						
							|  |  |  |             toolchain->setCompilerCommand(p.compilerPath); | 
					
						
							| 
									
										
										
										
											2013-10-31 17:46:52 +01:00
										 |  |  |             if (p.architecture == QLatin1String("i386")) { | 
					
						
							|  |  |  |                 if (debugProbe) | 
					
						
							|  |  |  |                     qDebug() << "setting toolchain Abi for " << toolchain->displayName(); | 
					
						
							|  |  |  |                 toolchain->setTargetAbi(Abi(Abi::X86Architecture,Abi::MacOS, Abi::GenericMacFlavor, | 
					
						
							|  |  |  |                                             Abi::MachOFormat, 32)); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (debugProbe) | 
					
						
							|  |  |  |                 qDebug() << "adding toolchain " << p.name; | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |             ToolChainManager::registerToolChain(toolchain); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             platformToolchainMap.insert(p.name, toolchain); | 
					
						
							|  |  |  |             QMapIterator<QString, Platform> iter2(iter); | 
					
						
							|  |  |  |             while (iter2.hasNext()) { | 
					
						
							|  |  |  |                 iter2.next(); | 
					
						
							|  |  |  |                 const Platform &p2 = iter2.value(); | 
					
						
							|  |  |  |                 if (!platformToolchainMap.contains(p2.name) | 
					
						
							|  |  |  |                         && p2.compilerPath == toolchain->compilerCommand() | 
					
						
							|  |  |  |                         && p2.backendFlags == toolchain->platformCodeGenFlags()) { | 
					
						
							|  |  |  |                     platformToolchainMap[p2.name] = toolchain; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     QMap<Abi::Architecture, QList<BaseQtVersion *> > qtVersionsForArch; | 
					
						
							|  |  |  |     foreach (BaseQtVersion *qtVersion, QtVersionManager::versions()) { | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |         if (debugProbe) | 
					
						
							|  |  |  |             qDebug() << "qt type " << qtVersion->type(); | 
					
						
							|  |  |  |         if (qtVersion->type() != QLatin1String(Constants::IOSQT)) { | 
					
						
							|  |  |  |             if (qtVersion->qmakeProperty("QMAKE_PLATFORM").contains(QLatin1String("ios")) | 
					
						
							|  |  |  |                     || qtVersion->qmakeProperty("QMAKE_XSPEC").contains(QLatin1String("ios"))) { | 
					
						
							|  |  |  |                 // replace with an ios version
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                 BaseQtVersion *iosVersion = | 
					
						
							|  |  |  |                         QtVersionFactory::createQtVersionFromQMakePath( | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                             qtVersion->qmakeCommand(), | 
					
						
							|  |  |  |                             qtVersion->isAutodetected(), | 
					
						
							|  |  |  |                             qtVersion->autodetectionSource()); | 
					
						
							|  |  |  |                 if (iosVersion && iosVersion->type() == QLatin1String(Constants::IOSQT)) { | 
					
						
							|  |  |  |                     if (debugProbe) | 
					
						
							|  |  |  |                         qDebug() << "converting QT to iOS QT for " << qtVersion->qmakeCommand().toUserOutput(); | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                     QtVersionManager::removeVersion(qtVersion); | 
					
						
							|  |  |  |                     QtVersionManager::addVersion(iosVersion); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                     qtVersion = iosVersion; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     continue; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!qtVersion->isValid()) | 
					
						
							|  |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |         QList<Abi> qtAbis = qtVersion->qtAbis(); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |         if (qtAbis.empty()) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         if (debugProbe) | 
					
						
							|  |  |  |             qDebug() << "qt arch " << qtAbis.first().architecture(); | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |         foreach (const Abi &abi, qtAbis) | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             qtVersionsForArch[abi.architecture()].append(qtVersion); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-05 11:32:47 +01:00
										 |  |  |     const DebuggerItem *possibleDebugger = DebuggerItemManager::findByEngineType(Debugger::LldbEngineType); | 
					
						
							|  |  |  |     QVariant debuggerId = (possibleDebugger ? possibleDebugger->id() : QVariant()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     QList<Kit *> existingKits; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |     QList<bool> kitMatched; | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     foreach (Kit *k, KitManager::kits()) { | 
					
						
							|  |  |  |         Core::Id deviceKind = DeviceTypeKitInformation::deviceTypeId(k); | 
					
						
							|  |  |  |         if (deviceKind != Constants::IOS_DEVICE_TYPE | 
					
						
							| 
									
										
										
										
											2013-12-09 16:21:33 +01:00
										 |  |  |                 && deviceKind != Constants::IOS_SIMULATOR_TYPE) { | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             if (debugProbe) | 
					
						
							|  |  |  |                 qDebug() << "skipping existing kit with deviceKind " << deviceKind.toString(); | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |         if (!k->isAutoDetected()) | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             continue; | 
					
						
							|  |  |  |         existingKits << k; | 
					
						
							|  |  |  |         kitMatched << false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     // create missing kits
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QMapIterator<QString, Platform> iter(platforms); | 
					
						
							|  |  |  |         while (iter.hasNext()) { | 
					
						
							|  |  |  |             iter.next(); | 
					
						
							|  |  |  |             const Platform &p = iter.value(); | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |             GccToolChain *pToolchain = platformToolchainMap.value(p.name, 0); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             if (!pToolchain) | 
					
						
							|  |  |  |                 continue; | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |             Core::Id pDeviceType; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             if (debugProbe) | 
					
						
							|  |  |  |                 qDebug() << "guaranteeing kit for " << p.name ; | 
					
						
							|  |  |  |             if (p.name.startsWith(QLatin1String("iphoneos-"))) { | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                 pDeviceType = Constants::IOS_DEVICE_TYPE; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             } else if (p.name.startsWith(QLatin1String("iphonesimulator-"))) { | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                 pDeviceType = Constants::IOS_SIMULATOR_TYPE; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                 if (debugProbe) | 
					
						
							|  |  |  |                     qDebug() << "pDeviceType " << pDeviceType.toString(); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 if (debugProbe) | 
					
						
							|  |  |  |                     qDebug() << "skipping non ios kit " << p.name; | 
					
						
							|  |  |  |                 // we looked up only the ios qt build above...
 | 
					
						
							|  |  |  |                 continue; | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                 //pDeviceType = Constants::DESKTOP_DEVICE_TYPE;
 | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |             Abi::Architecture arch = pToolchain->targetAbi().architecture(); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |             QList<BaseQtVersion *> qtVersions = qtVersionsForArch.value(arch); | 
					
						
							|  |  |  |             foreach (BaseQtVersion *qt, qtVersions) { | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                 Kit *kitAtt = 0; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                 bool kitExists = false; | 
					
						
							|  |  |  |                 for (int i = 0; i < existingKits.size(); ++i) { | 
					
						
							|  |  |  |                     Kit *k = existingKits.at(i); | 
					
						
							|  |  |  |                     if (DeviceTypeKitInformation::deviceTypeId(k) == pDeviceType | 
					
						
							|  |  |  |                             && ToolChainKitInformation::toolChain(k) == pToolchain | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |                             && QtKitInformation::qtVersion(k) == qt) | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                     { | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                         QTC_CHECK(!kitMatched.value(i, true)); | 
					
						
							|  |  |  |                         // as we generate only two kits per qt (one for device and one for simulator)
 | 
					
						
							|  |  |  |                         // we do not compare the sdk (thus automatically upgrading it in place if a
 | 
					
						
							|  |  |  |                         // new Xcode is used). Change?
 | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                         kitExists = true; | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                         kitAtt = k; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                         if (debugProbe) | 
					
						
							|  |  |  |                             qDebug() << "found existing kit " << k->displayName() << " for " << p.name | 
					
						
							|  |  |  |                                      << "," << qt->displayName(); | 
					
						
							|  |  |  |                         if (i<kitMatched.size()) | 
					
						
							|  |  |  |                             kitMatched.replace(i, true); | 
					
						
							|  |  |  |                         break; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                 if (kitExists) { | 
					
						
							|  |  |  |                     kitAtt->blockNotification(); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     if (debugProbe) | 
					
						
							|  |  |  |                         qDebug() << "setting up new kit for " << p.name; | 
					
						
							|  |  |  |                     kitAtt = new Kit; | 
					
						
							|  |  |  |                     kitAtt->setAutoDetected(true); | 
					
						
							|  |  |  |                     QString baseDisplayName = tr("%1 %2").arg(p.name, qt->displayName()); | 
					
						
							|  |  |  |                     QString displayName = baseDisplayName; | 
					
						
							|  |  |  |                     for (int iVers = 1; iVers < 100; ++iVers) { | 
					
						
							|  |  |  |                         bool unique = true; | 
					
						
							|  |  |  |                         foreach (const Kit *k, existingKits) { | 
					
						
							|  |  |  |                             if (k->displayName() == displayName) { | 
					
						
							|  |  |  |                                 unique = false; | 
					
						
							|  |  |  |                                 break; | 
					
						
							|  |  |  |                             } | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                         } | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                         if (unique) break; | 
					
						
							|  |  |  |                         displayName = baseDisplayName + QLatin1String("-") + QString::number(iVers); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                     kitAtt->setDisplayName(displayName); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                 kitAtt->setIconPath(Utils::FileName::fromString( | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |                                         QLatin1String(Constants::IOS_SETTINGS_CATEGORY_ICON))); | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                 DeviceTypeKitInformation::setDeviceTypeId(kitAtt, pDeviceType); | 
					
						
							|  |  |  |                 ToolChainKitInformation::setToolChain(kitAtt, pToolchain); | 
					
						
							|  |  |  |                 QtKitInformation::setQtVersion(kitAtt, qt); | 
					
						
							|  |  |  |                 if ((!Debugger::DebuggerKitInformation::debugger(kitAtt) | 
					
						
							|  |  |  |                         || !Debugger::DebuggerKitInformation::debugger(kitAtt)->isValid() | 
					
						
							|  |  |  |                         || Debugger::DebuggerKitInformation::debugger(kitAtt)->engineType() != Debugger::LldbEngineType) | 
					
						
							|  |  |  |                         && debuggerId.isValid()) | 
					
						
							|  |  |  |                     Debugger::DebuggerKitInformation::setDebugger(kitAtt, | 
					
						
							| 
									
										
										
										
											2013-11-05 11:32:47 +01:00
										 |  |  |                                                                   debuggerId); | 
					
						
							| 
									
										
										
										
											2013-10-11 13:55:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                 kitAtt->setMutable(DeviceKitInformation::id(), true); | 
					
						
							|  |  |  |                 kitAtt->setSticky(QtKitInformation::id(), true); | 
					
						
							|  |  |  |                 kitAtt->setSticky(ToolChainKitInformation::id(), true); | 
					
						
							|  |  |  |                 kitAtt->setSticky(DeviceTypeKitInformation::id(), true); | 
					
						
							|  |  |  |                 kitAtt->setSticky(SysRootKitInformation::id(), true); | 
					
						
							|  |  |  |                 kitAtt->setSticky(Debugger::DebuggerKitInformation::id(), false); | 
					
						
							| 
									
										
										
										
											2013-10-31 18:09:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                 SysRootKitInformation::setSysRoot(kitAtt, p.sdkPath); | 
					
						
							| 
									
										
										
										
											2013-10-16 11:02:37 +02:00
										 |  |  |                 // QmakeProjectManager::QmakeKitInformation::setMkspec(newKit,
 | 
					
						
							| 
									
										
										
										
											2014-02-07 15:46:36 +01:00
										 |  |  |                 //    Utils::FileName::fromLatin1("macx-ios-clang")));
 | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |                 if (kitExists) { | 
					
						
							|  |  |  |                     kitAtt->unblockNotification(); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     KitManager::registerKit(kitAtt); | 
					
						
							|  |  |  |                     existingKits << kitAtt; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     for (int i = 0; i < kitMatched.size(); ++i) { | 
					
						
							| 
									
										
										
										
											2013-11-05 11:32:47 +01:00
										 |  |  |         // deleting extra (old) kits
 | 
					
						
							| 
									
										
										
										
											2013-12-02 11:59:10 +01:00
										 |  |  |         if (!kitMatched.at(i)) { | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |             qDebug() << "deleting kit " << existingKits.at(i)->displayName(); | 
					
						
							|  |  |  |             KitManager::deregisterKit(existingKits.at(i)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  | static IosConfigurations *m_instance = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QObject *IosConfigurations::instance() | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |     return m_instance; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  | void IosConfigurations::initialize() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QTC_CHECK(m_instance == 0); | 
					
						
							|  |  |  |     m_instance = new IosConfigurations(0); | 
					
						
							|  |  |  |     m_instance->updateSimulators(); | 
					
						
							|  |  |  |     QTimer::singleShot(10000, IosDeviceManager::instance(), SLOT(monitorAvailableDevices())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  | bool IosConfigurations::ignoreAllDevices() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     return m_instance->m_ignoreAllDevices; | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void IosConfigurations::setIgnoreAllDevices(bool ignoreDevices) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     if (ignoreDevices != m_instance->m_ignoreAllDevices) { | 
					
						
							|  |  |  |         m_instance->m_ignoreAllDevices = ignoreDevices; | 
					
						
							|  |  |  |         m_instance->save(); | 
					
						
							|  |  |  |         emit m_instance->updated(); | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | FileName IosConfigurations::developerPath() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     return m_instance->m_developerPath; | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void IosConfigurations::save() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     QSettings *settings = Core::ICore::settings(); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |     settings->beginGroup(SettingsGroup); | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |     settings->setValue(ignoreAllDevicesKey, m_ignoreAllDevices); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |     settings->endGroup(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | IosConfigurations::IosConfigurations(QObject *parent) | 
					
						
							|  |  |  |     : QObject(parent) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     load(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void IosConfigurations::load() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     QSettings *settings = Core::ICore::settings(); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |     settings->beginGroup(SettingsGroup); | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |     m_ignoreAllDevices = settings->value(ignoreAllDevicesKey, false).toBool(); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |     settings->endGroup(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  | void IosConfigurations::updateSimulators() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |     // currently we have just one simulator
 | 
					
						
							|  |  |  |     DeviceManager *devManager = DeviceManager::instance(); | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     Core::Id devId = Constants::IOS_SIMULATOR_DEVICE_ID; | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |     QMap<QString, Platform> platforms = IosProbe::detectPlatforms(); | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  |     QMapIterator<QString, Platform> iter(platforms); | 
					
						
							|  |  |  |     Utils::FileName simulatorPath; | 
					
						
							|  |  |  |     while (iter.hasNext()) { | 
					
						
							|  |  |  |         iter.next(); | 
					
						
							|  |  |  |         const Platform &p = iter.value(); | 
					
						
							|  |  |  |         if (p.name.startsWith(QLatin1String("iphonesimulator-"))) { | 
					
						
							|  |  |  |             simulatorPath = p.platformPath; | 
					
						
							|  |  |  |             simulatorPath.appendPath(QLatin1String( | 
					
						
							|  |  |  |                 "/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator")); | 
					
						
							|  |  |  |             if (simulatorPath.toFileInfo().exists()) | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     IDevice::ConstPtr dev = devManager->find(devId); | 
					
						
							|  |  |  |     if (!simulatorPath.isEmpty() && simulatorPath.toFileInfo().exists()) { | 
					
						
							|  |  |  |         if (!dev.isNull()) { | 
					
						
							|  |  |  |             if (static_cast<const IosSimulator*>(dev.data())->simulatorPath() == simulatorPath) | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             devManager->removeDevice(devId); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         IosSimulator *newDev = new IosSimulator(devId, simulatorPath); | 
					
						
							|  |  |  |         devManager->addDevice(IDevice::ConstPtr(newDev)); | 
					
						
							|  |  |  |     } else if (!dev.isNull()) { | 
					
						
							|  |  |  |         devManager->removeDevice(devId); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  | void IosConfigurations::setDeveloperPath(const FileName &devPath) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-10-14 17:07:51 +02:00
										 |  |  |     if (devPath != m_instance->m_developerPath) { | 
					
						
							|  |  |  |         m_instance->m_developerPath = devPath; | 
					
						
							|  |  |  |         m_instance->save(); | 
					
						
							|  |  |  |         updateAutomaticKitList(); | 
					
						
							|  |  |  |         emit m_instance->updated(); | 
					
						
							| 
									
										
										
										
											2013-10-07 20:14:54 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-25 16:02:17 +02:00
										 |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace Ios
 |