Commit 2b0daf42 authored by Vikas Pachdha's avatar Vikas Pachdha

iOS: Replaces ios_sim tool with simctl

Task-number: QTCREATORBUG-16947
Change-Id: Ia28d5e4f9f220d566bd64da73989e8c24ef3eb37
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 19dcb9ed
......@@ -33,7 +33,8 @@ HEADERS += \
iosdeploystep.h \
iosdeploystepfactory.h \
iosdeploystepwidget.h \
iosanalyzesupport.h
iosanalyzesupport.h \
simulatorcontrol.h
SOURCES += \
......@@ -61,7 +62,8 @@ SOURCES += \
iosdeploystep.cpp \
iosdeploystepfactory.cpp \
iosdeploystepwidget.cpp \
iosanalyzesupport.cpp
iosanalyzesupport.cpp \
simulatorcontrol.cpp
FORMS += \
iossettingswidget.ui \
......
......@@ -69,6 +69,8 @@ QtcPlugin {
"iossimulatorfactory.cpp",
"iossimulatorfactory.h",
"iostoolhandler.cpp",
"iostoolhandler.h"
"iostoolhandler.h",
"simulatorcontrol.cpp",
"simulatorcontrol.h"
]
}
......@@ -27,6 +27,7 @@
#include "iosconstants.h"
#include "iosdevice.h"
#include "iossimulator.h"
#include "simulatorcontrol.h"
#include "iosprobe.h"
#include <coreplugin/icore.h>
......@@ -333,7 +334,7 @@ void IosConfigurations::updateSimulators()
dev = IDevice::ConstPtr(new IosSimulator(devId));
devManager->addDevice(dev);
}
IosSimulator::updateAvailableDevices();
SimulatorControl::updateAvailableSimulators();
}
void IosConfigurations::setDeveloperPath(const FileName &devPath)
......
......@@ -169,6 +169,8 @@ IosDebugSupport::IosDebugSupport(IosRunConfiguration *runConfig,
m_runner, &IosRunner::start);
connect(m_runControl, &RunControl::finished,
m_runner, &IosRunner::stop);
connect(m_runControl, &DebuggerRunControl::stateChanged,
m_runner, &IosRunner::debuggerStateChanged);
connect(m_runner, &IosRunner::gotServerPorts,
this, &IosDebugSupport::handleServerPorts);
......
......@@ -101,7 +101,12 @@ bool IosDeployStep::init(QList<const BuildStep *> &earlierSteps)
this->target()->activeRunConfiguration());
QTC_ASSERT(runConfig, return false);
m_bundlePath = runConfig->bundleDirectory().toString();
if (m_device.isNull()) {
if (iosdevice()) {
m_deviceType = IosDeviceType(IosDeviceType::IosDevice, deviceId());
} else if (iossimulator()) {
m_deviceType = runConfig->deviceType();
} else {
emit addOutput(tr("Error: no device available, deploy failed."),
BuildStep::ErrorMessageOutput);
return false;
......@@ -113,17 +118,15 @@ void IosDeployStep::run(QFutureInterface<bool> &fi)
{
m_futureInterface = fi;
QTC_CHECK(m_transferStatus == NoTransfer);
if (iosdevice().isNull()) {
if (iossimulator().isNull())
TaskHub::addTask(Task::Error, tr("Deployment failed. No iOS device found."),
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
if (device().isNull()) {
TaskHub::addTask(Task::Error, tr("Deployment failed. No iOS device found."),
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
reportRunResult(m_futureInterface, !iossimulator().isNull());
cleanup();
return;
}
m_toolHandler = new IosToolHandler(m_deviceType, this);
m_transferStatus = TransferInProgress;
QTC_CHECK(m_toolHandler == 0);
m_toolHandler = new IosToolHandler(IosDeviceType(IosDeviceType::IosDevice), this);
m_futureInterface.setProgressRange(0, 200);
m_futureInterface.setProgressValueAndText(0, QLatin1String("Transferring application"));
m_futureInterface.reportStarted();
......@@ -136,7 +139,7 @@ void IosDeployStep::run(QFutureInterface<bool> &fi)
connect(m_toolHandler, &IosToolHandler::errorMsg,
this, &IosDeployStep::handleErrorMsg);
checkProvisioningProfile();
m_toolHandler->requestTransferApp(appBundle(), deviceId());
m_toolHandler->requestTransferApp(appBundle(), m_deviceType.identifier);
}
void IosDeployStep::cancel()
......@@ -150,7 +153,7 @@ void IosDeployStep::cleanup()
QTC_CHECK(m_transferStatus != TransferInProgress);
m_transferStatus = NoTransfer;
m_device.clear();
m_toolHandler = 0;
m_toolHandler = nullptr;
m_expectFail = false;
}
......
......@@ -101,6 +101,7 @@ private:
QFutureInterface<bool> m_futureInterface;
ProjectExplorer::IDevice::ConstPtr m_device;
QString m_bundlePath;
IosDeviceType m_deviceType;
static const Core::Id Id;
bool m_expectFail;
};
......
......@@ -27,6 +27,7 @@
#include "iosconstants.h"
#include "iosmanager.h"
#include "iosdeploystep.h"
#include "simulatorcontrol.h"
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
......@@ -346,7 +347,7 @@ IosDeviceType IosRunConfiguration::deviceType() const
{
QList<IosDeviceType> availableSimulators;
if (m_deviceType.type == IosDeviceType::SimulatedDevice)
availableSimulators = IosSimulator::availableDevices();
availableSimulators = SimulatorControl::availableSimulators();
if (!availableSimulators.isEmpty()) {
QList<IosDeviceType> elegibleDevices;
QString devname = m_deviceType.identifier.split(QLatin1Char(',')).value(0);
......@@ -417,7 +418,7 @@ void IosRunConfigurationWidget::updateValues()
m_deviceTypeLabel->setVisible(showDeviceSelector);
m_deviceTypeComboBox->setVisible(showDeviceSelector);
if (showDeviceSelector && m_deviceTypeModel.rowCount() == 0) {
foreach (const IosDeviceType &dType, IosSimulator::availableDevices()) {
foreach (const IosDeviceType &dType, SimulatorControl::availableSimulators()) {
QStandardItem *item = new QStandardItem(dType.displayName);
QVariant v;
v.setValue(dType);
......
......@@ -168,6 +168,12 @@ void IosRunner::stop()
}
}
void IosRunner::debuggerStateChanged(Debugger::DebuggerState state)
{
if (m_toolHandler)
m_toolHandler->debuggerStateChanged(state);
}
void IosRunner::handleDidStartApp(IosToolHandler *handler, const QString &bundlePath,
const QString &deviceId, IosToolHandler::OpStatus status)
{
......
......@@ -29,6 +29,7 @@
#include "iostoolhandler.h"
#include "iossimulator.h"
#include <debugger/debuggerconstants.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
......@@ -64,6 +65,9 @@ public:
void start();
void stop();
public slots:
void debuggerStateChanged(Debugger::DebuggerState state);
signals:
void didStartApp(Ios::IosToolHandler::OpStatus status);
void gotServerPorts(Utils::Port gdbPort, Utils::Port qmlPort);
......
......@@ -44,9 +44,6 @@ static const QLatin1String iosDeviceTypeDisplayNameKey = QLatin1String("displayN
static const QLatin1String iosDeviceTypeTypeKey = QLatin1String("type");
static const QLatin1String iosDeviceTypeIdentifierKey = QLatin1String("identifier");
QMutex IosSimulator::_mutex;
QList<IosDeviceType> IosSimulator::_availableDevices;
IosSimulator::IosSimulator(Core::Id id)
: IDevice(Core::Id(Constants::IOS_SIMULATOR_TYPE),
IDevice::AutoDetected,
......@@ -119,48 +116,6 @@ IDevice::Ptr IosSimulator::clone() const
return IDevice::Ptr(new IosSimulator(*this));
}
QList<IosDeviceType> IosSimulator::availableDevices()
{
QMutexLocker l(&_mutex);
return _availableDevices;
}
void IosSimulator::setAvailableDevices(QList<IosDeviceType> value)
{
QMutexLocker l(&_mutex);
_availableDevices = value;
}
namespace {
void handleDeviceInfo(Ios::IosToolHandler *handler, const QString &deviceId,
const Ios::IosToolHandler::Dict &info)
{
Q_UNUSED(deviceId);
QList<IosDeviceType> res;
QMapIterator<QString, QString> i(info);
while (i.hasNext()) {
i.next();
IosDeviceType simulatorType(IosDeviceType::SimulatedDevice);
simulatorType.displayName = i.value();
simulatorType.identifier = i.key();
QStringList ids = i.key().split(QLatin1Char(','));
if (ids.length() > 1)
simulatorType.displayName += QLatin1String(", iOS ") + ids.last().trimmed();
res.append(simulatorType);
}
handler->deleteLater();
std::stable_sort(res.begin(), res.end());
IosSimulator::setAvailableDevices(res);
}
}
void IosSimulator::updateAvailableDevices()
{
IosToolHandler *toolHandler = new IosToolHandler(IosDeviceType(IosDeviceType::SimulatedDevice));
QObject::connect(toolHandler, &IosToolHandler::deviceInfo, &handleDeviceInfo);
toolHandler->requestDeviceInfo(QString());
}
void IosSimulator::fromMap(const QVariantMap &map)
{
IDevice::fromMap(map);
......
......@@ -67,10 +67,6 @@ public:
typedef QSharedPointer<IosSimulator> Ptr;
ProjectExplorer::IDevice::DeviceInfo deviceInformation() const override;
static QList<IosDeviceType> availableDevices();
static void setAvailableDevices(QList<IosDeviceType> value);
static void updateAvailableDevices();
QString displayType() const override;
ProjectExplorer::IDeviceWidget *createWidget() override;
QList<Core::Id> actionIds() const override;
......@@ -91,8 +87,6 @@ protected:
IosSimulator(const IosSimulator &other);
private:
mutable quint16 m_lastPort;
static QMutex _mutex;
static QList<IosDeviceType> _availableDevices;
};
namespace IosKitInformation {
......
This diff is collapsed.
......@@ -33,7 +33,6 @@
#include <QStringList>
#include <QProcess>
namespace Ios {
namespace Internal {
class IosToolHandlerPrivate;
......@@ -56,7 +55,6 @@ public:
};
static QString iosDeviceToolPath();
static QString iosSimulatorToolPath();
explicit IosToolHandler(const Internal::IosDeviceType &type, QObject *parent = 0);
~IosToolHandler();
......@@ -66,6 +64,7 @@ public:
void requestDeviceInfo(const QString &deviceId, int timeout = 1000);
bool isRunning();
void stop();
void debuggerStateChanged(int state);
signals:
void isTransferringApp(Ios::IosToolHandler *handler, const QString &bundlePath,
......@@ -85,11 +84,10 @@ signals:
void errorMsg(Ios::IosToolHandler *handler, const QString &msg);
void toolExited(Ios::IosToolHandler *handler, int code);
void finished(Ios::IosToolHandler *handler);
private:
void subprocessError(QProcess::ProcessError error);
void subprocessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void subprocessHasData();
protected:
void killProcess();
private:
friend class Ios::Internal::IosToolHandlerPrivate;
Ios::Internal::IosToolHandlerPrivate *d;
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#ifndef SIMULATORCONTROL_H
#define SIMULATORCONTROL_H
#include <QHash>
#include "utils/fileutils.h"
class QProcess;
namespace Ios {
namespace Internal {
class IosDeviceType;
class SimulatorControlPrivate;
class SimulatorControl
{
explicit SimulatorControl();
public:
static QList<IosDeviceType> availableSimulators();
static void updateAvailableSimulators();
static bool startSimulator(const QString &simUdid);
static bool isSimulatorRunning(const QString &simUdid);
static bool installApp(const QString &simUdid, const Utils::FileName &bundlePath, QByteArray &commandOutput);
static QProcess* spawnAppProcess(const QString &simUdid, const Utils::FileName &bundlePath, qint64 &pId,
bool waitForDebugger, const QStringList &extraArgs);
static qint64 launchApp(const QString &simUdid, const QString &bundleIdentifier, QByteArray *commandOutput = nullptr);
static QString bundleIdentifier(const Utils::FileName &bundlePath);
static QString bundleExecutable(const Utils::FileName &bundlePath);
static bool waitForProcessSpawn(qint64 processPId);
private:
static SimulatorControlPrivate *d;
};
} // namespace Internal
} // namespace Ios
#endif // SIMULATORCONTROL_H
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