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:
hjk
2023-01-06 15:54:09 +01:00
parent c6471341f6
commit ac5db86129
6 changed files with 153 additions and 144 deletions

View File

@@ -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_PRESET_BUILD_STEP_ID[] = "Ios.IosPresetBuildStep";
const char IOS_DSYM_BUILD_STEP_ID[] = "Ios.IosDsymBuildStep"; const char IOS_DSYM_BUILD_STEP_ID[] = "Ios.IosDsymBuildStep";
const char IOS_DEPLOY_STEP_ID[] = "Qt4ProjectManager.IosDeployStep"; const char IOS_DEPLOY_STEP_ID[] = "Qt4ProjectManager.IosDeployStep";
const char IOS_RUNCONFIG_ID[] = "Qt4ProjectManager.IosRunConfiguration:";
const char IosTarget[] = "IosTarget"; // QString const char IosTarget[] = "IosTarget"; // QString
const char IosBuildDir[] = "IosBuildDir"; // QString const char IosBuildDir[] = "IosBuildDir"; // QString

View File

@@ -21,13 +21,10 @@
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace QtSupport; using namespace QtSupport;
namespace Ios { namespace Ios::Internal {
namespace Internal {
Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common", QtWarningMsg) Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common", QtWarningMsg)
@@ -59,22 +56,9 @@ public:
IosDeployStepFactory deployStepFactory; IosDeployStepFactory deployStepFactory;
IosDsymBuildStepFactory dsymBuildStepFactory; IosDsymBuildStepFactory dsymBuildStepFactory;
IosDeployConfigurationFactory deployConfigurationFactory; IosDeployConfigurationFactory deployConfigurationFactory;
IosRunWorkerFactory runWorkerFactory;
RunWorkerFactory runWorkerFactory{ IosDebugWorkerFactory debugWorkerFactory;
RunWorkerFactory::make<IosRunSupport>(), IosQmlProfilerWorkerFactory qmlProfilerWorkerFactory;
{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()}
};
}; };
IosPlugin::~IosPlugin() IosPlugin::~IosPlugin()
@@ -96,5 +80,4 @@ bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage)
return true; return true;
} }
} // namespace Internal } // Internal::Ios
} // namespace Ios

View File

@@ -5,8 +5,7 @@
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
namespace Ios { namespace Ios::Internal {
namespace Internal {
class IosPlugin final : public ExtensionSystem::IPlugin class IosPlugin final : public ExtensionSystem::IPlugin
{ {
@@ -23,5 +22,4 @@ private:
class IosPluginPrivate *d = nullptr; class IosPluginPrivate *d = nullptr;
}; };
} // namespace Internal } // Ios::Internal
} // namespace Ios

View File

@@ -36,8 +36,7 @@
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace Ios { namespace Ios::Internal {
namespace Internal {
static const QLatin1String deviceTypeKey("Ios.device_type"); static const QLatin1String deviceTypeKey("Ios.device_type");
@@ -403,10 +402,9 @@ FilePath IosDeviceTypeAspect::localExecutable() const
IosRunConfigurationFactory::IosRunConfigurationFactory() IosRunConfigurationFactory::IosRunConfigurationFactory()
{ {
registerRunConfiguration<IosRunConfiguration>("Qt4ProjectManager.IosRunConfiguration:"); registerRunConfiguration<IosRunConfiguration>(Constants::IOS_RUNCONFIG_ID);
addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE); addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE);
addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE); addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE);
} }
} // namespace Internal } // Ios::Internal
} // namespace Ios

View File

