From 9c182911d38c60c2043faa9839be63158acfc923 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 3 Apr 2023 09:50:51 +0200 Subject: [PATCH] PE/Qnx: Disentangle BuildStep factories from downstream further The idea is to only expose factories with properties and not the actual step implementations. Change-Id: I72dc3944993f898f12b6a9bec11317f87e45c648 Reviewed-by: Qt CI Bot Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/buildstep.cpp | 24 +++++++++++++++++++ src/plugins/projectexplorer/buildstep.h | 1 + .../projectexplorer/projectexplorer.cpp | 2 ++ src/plugins/qnx/qnxplugin.cpp | 24 +++++-------------- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index 84c2fcf79ee..156aa5753f1 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -380,6 +380,29 @@ QString BuildStepFactory::displayName() const return m_displayName; } +void BuildStepFactory::cloneStep(Utils::Id exitstingStepId, Utils::Id overrideNewStepId) +{ + m_stepId = {}; + m_creator = {}; + for (BuildStepFactory *factory : BuildStepFactory::allBuildStepFactories()) { + if (factory->m_stepId == exitstingStepId) { + m_creator = factory->m_creator; + m_stepId = factory->m_stepId; + m_displayName = factory->m_displayName; + // 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_creator, return); + if (overrideNewStepId.isValid()) + m_stepId = overrideNewStepId; +} + void BuildStepFactory::setDisplayName(const QString &displayName) { m_displayName = displayName; @@ -432,6 +455,7 @@ Id BuildStepFactory::stepId() const BuildStep *BuildStepFactory::create(BuildStepList *parent) { + QTC_ASSERT(m_creator, return nullptr); BuildStep *step = m_creator(parent); step->setDefaultDisplayName(m_displayName); return step; diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index d0a21910afa..11adc4cf5fe 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -171,6 +171,7 @@ protected: m_stepId = id; m_creator = [id](BuildStepList *bsl) { return new BuildStepType(bsl, id); }; } + void cloneStep(Utils::Id exitstingStepId, Utils::Id overrideNewStepId = {}); void setSupportedStepList(Utils::Id id); void setSupportedStepLists(const QList &ids); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 6956d7862a3..cbf467349a1 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -36,6 +36,7 @@ #include "devicesupport/desktopdevice.h" #include "devicesupport/desktopdevicefactory.h" #include "devicesupport/devicemanager.h" +#include "devicesupport/devicecheckbuildstep.h" #include "devicesupport/devicesettingspage.h" #include "devicesupport/sshsettings.h" #include "devicesupport/sshsettingspage.h" @@ -726,6 +727,7 @@ public: cmakeRunConfigFactory.runConfigurationId() }}; + DeviceCheckBuildStepFactory deviceCheckBuildStepFactory; SanitizerOutputFormatterFactory sanitizerFormatterFactory; }; diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp index 7a06effc144..d2cb1964ce5 100644 --- a/src/plugins/qnx/qnxplugin.cpp +++ b/src/plugins/qnx/qnxplugin.cpp @@ -33,8 +33,6 @@ #include #include -#include -#include #include #include @@ -43,22 +41,12 @@ using namespace ProjectExplorer; namespace Qnx::Internal { -// FIXME: Remove... -class QnxUploadStepFactory : public RemoteLinux::GenericDirectUploadStepFactory +class QnxDeployStepFactory : public BuildStepFactory { public: - QnxUploadStepFactory() - { - registerStep(Constants::QNX_DIRECT_UPLOAD_STEP_ID); - } -}; - -template -class QnxDeployStepFactory : public RemoteLinux::MakeInstallStepFactory -{ -public: - QnxDeployStepFactory() + QnxDeployStepFactory(Utils::Id existingStepId, Utils::Id overrideId = {}) { + cloneStep(existingStepId, overrideId); setSupportedConfiguration(Constants::QNX_QNX_DEPLOYCONFIGURATION_ID); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); } @@ -96,9 +84,9 @@ public: QnxQtVersionFactory qtVersionFactory; QnxDeviceFactory deviceFactory; QnxDeployConfigurationFactory deployConfigFactory; - QnxDeployStepFactory directUploadDeployFactory; - QnxDeployStepFactory makeInstallDeployFactory; - QnxDeployStepFactory checkBuildDeployFactory; + QnxDeployStepFactory directUploadDeployFactory{RemoteLinux::Constants::DirectUploadStepId, + Constants::QNX_DIRECT_UPLOAD_STEP_ID}; + QnxDeployStepFactory makeInstallStepFactory{RemoteLinux::Constants::MakeInstallStepId}; QnxRunConfigurationFactory runConfigFactory; QnxSettingsPage settingsPage; QnxToolChainFactory toolChainFactory;