forked from qt-creator/qt-creator
iOS: use dedicated classes to create run workers
Change-Id: I3ba7b75edf69b9cf88726132f154de5c4cc7ca7b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -22,6 +22,7 @@ const char IOS_SIMULATOR_DEVICE_ID[] = "iOS Simulator Device ";
|
||||
const char IOS_PRESET_BUILD_STEP_ID[] = "Ios.IosPresetBuildStep";
|
||||
const char IOS_DSYM_BUILD_STEP_ID[] = "Ios.IosDsymBuildStep";
|
||||
const char IOS_DEPLOY_STEP_ID[] = "Qt4ProjectManager.IosDeployStep";
|
||||
const char IOS_RUNCONFIG_ID[] = "Qt4ProjectManager.IosRunConfiguration:";
|
||||
|
||||
const char IosTarget[] = "IosTarget"; // QString
|
||||
const char IosBuildDir[] = "IosBuildDir"; // QString
|
||||
|
@@ -21,13 +21,10 @@
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace QtSupport;
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
namespace Ios::Internal {
|
||||
|
||||
Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common", QtWarningMsg)
|
||||
|
||||
@@ -59,22 +56,9 @@ public:
|
||||
IosDeployStepFactory deployStepFactory;
|
||||
IosDsymBuildStepFactory dsymBuildStepFactory;
|
||||
IosDeployConfigurationFactory deployConfigurationFactory;
|
||||
|
||||
RunWorkerFactory runWorkerFactory{
|
||||
RunWorkerFactory::make<IosRunSupport>(),
|
||||
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
|
||||
{runConfigurationFactory.runConfigurationId()}
|
||||
};
|
||||
RunWorkerFactory debugWorkerFactory{
|
||||
RunWorkerFactory::make<IosDebugSupport>(),
|
||||
{ProjectExplorer::Constants::DEBUG_RUN_MODE},
|
||||
{runConfigurationFactory.runConfigurationId()}
|
||||
};
|
||||
RunWorkerFactory qmlProfilerWorkerFactory{
|
||||
RunWorkerFactory::make<IosQmlProfilerSupport>(),
|
||||
{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE},
|
||||
{runConfigurationFactory.runConfigurationId()}
|
||||
};
|
||||
IosRunWorkerFactory runWorkerFactory;
|
||||
IosDebugWorkerFactory debugWorkerFactory;
|
||||
IosQmlProfilerWorkerFactory qmlProfilerWorkerFactory;
|
||||
};
|
||||
|
||||
IosPlugin::~IosPlugin()
|
||||
@@ -96,5 +80,4 @@ bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
} // Internal::Ios
|
||||
|
@@ -5,8 +5,7 @@
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
namespace Ios::Internal {
|
||||
|
||||
class IosPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
@@ -23,5 +22,4 @@ private:
|
||||
class IosPluginPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
} // Ios::Internal
|
||||
|
@@ -36,8 +36,7 @@
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
namespace Ios::Internal {
|
||||
|
||||
static const QLatin1String deviceTypeKey("Ios.device_type");
|
||||
|
||||
@@ -403,10 +402,9 @@ FilePath IosDeviceTypeAspect::localExecutable() const
|
||||
|
||||
IosRunConfigurationFactory::IosRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<IosRunConfiguration>("Qt4ProjectManager.IosRunConfiguration:");
|
||||
registerRunConfiguration<IosRunConfiguration>(Constants::IOS_RUNCONFIG_ID);
|
||||
addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE);
|
||||
addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
} // Ios::Internal
|
||||
|
@@ -1,15 +1,19 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "iosrunner.h"
|
||||
|
||||
#include "iosconfigurations.h"
|
||||
#include "iosconstants.h"
|
||||
#include "iosdevice.h"
|
||||
#include "iosrunconfiguration.h"
|
||||
#include "iosrunner.h"
|
||||
#include "iossimulator.h"
|
||||
#include "iosconstants.h"
|
||||
#include "iostoolhandler.h"
|
||||
|
||||
#include <debugger/debuggerplugin.h>
|
||||
#include <debugger/debuggerconstants.h>
|
||||
#include <debugger/debuggerkitinformation.h>
|
||||
#include <debugger/debuggerplugin.h>
|
||||
#include <debugger/debuggerruncontrol.h>
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -19,6 +23,7 @@
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <qmldebug/qmldebugcommandlinearguments.h>
|
||||
#include <qmldebug/qmloutputparser.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
@@ -46,15 +51,14 @@ using namespace Debugger;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
namespace Ios::Internal {
|
||||
|
||||
static void stopRunningRunControl(RunControl *runControl)
|
||||
{
|
||||
static QMap<Utils::Id, QPointer<RunControl>> activeRunControls;
|
||||
static QMap<Id, QPointer<RunControl>> activeRunControls;
|
||||
|
||||
Target *target = runControl->target();
|
||||
Utils::Id devId = DeviceKitAspect::deviceId(target->kit());
|
||||
Id devId = DeviceKitAspect::deviceId(target->kit());
|
||||
|
||||
// The device can only run an application at a time, if an app is running stop it.
|
||||
if (activeRunControls.contains(devId)) {
|
||||
@@ -67,6 +71,59 @@ static void stopRunningRunControl(RunControl *runControl)
|
||||
activeRunControls[devId] = runControl;
|
||||
}
|
||||
|
||||
class IosRunner : public RunWorker
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Ios::Internal::IosRunner)
|
||||
|
||||
public:
|
||||
IosRunner(RunControl *runControl);
|
||||
~IosRunner() override;
|
||||
|
||||
void setCppDebugging(bool cppDebug);
|
||||
void setQmlDebugging(QmlDebug::QmlDebugServicesPreset qmlDebugServices);
|
||||
|
||||
QString bundlePath();
|
||||
QString deviceId();
|
||||
IosToolHandler::RunKind runType();
|
||||
bool cppDebug() const;
|
||||
bool qmlDebug() const;
|
||||
QmlDebug::QmlDebugServicesPreset qmlDebugServices() const;
|
||||
|
||||
void start() override;
|
||||
void stop() final;
|
||||
|
||||
virtual void appOutput(const QString &/*output*/) {}
|
||||
virtual void errorMsg(const QString &/*msg*/) {}
|
||||
virtual void onStart() { reportStarted(); }
|
||||
|
||||
Port qmlServerPort() const;
|
||||
Port gdbServerPort() const;
|
||||
qint64 pid() const;
|
||||
bool isAppRunning() const;
|
||||
|
||||
private:
|
||||
void handleGotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, Port gdbPort, Port qmlPort);
|
||||
void handleGotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, qint64 pid);
|
||||
void handleAppOutput(Ios::IosToolHandler *handler, const QString &output);
|
||||
void handleErrorMsg(Ios::IosToolHandler *handler, const QString &msg);
|
||||
void handleToolExited(Ios::IosToolHandler *handler, int code);
|
||||
void handleFinished(Ios::IosToolHandler *handler);
|
||||
|
||||
IosToolHandler *m_toolHandler = nullptr;
|
||||
QString m_bundleDir;
|
||||
IDeviceConstPtr m_device;
|
||||
IosDeviceType m_deviceType;
|
||||
bool m_cppDebug = false;
|
||||
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices = QmlDebug::NoQmlDebugServices;
|
||||
|
||||
bool m_cleanExit = false;
|
||||
Port m_qmlServerPort;
|
||||
Port m_gdbServerPort;
|
||||
qint64 m_pid = 0;
|
||||
};
|
||||
|
||||
IosRunner::IosRunner(RunControl *runControl)
|
||||
: RunWorker(runControl)
|
||||
{
|
||||
@@ -312,12 +369,12 @@ bool IosRunner::isAppRunning() const
|
||||
return m_toolHandler && m_toolHandler->isRunning();
|
||||
}
|
||||
|
||||
Utils::Port IosRunner::gdbServerPort() const
|
||||
Port IosRunner::gdbServerPort() const
|
||||
{
|
||||
return m_gdbServerPort;
|
||||
}
|
||||
|
||||
Utils::Port IosRunner::qmlServerPort() const
|
||||
Port IosRunner::qmlServerPort() const
|
||||
{
|
||||
return m_qmlServerPort;
|
||||
}
|
||||
@@ -326,6 +383,19 @@ Utils::Port IosRunner::qmlServerPort() const
|
||||
// IosRunner
|
||||
//
|
||||
|
||||
class IosRunSupport : public IosRunner
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Ios::Internal::IosRunSupport)
|
||||
|
||||
public:
|
||||
explicit IosRunSupport(RunControl *runControl);
|
||||
~IosRunSupport() override;
|
||||
|
||||
void didStartApp(IosToolHandler::OpStatus status);
|
||||
private:
|
||||
void start() override;
|
||||
};
|
||||
|
||||
IosRunSupport::IosRunSupport(RunControl *runControl)
|
||||
: IosRunner(runControl)
|
||||
{
|
||||
@@ -350,6 +420,19 @@ void IosRunSupport::start()
|
||||
// IosQmlProfilerSupport
|
||||
//
|
||||
|
||||
class IosQmlProfilerSupport : public RunWorker
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Ios::Internal::IosQmlProfilerSupport)
|
||||
|
||||
public:
|
||||
IosQmlProfilerSupport(RunControl *runControl);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
IosRunner *m_runner = nullptr;
|
||||
RunWorker *m_profiler = nullptr;
|
||||
};
|
||||
|
||||
IosQmlProfilerSupport::IosQmlProfilerSupport(RunControl *runControl)
|
||||
: RunWorker(runControl)
|
||||
{
|
||||
@@ -386,8 +469,22 @@ void IosQmlProfilerSupport::start()
|
||||
// IosDebugSupport
|
||||
//
|
||||
|
||||
class IosDebugSupport : public DebuggerRunTool
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Ios::Internal::IosDebugSupport)
|
||||
|
||||
public:
|
||||
IosDebugSupport(RunControl *runControl);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
|
||||
const QString m_dumperLib;
|
||||
IosRunner *m_runner;
|
||||
};
|
||||
|
||||
IosDebugSupport::IosDebugSupport(RunControl *runControl)
|
||||
: Debugger::DebuggerRunTool(runControl)
|
||||
: DebuggerRunTool(runControl)
|
||||
{
|
||||
setId("IosDebugSupport");
|
||||
|
||||
@@ -440,8 +537,8 @@ void IosDebugSupport::start()
|
||||
setRunControlName(data->applicationName);
|
||||
setContinueAfterAttach(true);
|
||||
|
||||
Utils::Port gdbServerPort = m_runner->gdbServerPort();
|
||||
Utils::Port qmlServerPort = m_runner->qmlServerPort();
|
||||
Port gdbServerPort = m_runner->gdbServerPort();
|
||||
Port qmlServerPort = m_runner->qmlServerPort();
|
||||
setAttachPid(ProcessHandle(m_runner->pid()));
|
||||
|
||||
const bool cppDebug = isCppDebugging();
|
||||
@@ -480,5 +577,27 @@ void IosDebugSupport::start()
|
||||
DebuggerRunTool::start();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
// Factories
|
||||
|
||||
IosRunWorkerFactory::IosRunWorkerFactory()
|
||||
{
|
||||
setProduct<IosRunSupport>();
|
||||
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
||||
addSupportedRunConfig(Constants::IOS_RUNCONFIG_ID);
|
||||
}
|
||||
|
||||
IosDebugWorkerFactory::IosDebugWorkerFactory()
|
||||
{
|
||||
setProduct<IosDebugSupport>();
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
addSupportedRunConfig(Constants::IOS_RUNCONFIG_ID);
|
||||
}
|
||||
|
||||
IosQmlProfilerWorkerFactory::IosQmlProfilerWorkerFactory()
|
||||
{
|
||||
setProduct<IosQmlProfilerSupport>();
|
||||
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
addSupportedRunConfig(Constants::IOS_RUNCONFIG_ID);
|
||||
}
|
||||
|
||||
} // Ios::Internal
|
||||
|
@@ -3,116 +3,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "iostoolhandler.h"
|
||||
#include "iossimulator.h"
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
|
||||
#include <debugger/debuggerconstants.h>
|
||||
#include <debugger/debuggerruncontrol.h>
|
||||
namespace Ios::Internal {
|
||||
|
||||
#include <projectexplorer/devicesupport/idevicefwd.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
#include <qmldebug/qmldebugcommandlinearguments.h>
|
||||
#include <qmldebug/qmloutputparser.h>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
|
||||
class IosRunner : public ProjectExplorer::RunWorker
|
||||
class IosRunWorkerFactory final : public ProjectExplorer::RunWorkerFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IosRunner(ProjectExplorer::RunControl *runControl);
|
||||
~IosRunner() override;
|
||||
|
||||
void setCppDebugging(bool cppDebug);
|
||||
void setQmlDebugging(QmlDebug::QmlDebugServicesPreset qmlDebugServices);
|
||||
|
||||
QString bundlePath();
|
||||
QString deviceId();
|
||||
IosToolHandler::RunKind runType();
|
||||
bool cppDebug() const;
|
||||
bool qmlDebug() const;
|
||||
QmlDebug::QmlDebugServicesPreset qmlDebugServices() const;
|
||||
|
||||
void start() override;
|
||||
void stop() final;
|
||||
|
||||
virtual void appOutput(const QString &/*output*/) {}
|
||||
virtual void errorMsg(const QString &/*msg*/) {}
|
||||
virtual void onStart() { reportStarted(); }
|
||||
|
||||
Utils::Port qmlServerPort() const;
|
||||
Utils::Port gdbServerPort() const;
|
||||
qint64 pid() const;
|
||||
bool isAppRunning() const;
|
||||
|
||||
private:
|
||||
void handleGotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, Utils::Port gdbPort, Utils::Port qmlPort);
|
||||
void handleGotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, qint64 pid);
|
||||
void handleAppOutput(Ios::IosToolHandler *handler, const QString &output);
|
||||
void handleErrorMsg(Ios::IosToolHandler *handler, const QString &msg);
|
||||
void handleToolExited(Ios::IosToolHandler *handler, int code);
|
||||
void handleFinished(Ios::IosToolHandler *handler);
|
||||
|
||||
IosToolHandler *m_toolHandler = nullptr;
|
||||
QString m_bundleDir;
|
||||
ProjectExplorer::IDeviceConstPtr m_device;
|
||||
IosDeviceType m_deviceType;
|
||||
bool m_cppDebug = false;
|
||||
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices = QmlDebug::NoQmlDebugServices;
|
||||
|
||||
bool m_cleanExit = false;
|
||||
Utils::Port m_qmlServerPort;
|
||||
Utils::Port m_gdbServerPort;
|
||||
qint64 m_pid = 0;
|
||||
IosRunWorkerFactory();
|
||||
};
|
||||
|
||||
|
||||
class IosRunSupport : public IosRunner
|
||||
class IosDebugWorkerFactory final : public ProjectExplorer::RunWorkerFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IosRunSupport(ProjectExplorer::RunControl *runControl);
|
||||
~IosRunSupport() override;
|
||||
|
||||
void didStartApp(IosToolHandler::OpStatus status);
|
||||
private:
|
||||
void start() override;
|
||||
IosDebugWorkerFactory();
|
||||
};
|
||||
|
||||
|
||||
class IosQmlProfilerSupport : public ProjectExplorer::RunWorker
|
||||
class IosQmlProfilerWorkerFactory final : public ProjectExplorer::RunWorkerFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IosQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
IosRunner *m_runner = nullptr;
|
||||
ProjectExplorer::RunWorker *m_profiler = nullptr;
|
||||
IosQmlProfilerWorkerFactory();
|
||||
};
|
||||
|
||||
|
||||
class IosDebugSupport : public Debugger::DebuggerRunTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IosDebugSupport(ProjectExplorer::RunControl *runControl);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
|
||||
const QString m_dumperLib;
|
||||
IosRunner *m_runner;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
} // Ios::Internal
|
||||
|
Reference in New Issue
Block a user