forked from qt-creator/qt-creator
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:
@@ -14,6 +14,8 @@ const char MODE_DEBUG[] = "Mode.Debug";
|
||||
// Debug mode context
|
||||
const char C_DEBUGMODE[] = "Debugger.DebugMode";
|
||||
|
||||
const char DEBUGGER_RUN_FACTORY[] = "RunWorkerFactory.DebuggerRunWorkerFactory";
|
||||
|
||||
} // namespace Constants
|
||||
|
||||
// Keep in sync with dumper.py
|
||||
|
@@ -1092,12 +1092,15 @@ void DebugServerRunner::setAttachPid(ProcessHandle pid)
|
||||
DebuggerRunWorkerFactory::DebuggerRunWorkerFactory()
|
||||
{
|
||||
setProduct<DebuggerRunTool>();
|
||||
setId(Constants::DEBUGGER_RUN_FACTORY);
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DAP_CMAKE_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("DockerDeviceType");
|
||||
addSupportedRunConfig(ProjectExplorer::Constants::QMAKE_RUNCONFIG_ID);
|
||||
addSupportedRunConfig(ProjectExplorer::Constants::QBS_RUNCONFIG_ID);
|
||||
addSupportedRunConfig(ProjectExplorer::Constants::CMAKE_RUNCONFIG_ID);
|
||||
}
|
||||
|
||||
} // Debugger
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "debuggerengine.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
|
||||
|
||||
@@ -160,6 +161,19 @@ public:
|
||||
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 GdbServerPortGathererWorkerId[];
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
#include "haskelltr.h"
|
||||
#include "haskellsettings.h"
|
||||
|
||||
#include <debugger/debuggerruncontrol.h>
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/project.h>
|
||||
@@ -18,6 +20,7 @@
|
||||
|
||||
#include <utils/processinterface.h>
|
||||
|
||||
using namespace Debugger;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -92,6 +95,7 @@ void setupHaskellRunSupport()
|
||||
{
|
||||
static HaskellRunConfigurationFactory runConfigFactory;
|
||||
static SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
|
||||
static SimpleDebugRunnerFactory debugWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
|
||||
}
|
||||
|
||||
} // Haskell::Internal
|
||||
|
@@ -10,6 +10,8 @@
|
||||
#include "toolssettingsaccessor.h"
|
||||
#include "toolssettingspage.h"
|
||||
|
||||
#include <debugger/debuggerruncontrol.h>
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -18,6 +20,7 @@
|
||||
|
||||
#include <utils/fsengine/fileiconprovider.h>
|
||||
|
||||
using namespace Debugger;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -34,6 +37,7 @@ public:
|
||||
MesonActionsManager m_actions;
|
||||
MachineFileManager m_machineFilesManager;
|
||||
SimpleTargetRunnerFactory m_mesonRunWorkerFactory{{m_runConfigurationFactory.runConfigurationId()}};
|
||||
SimpleDebugRunnerFactory m_mesonDebugRunWorkerFactory{{m_runConfigurationFactory.runConfigurationId()}};
|
||||
};
|
||||
|
||||
class MesonProjectPlugin final : public ExtensionSystem::IPlugin
|
||||
|
@@ -21,6 +21,8 @@
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <debugger/debuggerruncontrol.h>
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
@@ -32,6 +34,7 @@
|
||||
#include <utils/icon.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
using namespace Debugger;
|
||||
using namespace Utils;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
@@ -48,6 +51,8 @@ public:
|
||||
NimbleTestConfigurationFactory nimbleTestConfigFactory;
|
||||
SimpleTargetRunnerFactory nimRunWorkerFactory{{nimRunConfigFactory.runConfigurationId()}};
|
||||
SimpleTargetRunnerFactory nimbleRunWorkerFactory{{nimbleRunConfigFactory.runConfigurationId()}};
|
||||
SimpleDebugRunnerFactory nimDebugWorkerFactory{{nimRunConfigFactory.runConfigurationId()}};
|
||||
SimpleDebugRunnerFactory nimbleDebugWorkerFactory{{nimbleRunConfigFactory.runConfigurationId()}};
|
||||
SimpleTargetRunnerFactory nimbleTestWorkerFactory{{nimbleTestConfigFactory.runConfigurationId()}};
|
||||
NimbleBuildStepFactory nimbleBuildStepFactory;
|
||||
NimbleTaskStepFactory nimbleTaskStepFactory;
|
||||
|
@@ -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()
|
||||
{
|
||||
registerRunConfiguration<CMakeRunConfiguration>(CMAKE_RUNCONFIG_ID);
|
||||
registerRunConfiguration<CMakeRunConfiguration>(ProjectExplorer::Constants::CMAKE_RUNCONFIG_ID);
|
||||
addSupportedProjectType(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
||||
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||
addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE);
|
||||
@@ -182,7 +178,7 @@ CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
|
||||
|
||||
QbsRunConfigurationFactory::QbsRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<QbsRunConfiguration>(QBS_RUNCONFIG_ID);
|
||||
registerRunConfiguration<QbsRunConfiguration>(ProjectExplorer::Constants::QBS_RUNCONFIG_ID);
|
||||
addSupportedProjectType(QbsProjectManager::Constants::PROJECT_ID);
|
||||
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||
addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE);
|
||||
@@ -190,7 +186,7 @@ QbsRunConfigurationFactory::QbsRunConfigurationFactory()
|
||||
|
||||
DesktopQmakeRunConfigurationFactory::DesktopQmakeRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<DesktopQmakeRunConfiguration>(QMAKE_RUNCONFIG_ID);
|
||||
registerRunConfiguration<DesktopQmakeRunConfiguration>(ProjectExplorer::Constants::QMAKE_RUNCONFIG_ID);
|
||||
addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
|
||||
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||
addSupportedTargetDeviceType(Docker::Constants::DOCKER_DEVICE_TYPE);
|
||||
|
@@ -176,6 +176,11 @@ const char QML_PREVIEW_RUNNER[]="RunConfiguration.QmlPreviewRunner";
|
||||
const char PERFPROFILER_RUN_MODE[]="PerfProfiler.RunMode";
|
||||
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
|
||||
const char PROJECTTREE_ID[] = "Projects";
|
||||
|
||||
|
@@ -98,6 +98,25 @@ void RunWorkerFactory::addSupportedDeviceType(Id 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
|
||||
{
|
||||
if (!m_supportedRunModes.contains(runMode))
|
||||
|
@@ -107,11 +107,13 @@ public:
|
||||
protected:
|
||||
template <typename Worker>
|
||||
void setProduct() { setProducer([](RunControl *rc) { return new Worker(rc); }); }
|
||||
void setId(Utils::Id id) { m_id = id; }
|
||||
void setProducer(const WorkerCreator &producer);
|
||||
void setSupportedRunConfigs(const QList<Utils::Id> &runConfigs);
|
||||
void addSupportedRunMode(Utils::Id runMode);
|
||||
void addSupportedRunConfig(Utils::Id runConfig);
|
||||
void addSupportedDeviceType(Utils::Id deviceType);
|
||||
void cloneProduct(Utils::Id exitstingStepId, Utils::Id overrideId = Utils::Id());
|
||||
|
||||
private:
|
||||
friend class RunControl;
|
||||
@@ -122,6 +124,7 @@ private:
|
||||
QList<Utils::Id> m_supportedRunModes;
|
||||
QList<Utils::Id> m_supportedRunConfigurations;
|
||||
QList<Utils::Id> m_supportedDeviceTypes;
|
||||
Utils::Id m_id;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include "pythontr.h"
|
||||
#include "pythonwizardpage.h"
|
||||
|
||||
#include <debugger/debuggerruncontrol.h>
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <projectexplorer/buildtargetinfo.h>
|
||||
@@ -25,6 +27,7 @@
|
||||
#include <utils/fsengine/fileiconprovider.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
using namespace Debugger;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -45,6 +48,7 @@ public:
|
||||
PySideBuildStepFactory buildStepFactory;
|
||||
PythonBuildConfigurationFactory buildConfigFactory;
|
||||
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
|
||||
SimpleDebugRunnerFactory debugRunWorkerFactory{{runConfigFactory.runConfigurationId()}, {ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE}};
|
||||
PythonSettings settings;
|
||||
PythonWizardPageFactory pythonWizardPageFactory;
|
||||
};
|
||||
@@ -84,7 +88,7 @@ private:
|
||||
{
|
||||
// Add MIME overlay icons (these icons displayed at Project dock panel)
|
||||
const QString imageFile = Utils::creatorTheme()->imageFile(Theme::IconOverlayPro,
|
||||
::Constants::FILEOVERLAY_PY);
|
||||
ProjectExplorer::Constants::FILEOVERLAY_PY);
|
||||
FileIconProvider::registerIconOverlayForSuffix(imageFile, "py");
|
||||
|
||||
TaskHub::addCategory({PythonErrorTaskCategory,
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#include <coreplugin/messagebox.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
|
||||
#include <debugger/debuggerruncontrol.h>
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -55,6 +57,7 @@
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Debugger;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -97,6 +100,7 @@ class QmlProjectPluginPrivate
|
||||
public:
|
||||
QmlProjectRunConfigurationFactory runConfigFactory;
|
||||
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
|
||||
SimpleDebugRunnerFactory debugRunWorkerFactory{{runConfigFactory.runConfigurationId()}};
|
||||
QPointer<QMessageBox> lastMessageBox;
|
||||
QdsLandingPage *landingPage = nullptr;
|
||||
QdsLandingPageWidget *landingPageWidget = nullptr;
|
||||
|
Reference in New Issue
Block a user