Commit 9a4caa4b authored by Fawzi Mohamed's avatar Fawzi Mohamed

ios: improve automatic kits

* fix incorrect old kits
* avoid adding a special debugger

Change-Id: I233068dbb9958045cdc2e875337297748b2b4ff8
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent 242cba30
......@@ -38,10 +38,12 @@
#include <utils/fileutils.h>
#include <utils/persistentsettings.h>
#include <utils/qtcassert.h>
#include <utils/hostosinfo.h>
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QProcess>
using namespace ProjectExplorer;
using namespace Utils;
......@@ -217,6 +219,19 @@ void DebuggerItemManager::autoDetectGdbOrLldbDebuggers()
QFileInfoList suspects;
if (HostOsInfo::isMacHost()) {
QProcess lldbInfo;
lldbInfo.start(QLatin1String("xcrun"), QStringList() << QLatin1String("--find")
<< QLatin1String("lldb"));
if (!lldbInfo.waitForFinished(2000)) {
lldbInfo.kill();
lldbInfo.waitForFinished();
} else {
QByteArray lPath = lldbInfo.readAll();
suspects.append(QFileInfo(QString::fromLocal8Bit(lPath.data(), lPath.size() -1)));
}
}
QStringList path = Environment::systemEnvironment().path();
foreach (const QString &base, path) {
QDir dir(base);
......@@ -301,6 +316,14 @@ const DebuggerItem *DebuggerItemManager::findById(const QVariant &id)
return 0;
}
const DebuggerItem *DebuggerItemManager::findByEngineType(DebuggerEngineType engineType)
{
foreach (const DebuggerItem &item, m_debuggers)
if (item.engineType() == engineType && item.isValid())
return &item;
return 0;
}
void DebuggerItemManager::restoreDebuggers()
{
// Read debuggers from SDK
......
......@@ -62,6 +62,7 @@ public:
static const DebuggerItem *findByCommand(const Utils::FileName &command);
static const DebuggerItem *findById(const QVariant &id);
static const DebuggerItem *findByEngineType(DebuggerEngineType engineType);
static void restoreDebuggers();
static QString uniqueDisplayName(const QString &base);
......
......@@ -59,6 +59,7 @@
using namespace ProjectExplorer;
using namespace QtSupport;
using namespace Utils;
using namespace Debugger;
const bool debugProbe = false;
......@@ -243,6 +244,9 @@ void IosConfigurations::updateAutomaticKitList()
qtVersionsForArch[abi.architecture()].append(qtVersion);
}
const DebuggerItem *possibleDebugger = DebuggerItemManager::findByEngineType(Debugger::LldbEngineType);
QVariant debuggerId = (possibleDebugger ? possibleDebugger->id() : QVariant());
QList<Kit *> existingKits;
QList<bool> kitMatched;
foreach (Kit *k, KitManager::kits()) {
......@@ -331,22 +335,15 @@ void IosConfigurations::updateAutomaticKitList()
ToolChainKitInformation::setToolChain(newKit, pToolchain);
QtKitInformation::setQtVersion(newKit, qt);
//DeviceKitInformation::setDevice(newKit, device);
Debugger::DebuggerItem debugger;
debugger.setCommand(lldbPath());
debugger.setEngineType(Debugger::LldbEngineType);
debugger.setDisplayName(tr("IOS Debugger"));
debugger.setAutoDetected(true);
debugger.setAbi(pToolchain->targetAbi());
QVariant id = Debugger::DebuggerItemManager::registerDebugger(debugger);
Debugger::DebuggerKitInformation::setDebugger(newKit, id);
if (!debuggerId.isValid())
Debugger::DebuggerKitInformation::setDebugger(newKit,
debuggerId);
newKit->setMutable(DeviceKitInformation::id(), true);
newKit->setSticky(QtKitInformation::id(), true);
newKit->setSticky(ToolChainKitInformation::id(), true);
newKit->setSticky(DeviceTypeKitInformation::id(), true);
newKit->setSticky(SysRootKitInformation::id(), true);
newKit->setSticky(Debugger::DebuggerKitInformation::id(), true);
SysRootKitInformation::setSysRoot(newKit, p.sdkPath);
// QmakeProjectManager::QmakeKitInformation::setMkspec(newKit,
......@@ -356,12 +353,30 @@ void IosConfigurations::updateAutomaticKitList()
}
}
}
// deleting extra (old) kits
for (int i = 0; i < kitMatched.size(); ++i) {
// deleting extra (old) kits
if (!kitMatched.at(i) && !existingKits.at(i)->isValid()) {
qDebug() << "deleting kit " << existingKits.at(i)->displayName();
KitManager::deregisterKit(existingKits.at(i));
}
// fix old kits
if (kitMatched.at(i)) {
Kit *kit = existingKits.at(i);
kit->blockNotification();
const Debugger::DebuggerItem *debugger = Debugger::DebuggerKitInformation::debugger(kit);
if ((!debugger || !debugger->isValid()) && debuggerId.isValid())
Debugger::DebuggerKitInformation::setDebugger(kit, debuggerId);
if (!kit->isMutable(DeviceKitInformation::id())) {
kit->setMutable(DeviceKitInformation::id(), true);
kit->setSticky(QtKitInformation::id(), true);
kit->setSticky(ToolChainKitInformation::id(), true);
kit->setSticky(DeviceTypeKitInformation::id(), true);
kit->setSticky(SysRootKitInformation::id(), true);
}
if (kit->isSticky(Debugger::DebuggerKitInformation::id()))
kit->setSticky(Debugger::DebuggerKitInformation::id(), false);
kit->unblockNotification();
}
}
}
......@@ -399,11 +414,6 @@ FileName IosConfigurations::developerPath()
return m_instance->m_developerPath;
}
FileName IosConfigurations::lldbPath()
{
return m_instance->m_lldbPath;
}
void IosConfigurations::save()
{
QSettings *settings = Core::ICore::settings();
......@@ -465,18 +475,6 @@ void IosConfigurations::setDeveloperPath(const FileName &devPath)
m_instance->m_developerPath = devPath;
m_instance->save();
updateAutomaticKitList();
QProcess lldbInfo;
lldbInfo.start(QLatin1String("xcrun"), QStringList() << QLatin1String("--find")
<< QLatin1String("lldb"));
if (!lldbInfo.waitForFinished(2000)) {
lldbInfo.kill();
} else {
QByteArray lPath=lldbInfo.readAll();
lPath.chop(1);
Utils::FileName lldbPath = Utils::FileName::fromString(QString::fromLocal8Bit(lPath.data(), lPath.size()));
if (lldbPath.toFileInfo().exists())
m_instance->m_lldbPath = lldbPath;
}
emit m_instance->updated();
}
}
......
......@@ -69,7 +69,6 @@ private:
static void setDeveloperPath(const Utils::FileName &devPath);
Utils::FileName m_developerPath;
Utils::FileName m_lldbPath;
bool m_ignoreAllDevices;
};
......
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