ProjectExplorer: Introduce and use convenience factory class

... to create SimpleTargetRunner runners for a single run config.

Change-Id: I8af3d7cdcaf54f0584af948aa6e0fa015d1a3077
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-01-06 13:56:00 +01:00
parent c7884a2b17
commit f08b5727dc
8 changed files with 40 additions and 54 deletions

View File

@@ -27,8 +27,7 @@ using namespace Core;
using namespace ProjectExplorer;
using namespace Utils;
namespace MesonProjectManager {
namespace Internal {
namespace MesonProjectManager::Internal {
class MesonProjectPluginPrivate : public QObject
{
@@ -56,10 +55,8 @@ private:
MesonRunConfigurationFactory m_runConfigurationFactory;
MesonActionsManager m_actions;
MachineFileManager m_machineFilesManager;
RunWorkerFactory
m_mesonRunWorkerFactory{RunWorkerFactory::make<ProjectExplorer::SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{m_runConfigurationFactory.runConfigurationId()}};
SimpleTargetRunnerFactory m_mesonRunWorkerFactory{{m_runConfigurationFactory.runConfigurationId()}};
void saveAll()
{
m_toolsSettings.saveMesonTools(MesonTools::tools(), ICore::dialogParent());
@@ -85,7 +82,6 @@ bool MesonProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
return true;
}
} // namespace Internal
} // namespace MesonProjectManager
} // MesonProjectManager::Internal
#include "mesonprojectplugin.moc"

View File

@@ -55,21 +55,9 @@ public:
NimRunConfigurationFactory nimRunConfigFactory;
NimbleRunConfigurationFactory nimbleRunConfigFactory;
NimbleTestConfigurationFactory nimbleTestConfigFactory;
RunWorkerFactory nimRunWorkerFactory {
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{nimRunConfigFactory.runConfigurationId()}
};
RunWorkerFactory nimbleRunWorkerFactory {
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{nimbleRunConfigFactory.runConfigurationId()}
};
RunWorkerFactory nimbleTestWorkerFactory {
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{nimbleTestConfigFactory.runConfigurationId()}
};
SimpleTargetRunnerFactory nimRunWorkerFactory{{nimRunConfigFactory.runConfigurationId()}};
SimpleTargetRunnerFactory nimbleRunWorkerFactory{{nimbleRunConfigFactory.runConfigurationId()}};
SimpleTargetRunnerFactory nimbleTestWorkerFactory{{nimbleTestConfigFactory.runConfigurationId()}};
NimbleBuildStepFactory nimbleBuildStepFactory;
NimbleTaskStepFactory nimbleTaskStepFactory;
NimCompilerBuildStepFactory buildStepFactory;

View File

@@ -719,14 +719,11 @@ public:
DesktopQmakeRunConfigurationFactory qmakeRunConfigFactory;
QbsRunConfigurationFactory qbsRunConfigFactory;
CMakeRunConfigurationFactory cmakeRunConfigFactory;
RunWorkerFactory desktopRunWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{qmakeRunConfigFactory.runConfigurationId(),
qbsRunConfigFactory.runConfigurationId(),
cmakeRunConfigFactory.runConfigurationId()}
};
SimpleTargetRunnerFactory desktopRunWorkerFactory{{
qmakeRunConfigFactory.runConfigurationId(),
qbsRunConfigFactory.runConfigurationId(),
cmakeRunConfigFactory.runConfigurationId()
}};
SanitizerOutputFormatterFactory sanitizerFormatterFactory;
};

View File

@@ -100,6 +100,11 @@ void RunWorkerFactory::setProducer(const WorkerCreator &producer)
m_producer = producer;
}
void RunWorkerFactory::setSupportedRunConfigs(const QList<Utils::Id> &runConfigs)
{
m_supportedRunConfigurations = runConfigs;
}
void RunWorkerFactory::addSupportedRunMode(Utils::Id runMode)
{
m_supportedRunModes.append(runMode);
@@ -1892,6 +1897,15 @@ void OutputFormatterFactory::setFormatterCreator(const FormatterCreator &creator
m_creator = creator;
}
// SimpleTargetRunnerFactory
SimpleTargetRunnerFactory::SimpleTargetRunnerFactory(const QList<Id> &runConfigs)
{
setProduct<SimpleTargetRunner>();
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
setSupportedRunConfigs(runConfigs);
}
} // namespace ProjectExplorer
#include "runcontrol.moc"

View File

@@ -137,6 +137,7 @@ protected:
template <typename Worker>
void setProduct() { setProducer([](RunControl *rc) { return new Worker(rc); }); }
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);
@@ -298,6 +299,12 @@ private:
const std::unique_ptr<Internal::SimpleTargetRunnerPrivate> d;
};
class PROJECTEXPLORER_EXPORT SimpleTargetRunnerFactory : public RunWorkerFactory
{
public:
explicit SimpleTargetRunnerFactory(const QList<Utils::Id> &runConfig);
};
class PROJECTEXPLORER_EXPORT OutputFormatterFactory
{
protected:

View File

@@ -20,8 +20,7 @@
using namespace ProjectExplorer;
namespace Python {
namespace Internal {
namespace Python::Internal {
static PythonPlugin *m_instance = nullptr;
@@ -33,13 +32,7 @@ public:
PythonRunConfigurationFactory runConfigFactory;
PySideBuildStepFactory buildStepFactory;
PySideBuildConfigurationFactory buildConfigFactory;
RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.runConfigurationId()}
};
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
PythonSettings settings;
};
@@ -81,5 +74,4 @@ void PythonPlugin::extensionsInitialized()
TaskHub::addCategory(PythonErrorTaskCategory, "Python", true);
}
} // namespace Internal
} // namespace Python
} // Python::Internal

View File

@@ -51,8 +51,7 @@
using namespace ProjectExplorer;
namespace QmlProjectManager {
namespace Internal {
namespace QmlProjectManager::Internal {
static bool isQmlDesigner(const ExtensionSystem::PluginSpec *spec)
{
@@ -90,9 +89,7 @@ class QmlProjectPluginPrivate
{
public:
QmlProjectRunConfigurationFactory runConfigFactory;
RunWorkerFactory runWorkerFactory{RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.runConfigurationId()}};
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
QPointer<QMessageBox> lastMessageBox;
QdsLandingPage *landingPage = nullptr;
QdsLandingPageWidget *landingPageWidget = nullptr;
@@ -457,5 +454,4 @@ Utils::FilePath QmlProjectPlugin::projectFilePath()
return {};
}
} // namespace Internal
} // namespace QmlProjectManager
} // QmlProjectManager::Internal

View File

@@ -102,12 +102,8 @@ public:
QnxRunConfigurationFactory runConfigFactory;
QnxSettingsPage settingsPage;
QnxToolChainFactory toolChainFactory;
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.runConfigurationId()}
};
RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<QnxDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE},