Create RunConfiguration specific DebugWorkerFactories

Instead of relying on the DebuggerRunWorkerFactory to match for all
RunConfiguration, every plugin needs to create a WorkerFactory for
its own RunConfiguration.

Similar to the SimpleTargetRunnerFactory there is now a
SimpleDebugRunnerFactory which makes the setup easy.

Change-Id: I25aaabcd70f7ac649baeab4eb4c7e88d53dac91e
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Dominik Holland
2024-01-12 14:04:37 +01:00
parent 5af310b4fb
commit c81efc39c8
12 changed files with 72 additions and 9 deletions

View File

@@ -14,6 +14,8 @@ const char MODE_DEBUG[] = "Mode.Debug";
// Debug mode context // Debug mode context
const char C_DEBUGMODE[] = "Debugger.DebugMode"; const char C_DEBUGMODE[] = "Debugger.DebugMode";
const char DEBUGGER_RUN_FACTORY[] = "RunWorkerFactory.DebuggerRunWorkerFactory";
} // namespace Constants } // namespace Constants
// Keep in sync with dumper.py // Keep in sync with dumper.py

View File

@@ -1092,12 +1092,15 @@ void DebugServerRunner::setAttachPid(ProcessHandle pid)
DebuggerRunWorkerFactory::DebuggerRunWorkerFactory() DebuggerRunWorkerFactory::DebuggerRunWorkerFactory()
{ {
setProduct<DebuggerRunTool>(); setProduct<DebuggerRunTool>();
setId(Constants::DEBUGGER_RUN_FACTORY);
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE); addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
addSupportedRunMode(ProjectExplorer::Constants::DAP_CMAKE_DEBUG_RUN_MODE); addSupportedRunMode(ProjectExplorer::Constants::DAP_CMAKE_DEBUG_RUN_MODE);
addSupportedRunMode(ProjectExplorer::Constants::DAP_GDB_DEBUG_RUN_MODE); addSupportedRunMode(ProjectExplorer::Constants::DAP_GDB_DEBUG_RUN_MODE);
addSupportedRunMode(ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE);
addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
addSupportedDeviceType("DockerDeviceType"); addSupportedDeviceType("DockerDeviceType");
addSupportedRunConfig(ProjectExplorer::Constants::QMAKE_RUNCONFIG_ID);
addSupportedRunConfig(ProjectExplorer::Constants::QBS_RUNCONFIG_ID);
addSupportedRunConfig(ProjectExplorer::Constants::CMAKE_RUNCONFIG_ID);
} }
} // Debugger } // Debugger

View File

@@ -8,6 +8,7 @@
#include "debuggerengine.h" #include "debuggerengine.h"
#include "terminal.h" #include "terminal.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h> #include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
@@ -160,6 +161,19 @@ public:
DebuggerRunWorkerFactory(); DebuggerRunWorkerFactory();
}; };
class SimpleDebugRunnerFactory final : public ProjectExplorer::RunWorkerFactory
{
public:
explicit SimpleDebugRunnerFactory(const QList<Utils::Id> &runConfigs, const QList<Utils::Id> &extraRunModes = {})
{
cloneProduct(Constants::DEBUGGER_RUN_FACTORY);
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
for (const Utils::Id &id : extraRunModes)
addSupportedRunMode(id);
setSupportedRunConfigs(runConfigs);
}
};
extern DEBUGGER_EXPORT const char DebugServerRunnerWorkerId[]; extern DEBUGGER_EXPORT const char DebugServerRunnerWorkerId[];
extern DEBUGGER_EXPORT const char GdbServerPortGathererWorkerId[]; extern DEBUGGER_EXPORT const char GdbServerPortGathererWorkerId[];

View File

