diff --git a/src/plugins/ios/iosconstants.h b/src/plugins/ios/iosconstants.h index 1984672c5e9..12f2f4ef739 100644 --- a/src/plugins/ios/iosconstants.h +++ b/src/plugins/ios/iosconstants.h @@ -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 diff --git a/src/plugins/ios/iosplugin.cpp b/src/plugins/ios/iosplugin.cpp index 3b37bcf9f42..420ec42488d 100644 --- a/src/plugins/ios/iosplugin.cpp +++ b/src/plugins/ios/iosplugin.cpp @@ -21,13 +21,10 @@ #include #include -#include - 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(), - {ProjectExplorer::Constants::NORMAL_RUN_MODE}, - {runConfigurationFactory.runConfigurationId()} - }; - RunWorkerFactory debugWorkerFactory{ - RunWorkerFactory::make(), - {ProjectExplorer::Constants::DEBUG_RUN_MODE}, - {runConfigurationFactory.runConfigurationId()} - }; - RunWorkerFactory qmlProfilerWorkerFactory{ - RunWorkerFactory::make(), - {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 diff --git a/src/plugins/ios/iosplugin.h b/src/plugins/ios/iosplugin.h index 376a962b9bc..0e06fc198af 100644 --- a/src/plugins/ios/iosplugin.h +++ b/src/plugins/ios/iosplugin.h @@ -5,8 +5,7 @@ #include -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 diff --git a/src/plugins/ios/iosrunconfiguration.cpp b/src/plugins/ios/iosrunconfiguration.cpp index d232e8daff0..84e0910ca96 100644 --- a/src/plugins/ios/iosrunconfiguration.cpp +++ b/src/plugins/ios/iosrunconfiguration.cpp @@ -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("Qt4ProjectManager.IosRunConfiguration:"); + registerRunConfiguration(Constants::IOS_RUNCONFIG_ID); addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE); addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE); } -} // namespace Internal -} // namespace Ios +} // Ios::Internal diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index edf648669a1..58be6d82e07 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -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 +#include #include +#include +#include #include #include @@ -19,6 +23,7 @@ #include #include +#include #include #include @@ -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> activeRunControls; + static QMap> 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(); + addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE); + addSupportedRunConfig(Constants::IOS_RUNCONFIG_ID); +} + +IosDebugWorkerFactory::IosDebugWorkerFactory() +{ + setProduct(); + addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE); + addSupportedRunConfig(Constants::IOS_RUNCONFIG_ID); +} + +IosQmlProfilerWorkerFactory::IosQmlProfilerWorkerFactory() +{ + setProduct(); + addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); + addSupportedRunConfig(Constants::IOS_RUNCONFIG_ID); +} + +} // Ios::Internal diff --git a/src/plugins/ios/iosrunner.h b/src/plugins/ios/iosrunner.h index 48d1af29ebd..42a1a6f4715 100644 --- a/src/plugins/ios/iosrunner.h +++ b/src/plugins/ios/iosrunner.h @@ -3,116 +3,26 @@ #pragma once -#include "iostoolhandler.h" -#include "iossimulator.h" +#include -#include -#include +namespace Ios::Internal { -#include -#include - -#include -#include - -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