@@ -1,15 +1,19 @@
// Copyright (C) 2016 The Qt Company Ltd. // Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "iosrunner.h"
#include "iosconfigurations.h" #include "iosconfigurations.h"
#include "iosconstants.h"
#include "iosdevice.h" #include "iosdevice.h"
#include "iosrunconfiguration.h" #include "iosrunconfiguration.h"
#include "iosrunner.h"
#include "iossimulator.h" #include "iossimulator.h"
#include "iosconstants.h" #include "iostoolhandler.h"
#include <debugger/debuggerplugin.h> #include <debugger/debuggerconstants.h>
#include <debugger/debuggerkitinformation.h> #include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerruncontrol.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -19,6 +23,7 @@
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <qmldebug/qmldebugcommandlinearguments.h> #include <qmldebug/qmldebugcommandlinearguments.h>
#include <qmldebug/qmloutputparser.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
@@ -46,15 +51,14 @@ using namespace Debugger;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace Ios { namespace Ios::Internal {
namespace Internal {
static void stopRunningRunControl(RunControl *runControl) static void stopRunningRunControl(RunControl *runControl)
{ {
static QMap<Utils::Id, QPointer<RunControl>> activeRunControls; static QMap<Id, QPointer<RunControl>> activeRunControls;
Target *target = runControl->target(); 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. // The device can only run an application at a time, if an app is running stop it.
if (activeRunControls.contains(devId)) { if (activeRunControls.contains(devId)) {
@@ -67,6 +71,59 @@ static void stopRunningRunControl(RunControl *runControl)
activeRunControls[devId] = 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) IosRunner::IosRunner(RunControl *runControl)
: RunWorker(runControl) : RunWorker(runControl)
{ {
@@ -312,12 +369,12 @@ bool IosRunner::isAppRunning() const
return m_toolHandler && m_toolHandler->isRunning(); return m_toolHandler && m_toolHandler->isRunning();
} }
Utils::Port IosRunner::gdbServerPort() const Port IosRunner::gdbServerPort() const
{ {
return m_gdbServerPort; return m_gdbServerPort;
} }
Utils::Port IosRunner::qmlServerPort() const Port IosRunner::qmlServerPort() const
{ {
return m_qmlServerPort; return m_qmlServerPort;
} }
@@ -326,6 +383,19 @@ Utils::Port IosRunner::qmlServerPort() const
// IosRunner // 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) IosRunSupport::IosRunSupport(RunControl *runControl)
: IosRunner(runControl) : IosRunner(runControl)
{ {
@@ -350,6 +420,19 @@ void IosRunSupport::start()
// IosQmlProfilerSupport // 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) IosQmlProfilerSupport::IosQmlProfilerSupport(RunControl *runControl)
: RunWorker(runControl) : RunWorker(runControl)
{ {
@@ -386,8 +469,22 @@ void IosQmlProfilerSupport::start()
// IosDebugSupport // 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) IosDebugSupport::IosDebugSupport(RunControl *runControl)
: Debugger::DebuggerRunTool(runControl) : DebuggerRunTool(runControl)
{ {
setId("IosDebugSupport"); setId("IosDebugSupport");
@@ -440,8 +537,8 @@ void IosDebugSupport::start()
setRunControlName(data->applicationName); setRunControlName(data->applicationName);
setContinueAfterAttach(true); setContinueAfterAttach(true);
Utils::Port gdbServerPort = m_runner->gdbServerPort(); Port gdbServerPort = m_runner->gdbServerPort();
Utils::Port qmlServerPort = m_runner->qmlServerPort(); Port qmlServerPort = m_runner->qmlServerPort();
setAttachPid(ProcessHandle(m_runner->pid())); setAttachPid(ProcessHandle(m_runner->pid()));
const bool cppDebug = isCppDebugging(); const bool cppDebug = isCppDebugging();
@@ -480,5 +577,27 @@ void IosDebugSupport::start()
DebuggerRunTool::start(); DebuggerRunTool::start();
} }
} // namespace Internal // Factories
} // namespace Ios
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

View File

@@ -3,116 +3,26 @@
#pragma once #pragma once
#include "iostoolhandler.h" #include <projectexplorer/runcontrol.h>
#include "iossimulator.h"
#include <debugger/debuggerconstants.h> namespace Ios::Internal {
#include <debugger/debuggerruncontrol.h>
#include <projectexplorer/devicesupport/idevicefwd.h> class IosRunWorkerFactory final : public ProjectExplorer::RunWorkerFactory
#include <projectexplorer/runconfiguration.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <qmldebug/qmloutputparser.h>
namespace Ios {
namespace Internal {
class IosRunner : public ProjectExplorer::RunWorker
{ {
Q_OBJECT
public: public:
IosRunner(ProjectExplorer::RunControl *runControl); IosRunWorkerFactory();
~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;
}; };
class IosDebugWorkerFactory final : public ProjectExplorer::RunWorkerFactory
class IosRunSupport : public IosRunner
{ {
Q_OBJECT
public: public:
explicit IosRunSupport(ProjectExplorer::RunControl *runControl); IosDebugWorkerFactory();
~IosRunSupport() override;
void didStartApp(IosToolHandler::OpStatus status);
private:
void start() override;
}; };
class IosQmlProfilerWorkerFactory final : public ProjectExplorer::RunWorkerFactory
class IosQmlProfilerSupport : public ProjectExplorer::RunWorker
{ {
Q_OBJECT
public: public:
IosQmlProfilerSupport(ProjectExplorer::RunControl *runControl); IosQmlProfilerWorkerFactory();
private:
void start() override;
IosRunner *m_runner = nullptr;
ProjectExplorer::RunWorker *m_profiler = nullptr;
}; };
} // Ios::Internal
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