@@ -7,6 +7,8 @@
#include "haskelltr.h" #include "haskelltr.h"
#include "haskellsettings.h" #include "haskellsettings.h"
#include <debugger/debuggerruncontrol.h>
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsystem.h> #include <projectexplorer/buildsystem.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -18,6 +20,7 @@
#include <utils/processinterface.h> #include <utils/processinterface.h>
using namespace Debugger;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
@@ -92,6 +95,7 @@ void setupHaskellRunSupport()
{ {
static HaskellRunConfigurationFactory runConfigFactory; static HaskellRunConfigurationFactory runConfigFactory;
static SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}}; static SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
static SimpleDebugRunnerFactory debugWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
} }
} // Haskell::Internal } // Haskell::Internal

View File

@@ -10,6 +10,8 @@
#include "toolssettingsaccessor.h" #include "toolssettingsaccessor.h"
#include "toolssettingspage.h" #include "toolssettingspage.h"
#include <debugger/debuggerruncontrol.h>
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -18,6 +20,7 @@
#include <utils/fsengine/fileiconprovider.h> #include <utils/fsengine/fileiconprovider.h>
using namespace Debugger;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
@@ -34,6 +37,7 @@ public:
MesonActionsManager m_actions; MesonActionsManager m_actions;
MachineFileManager m_machineFilesManager; MachineFileManager m_machineFilesManager;
SimpleTargetRunnerFactory m_mesonRunWorkerFactory{{m_runConfigurationFactory.runConfigurationId()}}; SimpleTargetRunnerFactory m_mesonRunWorkerFactory{{m_runConfigurationFactory.runConfigurationId()}};
SimpleDebugRunnerFactory m_mesonDebugRunWorkerFactory{{m_runConfigurationFactory.runConfigurationId()}};
}; };
class MesonProjectPlugin final : public ExtensionSystem::IPlugin class MesonProjectPlugin final : public ExtensionSystem::IPlugin

View File

@@ -21,6 +21,8 @@
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <debugger/debuggerruncontrol.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runcontrol.h> #include <projectexplorer/runcontrol.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
@@ -32,6 +34,7 @@
#include <utils/icon.h> #include <utils/icon.h>
#include <utils/theme/theme.h> #include <utils/theme/theme.h>
using namespace Debugger;
using namespace Utils; using namespace Utils;
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -48,6 +51,8 @@ public:
NimbleTestConfigurationFactory nimbleTestConfigFactory; NimbleTestConfigurationFactory nimbleTestConfigFactory;
SimpleTargetRunnerFactory nimRunWorkerFactory{{nimRunConfigFactory.runConfigurationId()}}; SimpleTargetRunnerFactory nimRunWorkerFactory{{nimRunConfigFactory.runConfigurationId()}};
SimpleTargetRunnerFactory nimbleRunWorkerFactory{{nimbleRunConfigFactory.runConfigurationId()}}; SimpleTargetRunnerFactory nimbleRunWorkerFactory{{nimbleRunConfigFactory.runConfigurationId()}};
SimpleDebugRunnerFactory nimDebugWorkerFactory{{nimRunConfigFactory.runConfigurationId()}};
SimpleDebugRunnerFactory nimbleDebugWorkerFactory{{nimbleRunConfigFactory.runConfigurationId()}};
SimpleTargetRunnerFactory nimbleTestWorkerFactory{{nimbleTestConfigFactory.runConfigurationId()}}; SimpleTargetRunnerFactory nimbleTestWorkerFactory{{nimbleTestConfigFactory.runConfigurationId()}};
NimbleBuildStepFactory nimbleBuildStepFactory; NimbleBuildStepFactory nimbleBuildStepFactory;
NimbleTaskStepFactory nimbleTaskStepFactory; NimbleTaskStepFactory nimbleTaskStepFactory;

View File

