Boot2Qt: Use dedicated classes for run worker factories

Change-Id: Ibe060ab15e57014866e8fa1311c1441238f81c7e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-01-06 16:58:53 +01:00
parent aff6c4b2d2
commit bb6764d065
3 changed files with 114 additions and 74 deletions

View File

@@ -7,6 +7,10 @@
#include "qdbdevice.h"
#include "qdbrunconfiguration.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <debugger/debuggerruncontrol.h>
#include <utils/algorithm.h>
@@ -16,9 +20,8 @@
using namespace Debugger;
using namespace ProjectExplorer;
using namespace Utils;
using namespace Qdb::Internal;
namespace Qdb {
namespace Qdb::Internal {
class QdbDeviceInferiorRunner : public RunWorker
{
@@ -113,9 +116,40 @@ private:
QtcProcess m_launcher;
};
// QdbDeviceRunSupport
class QdbDeviceRunSupport : public SimpleTargetRunner
{
public:
QdbDeviceRunSupport(RunControl *runControl)
: SimpleTargetRunner(runControl)
{
setStartModifier([this] {
const CommandLine remoteCommand = commandLine();
const FilePath remoteExe = remoteCommand.executable();
CommandLine cmd{remoteExe.withNewPath(Constants::AppcontrollerFilepath)};
cmd.addArg(remoteExe.nativePath());
cmd.addArgs(remoteCommand.arguments(), CommandLine::Raw);
setCommandLine(cmd);
});
}
};
// QdbDeviceDebugSupport
class QdbDeviceDebugSupport final : public Debugger::DebuggerRunTool
{
public:
explicit QdbDeviceDebugSupport(RunControl *runControl);
private:
void start() override;
void stop() override;
QdbDeviceInferiorRunner *m_debuggee = nullptr;
};
QdbDeviceDebugSupport::QdbDeviceDebugSupport(RunControl *runControl)
: Debugger::DebuggerRunTool(runControl)
{
@@ -150,6 +184,18 @@ void QdbDeviceDebugSupport::stop()
// QdbDeviceQmlProfilerSupport
class QdbDeviceQmlToolingSupport final : public RunWorker
{
public:
explicit QdbDeviceQmlToolingSupport(RunControl *runControl);
private:
void start() override;
QdbDeviceInferiorRunner *m_runner = nullptr;
RunWorker *m_worker = nullptr;
};
QdbDeviceQmlToolingSupport::QdbDeviceQmlToolingSupport(RunControl *runControl)
: RunWorker(runControl)
{
@@ -173,6 +219,17 @@ void QdbDeviceQmlToolingSupport::start()
// QdbDevicePerfProfilerSupport
class QdbDevicePerfProfilerSupport final : public RunWorker
{
public:
explicit QdbDevicePerfProfilerSupport(RunControl *runControl);
private:
void start() override;
QdbDeviceInferiorRunner *m_profilee = nullptr;
};
QdbDevicePerfProfilerSupport::QdbDevicePerfProfilerSupport(RunControl *runControl)
: RunWorker(runControl)
{
@@ -190,4 +247,38 @@ void QdbDevicePerfProfilerSupport::start()
reportStarted();
}
} // namespace Qdb
// Factories
QdbRunWorkerFactory::QdbRunWorkerFactory(const QList<Id> &runConfigs)
{
setProduct<QdbDeviceRunSupport>();
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
setSupportedRunConfigs(runConfigs);
addSupportedDeviceType(Qdb::Constants::QdbLinuxOsType);
}
QdbDebugWorkerFactory::QdbDebugWorkerFactory(const QList<Id> &runConfigs)
{
setProduct<QdbDeviceDebugSupport>();
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
setSupportedRunConfigs(runConfigs);
addSupportedDeviceType(Qdb::Constants::QdbLinuxOsType);
}
QdbQmlToolingWorkerFactory::QdbQmlToolingWorkerFactory(const QList<Id> &runConfigs)
{
setProduct<QdbDeviceQmlToolingSupport>();
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE);
setSupportedRunConfigs(runConfigs);
addSupportedDeviceType(Qdb::Constants::QdbLinuxOsType);
}
QdbPerfProfilerWorkerFactory::QdbPerfProfilerWorkerFactory()
{
setProduct<QdbDevicePerfProfilerSupport>();
addSupportedRunMode("PerfRecorder");
addSupportedDeviceType(Qdb::Constants::QdbLinuxOsType);
}
} // Qdb::Internal

View File

@@ -3,46 +3,32 @@
#pragma once
#include <debugger/debuggerruncontrol.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <projectexplorer/runcontrol.h>
namespace Qdb {
namespace Qdb::Internal {
class QdbDeviceInferiorRunner;
class QdbDeviceDebugSupport : public Debugger::DebuggerRunTool
class QdbRunWorkerFactory final : public ProjectExplorer::RunWorkerFactory
{
public:
QdbDeviceDebugSupport(ProjectExplorer::RunControl *runControl);
private:
void start();
void stop();
QdbDeviceInferiorRunner *m_debuggee = nullptr;
explicit QdbRunWorkerFactory(const QList<Utils::Id> &runConfigs);
};
class QdbDeviceQmlToolingSupport : public ProjectExplorer::RunWorker
class QdbDebugWorkerFactory final : public ProjectExplorer::RunWorkerFactory
{
public:
QdbDeviceQmlToolingSupport(ProjectExplorer::RunControl *runControl);
private:
void start() override;
QdbDeviceInferiorRunner *m_runner = nullptr;
ProjectExplorer::RunWorker *m_worker = nullptr;
explicit QdbDebugWorkerFactory(const QList<Utils::Id> &runConfigs);
};
class QdbDevicePerfProfilerSupport : public ProjectExplorer::RunWorker
class QdbQmlToolingWorkerFactory final : public ProjectExplorer::RunWorkerFactory
{
public:
QdbDevicePerfProfilerSupport(ProjectExplorer::RunControl *runControl);
private:
void start() override;
QdbDeviceInferiorRunner *m_profilee = nullptr;
explicit QdbQmlToolingWorkerFactory(const QList<Utils::Id> &runConfigs);
};
} // namespace Qdb
class QdbPerfProfilerWorkerFactory final : public ProjectExplorer::RunWorkerFactory
{
public:
QdbPerfProfilerWorkerFactory();
};
} // Qdb::Internal

View File

@@ -19,6 +19,7 @@
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtversionfactory.h>
@@ -114,23 +115,6 @@ public:
}
};
class QdbDeviceRunSupport : public SimpleTargetRunner
{
public:
QdbDeviceRunSupport(RunControl *runControl)
: SimpleTargetRunner(runControl)
{
setStartModifier([this] {
const CommandLine remoteCommand = commandLine();
const FilePath remoteExe = remoteCommand.executable();
CommandLine cmd{remoteExe.withNewPath(Constants::AppcontrollerFilepath)};
cmd.addArg(remoteExe.nativePath());
cmd.addArgs(remoteCommand.arguments(), CommandLine::Raw);
setCommandLine(cmd);
});
}
};
template <class Step>
class QdbDeployStepFactory : public ProjectExplorer::BuildStepFactory
{
@@ -168,31 +152,10 @@ public:
"QmlProjectManager.QmlRunConfiguration"
};
RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<QdbDeviceRunSupport>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
supportedRunConfigs,
{Qdb::Constants::QdbLinuxOsType}
};
RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<QdbDeviceDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE},
supportedRunConfigs,
{Qdb::Constants::QdbLinuxOsType}
};
RunWorkerFactory qmlToolWorkerFactory{
RunWorkerFactory::make<QdbDeviceQmlToolingSupport>(),
{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE,
ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE},
supportedRunConfigs,
{Qdb::Constants::QdbLinuxOsType}
};
RunWorkerFactory perfRecorderFactory{
RunWorkerFactory::make<QdbDevicePerfProfilerSupport>(),
{"PerfRecorder"},
{},
{Qdb::Constants::QdbLinuxOsType}
};
QdbRunWorkerFactory runWorkerFactory{supportedRunConfigs};
QdbDebugWorkerFactory debugWorkerFactory{supportedRunConfigs};
QdbQmlToolingWorkerFactory qmlToolingWorkerFactory{supportedRunConfigs};
QdbPerfProfilerWorkerFactory perfRecorderWorkerFactory;
DeviceDetector m_deviceDetector;
};