@@ -168,13 +168,9 @@ public:
{} {}
}; };
const char QMAKE_RUNCONFIG_ID[] = "Qt4ProjectManager.Qt4RunConfiguration:";
const char QBS_RUNCONFIG_ID[] = "Qbs.RunConfiguration:";
const char CMAKE_RUNCONFIG_ID[] = "CMakeProjectManager.CMakeRunConfiguration.";
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory() CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
{ {
registerRunConfiguration<CMakeRunConfiguration>(CMAKE_RUNCONFIG_ID); registerRunConfiguration<CMakeRunConfiguration>(ProjectExplorer::Constants::CMAKE_RUNCONFIG_ID);
addSupportedProjectType(CMakeProjectManager::Constants::CMAKE_PROJECT_ID); addSupportedProjectType(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE); addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE);
@@ -182,7 +178,7 @@ CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
QbsRunConfigurationFactory::QbsRunConfigurationFactory() QbsRunConfigurationFactory::QbsRunConfigurationFactory()
{ {
registerRunConfiguration<QbsRunConfiguration>(QBS_RUNCONFIG_ID); registerRunConfiguration<QbsRunConfiguration>(ProjectExplorer::Constants::QBS_RUNCONFIG_ID);
addSupportedProjectType(QbsProjectManager::Constants::PROJECT_ID); addSupportedProjectType(QbsProjectManager::Constants::PROJECT_ID);
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE); addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE);
@@ -190,7 +186,7 @@ QbsRunConfigurationFactory::QbsRunConfigurationFactory()
DesktopQmakeRunConfigurationFactory::DesktopQmakeRunConfigurationFactory() DesktopQmakeRunConfigurationFactory::DesktopQmakeRunConfigurationFactory()
{ {
registerRunConfiguration<DesktopQmakeRunConfiguration>(QMAKE_RUNCONFIG_ID); registerRunConfiguration<DesktopQmakeRunConfiguration>(ProjectExplorer::Constants::QMAKE_RUNCONFIG_ID);
addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID); addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE); addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE);

View File

@@ -176,6 +176,11 @@ const char QML_PREVIEW_RUNNER[]="RunConfiguration.QmlPreviewRunner";
const char PERFPROFILER_RUN_MODE[]="PerfProfiler.RunMode"; const char PERFPROFILER_RUN_MODE[]="PerfProfiler.RunMode";
const char PERFPROFILER_RUNNER[]="PerfProfiler.Runner"; const char PERFPROFILER_RUNNER[]="PerfProfiler.Runner";
// RunConfig
const char QMAKE_RUNCONFIG_ID[] = "Qt4ProjectManager.Qt4RunConfiguration:";
const char QBS_RUNCONFIG_ID[] = "Qbs.RunConfiguration:";
const char CMAKE_RUNCONFIG_ID[] = "CMakeProjectManager.CMakeRunConfiguration.";
// Navigation Widget // Navigation Widget
const char PROJECTTREE_ID[] = "Projects"; const char PROJECTTREE_ID[] = "Projects";

View File

@@ -98,6 +98,25 @@ void RunWorkerFactory::addSupportedDeviceType(Id deviceType)
m_supportedDeviceTypes.append(deviceType); m_supportedDeviceTypes.append(deviceType);
} }
void RunWorkerFactory::cloneProduct(Id exitstingStepId, Id overrideId)
{
for (RunWorkerFactory *factory : g_runWorkerFactories) {
if (factory->m_id == exitstingStepId) {
m_producer = factory->m_producer;
// Other bits are intentionally not copied as they are unlikely to be
// useful in the cloner's context. The cloner can/has to finish the
// setup on its own.
break;
}
}
// Existence should be guaranteed by plugin dependencies. In case it fails,
// bark and keep the factory in a state where the invalid m_stepId keeps it
// inaction.
QTC_ASSERT(m_producer, return);
if (overrideId.isValid())
m_id = overrideId;
}
bool RunWorkerFactory::canCreate(Id runMode, Id deviceType, const QString &runConfigId) const bool RunWorkerFactory::canCreate(Id runMode, Id deviceType, const QString &runConfigId) const
{ {
if (!m_supportedRunModes.contains(runMode)) if (!m_supportedRunModes.contains(runMode))

View File

@@ -107,11 +107,13 @@ public:
protected: protected:
template <typename Worker> template <typename Worker>
void setProduct() { setProducer([](RunControl *rc) { return new Worker(rc); }); } void setProduct() { setProducer([](RunControl *rc) { return new Worker(rc); }); }
void setId(Utils::Id id) { m_id = id; }
void setProducer(const WorkerCreator &producer); void setProducer(const WorkerCreator &producer);
void setSupportedRunConfigs(const QList<Utils::Id> &runConfigs); void setSupportedRunConfigs(const QList<Utils::Id> &runConfigs);
void addSupportedRunMode(Utils::Id runMode); void addSupportedRunMode(Utils::Id runMode);
void addSupportedRunConfig(Utils::Id runConfig); void addSupportedRunConfig(Utils::Id runConfig);
void addSupportedDeviceType(Utils::Id deviceType); void addSupportedDeviceType(Utils::Id deviceType);
void cloneProduct(Utils::Id exitstingStepId, Utils::Id overrideId = Utils::Id());
private: private:
friend class RunControl; friend class RunControl;
@@ -122,6 +124,7 @@ private:
QList<Utils::Id> m_supportedRunModes; QList<Utils::Id> m_supportedRunModes;
QList<Utils::Id> m_supportedRunConfigurations; QList<Utils::Id> m_supportedRunConfigurations;
QList<Utils::Id> m_supportedDeviceTypes; QList<Utils::Id> m_supportedDeviceTypes;
Utils::Id m_id;
}; };
/** /**

View File

@@ -13,6 +13,8 @@
#include "pythontr.h" #include "pythontr.h"
#include "pythonwizardpage.h" #include "pythonwizardpage.h"
#include <debugger/debuggerruncontrol.h>
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/buildtargetinfo.h>
@@ -25,6 +27,7 @@
#include <utils/fsengine/fileiconprovider.h> #include <utils/fsengine/fileiconprovider.h>
#include <utils/theme/theme.h> #include <utils/theme/theme.h>
using namespace Debugger;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
@@ -45,6 +48,7 @@ public:
PySideBuildStepFactory buildStepFactory; PySideBuildStepFactory buildStepFactory;
PythonBuildConfigurationFactory buildConfigFactory; PythonBuildConfigurationFactory buildConfigFactory;
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}}; SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
SimpleDebugRunnerFactory debugRunWorkerFactory{{runConfigFactory.runConfigurationId()}, {ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE}};
PythonSettings settings; PythonSettings settings;
PythonWizardPageFactory pythonWizardPageFactory; PythonWizardPageFactory pythonWizardPageFactory;
}; };
@@ -84,7 +88,7 @@ private:
{ {
// Add MIME overlay icons (these icons displayed at Project dock panel) // Add MIME overlay icons (these icons displayed at Project dock panel)
const QString imageFile = Utils::creatorTheme()->imageFile(Theme::IconOverlayPro, const QString imageFile = Utils::creatorTheme()->imageFile(Theme::IconOverlayPro,
::Constants::FILEOVERLAY_PY); ProjectExplorer::Constants::FILEOVERLAY_PY);
FileIconProvider::registerIconOverlayForSuffix(imageFile, "py"); FileIconProvider::registerIconOverlayForSuffix(imageFile, "py");
TaskHub::addCategory({PythonErrorTaskCategory, TaskHub::addCategory({PythonErrorTaskCategory,

View File

@@ -21,6 +21,8 @@
#include <coreplugin/messagebox.h> #include <coreplugin/messagebox.h>
#include <coreplugin/modemanager.h> #include <coreplugin/modemanager.h>
#include <debugger/debuggerruncontrol.h>
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -55,6 +57,7 @@
#include <QTimer> #include <QTimer>
using namespace Core; using namespace Core;
using namespace Debugger;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
@@ -97,6 +100,7 @@ class QmlProjectPluginPrivate
public: public:
QmlProjectRunConfigurationFactory runConfigFactory; QmlProjectRunConfigurationFactory runConfigFactory;
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}}; SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
SimpleDebugRunnerFactory debugRunWorkerFactory{{runConfigFactory.runConfigurationId()}};
QPointer<QMessageBox> lastMessageBox; QPointer<QMessageBox> lastMessageBox;
QdsLandingPage *landingPage = nullptr; QdsLandingPage *landingPage = nullptr;
QdsLandingPageWidget *landingPageWidget = nullptr; QdsLandingPageWidget *landingPageWidget = nullptr;