RemoteLinux: Prevent step factory sharing by inheritance

This was the preferred way for a while, but has been superseded by
creating the steps by ID.

Not exposing the factory classes in a header prevents following
the old approach in downstream plugins.

Change-Id: Iaa89458a87602006f1a05fa142a34cc1f9d63c64
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2024-07-18 15:57:16 +02:00
parent 60206de94f
commit a1eaaadbe9
7 changed files with 65 additions and 59 deletions

View File

@@ -7,6 +7,7 @@
#include "remotelinux_constants.h" #include "remotelinux_constants.h"
#include "remotelinuxtr.h" #include "remotelinuxtr.h"
#include <projectexplorer/buildstep.h>
#include <projectexplorer/buildsystem.h> #include <projectexplorer/buildsystem.h>
#include <projectexplorer/deploymentdata.h> #include <projectexplorer/deploymentdata.h>
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/devicemanager.h>
@@ -28,9 +29,9 @@ using namespace Utils;
namespace RemoteLinux::Internal { namespace RemoteLinux::Internal {
// RsyncDeployStep // GenericDeployStep
class GenericDeployStep : public AbstractRemoteLinuxDeployStep class GenericDeployStep final : public AbstractRemoteLinuxDeployStep
{ {
public: public:
GenericDeployStep(BuildStepList *bsl, Id id) GenericDeployStep(BuildStepList *bsl, Id id)
@@ -223,10 +224,21 @@ GroupItem GenericDeployStep::deployRecipe()
// Factory // Factory
GenericDeployStepFactory::GenericDeployStepFactory() class GenericDeployStepFactory final : public BuildStepFactory
{ {
registerStep<GenericDeployStep>(Constants::GenericDeployStepId); public:
setDisplayName(Tr::tr("Deploy files")); GenericDeployStepFactory()
{
registerStep<GenericDeployStep>(Constants::GenericDeployStepId);
setDisplayName(Tr::tr("Deploy files"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
setSupportedDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
}
};
void setupGenericDeployStep()
{
static GenericDeployStepFactory theGenericDeployStepFactory;
} }
} // RemoteLinux::Internal } // RemoteLinux::Internal

View File

@@ -3,14 +3,8 @@
#pragma once #pragma once
#include <projectexplorer/buildstep.h>
namespace RemoteLinux::Internal { namespace RemoteLinux::Internal {
class GenericDeployStepFactory : public ProjectExplorer::BuildStepFactory void setupGenericDeployStep();
{
public:
GenericDeployStepFactory();
};
} // namespace RemoteLinux::Internal } // namespace RemoteLinux::Internal

View File

@@ -7,10 +7,12 @@
#include "remotelinux_constants.h" #include "remotelinux_constants.h"
#include "remotelinuxtr.h" #include "remotelinuxtr.h"
#include <projectexplorer/buildstep.h>
#include <projectexplorer/deployablefile.h> #include <projectexplorer/deployablefile.h>
#include <projectexplorer/deploymentdata.h> #include <projectexplorer/deploymentdata.h>
#include <projectexplorer/devicesupport/filetransfer.h> #include <projectexplorer/devicesupport/filetransfer.h>
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -35,7 +37,7 @@ struct UploadStorage
QList<DeployableFile> filesToUpload; QList<DeployableFile> filesToUpload;
}; };
class GenericDirectUploadStep : public AbstractRemoteLinuxDeployStep class GenericDirectUploadStep final : public AbstractRemoteLinuxDeployStep
{ {
public: public:
GenericDirectUploadStep(BuildStepList *bsl, Id id) GenericDirectUploadStep(BuildStepList *bsl, Id id)
@@ -266,10 +268,21 @@ GroupItem GenericDirectUploadStep::deployRecipe()
// Factory // Factory
GenericDirectUploadStepFactory::GenericDirectUploadStepFactory() class GenericDirectUploadStepFactory final : public BuildStepFactory
{ {
registerStep<GenericDirectUploadStep>(Constants::DirectUploadStepId); public:
setDisplayName(Tr::tr("Upload files via SFTP")); GenericDirectUploadStepFactory()
{
registerStep<GenericDirectUploadStep>(Constants::DirectUploadStepId);
setDisplayName(Tr::tr("Upload files via SFTP"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
setSupportedDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
}
};
void setupGenericDirectUploadStep()
{
static GenericDirectUploadStepFactory theGenericDirectUploadStepFactory;
} }
} // RemoteLinux::Internal } // RemoteLinux::Internal

View File

@@ -3,14 +3,8 @@
#pragma once #pragma once
#include <projectexplorer/buildstep.h>
namespace RemoteLinux::Internal { namespace RemoteLinux::Internal {
class GenericDirectUploadStepFactory : public ProjectExplorer::BuildStepFactory void setupGenericDirectUploadStep();
{
public:
GenericDirectUploadStepFactory();
};
} // RemoteLinux::Internal } // RemoteLinux::Internal

View File

@@ -7,6 +7,7 @@
#include "remotelinuxtr.h" #include "remotelinuxtr.h"
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildsteplist.h>
#include <projectexplorer/buildsystem.h> #include <projectexplorer/buildsystem.h>
#include <projectexplorer/deployconfiguration.h> #include <projectexplorer/deployconfiguration.h>
@@ -32,17 +33,17 @@ using namespace Utils;
namespace RemoteLinux::Internal { namespace RemoteLinux::Internal {
class MakeInstallStep : public MakeStep class MakeInstallStep final : public MakeStep
{ {
public: public:
MakeInstallStep(BuildStepList *parent, Id id); MakeInstallStep(BuildStepList *parent, Id id);
private: private:
void fromMap(const Store &map) override; void fromMap(const Store &map) final;
QWidget *createConfigWidget() override; QWidget *createConfigWidget() final;
bool init() override; bool init() final;
Tasking::GroupItem runRecipe() final; Tasking::GroupItem runRecipe() final;
bool isJobCountSupported() const override { return false; } bool isJobCountSupported() const final { return false; }
void updateCommandFromAspect(); void updateCommandFromAspect();
void updateArgsFromAspect(); void updateArgsFromAspect();
@@ -270,10 +271,21 @@ void MakeInstallStep::fromMap(const Store &map)
// Factory // Factory
MakeInstallStepFactory::MakeInstallStepFactory() class MakeInstallStepFactory final : public BuildStepFactory
{ {
registerStep<MakeInstallStep>(Constants::MakeInstallStepId); public:
setDisplayName(Tr::tr("Install into temporary host directory")); MakeInstallStepFactory()
{
registerStep<MakeInstallStep>(Constants::MakeInstallStepId);
setDisplayName(Tr::tr("Install into temporary host directory"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
setSupportedDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
}
};
void setupMakeInstallStep()
{
static MakeInstallStepFactory theMakeInstallStepFactory;
} }
} // RemoteLinux::Internal } // RemoteLinux::Internal

View File

@@ -3,14 +3,8 @@
#pragma once #pragma once
#include <projectexplorer/buildstep.h>
namespace RemoteLinux::Internal { namespace RemoteLinux::Internal {
class MakeInstallStepFactory : public ProjectExplorer::BuildStepFactory void setupMakeInstallStep();
{
public:
MakeInstallStepFactory();
};
} // namespace RemoteLinux::Internal } // RemoteLinux::Internal

View File

@@ -1,7 +1,7 @@
// Copyright (C) 2023 The Qt Company Ltd. // Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "remotelinuxdebugsupport.h" #include "remotelinuxdeploysupport.h"
#include "genericdeploystep.h" #include "genericdeploystep.h"
#include "genericdirectuploadstep.h" #include "genericdirectuploadstep.h"
@@ -14,24 +14,11 @@
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <utils/store.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace RemoteLinux::Internal { namespace RemoteLinux::Internal {
template <class Factory> class RemoteLinuxDeployConfigurationFactory final : public DeployConfigurationFactory
class RemoteLinuxDeployStepFactory : public Factory
{
public:
RemoteLinuxDeployStepFactory()
{
Factory::setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
Factory::setSupportedDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
}
};
class RemoteLinuxDeployConfigurationFactory : public DeployConfigurationFactory
{ {
public: public:
RemoteLinuxDeployConfigurationFactory() RemoteLinuxDeployConfigurationFactory()
@@ -54,10 +41,13 @@ public:
} }
}); });
// Make sure we can use the steps below.
setupGenericDirectUploadStep();
setupGenericDeployStep();
setupMakeInstallStep();
addInitialStep(Constants::MakeInstallStepId, needsMakeInstall); addInitialStep(Constants::MakeInstallStepId, needsMakeInstall);
addInitialStep(Constants::KillAppStepId); addInitialStep(Constants::KillAppStepId);
// TODO: Rename RsyncDeployStep to something more generic.
addInitialStep(Constants::GenericDeployStepId); addInitialStep(Constants::GenericDeployStepId);
} }
}; };
@@ -65,9 +55,6 @@ public:
void setupRemoteLinuxDeploySupport() void setupRemoteLinuxDeploySupport()
{ {
static RemoteLinuxDeployConfigurationFactory deployConfigurationFactory; static RemoteLinuxDeployConfigurationFactory deployConfigurationFactory;
static RemoteLinuxDeployStepFactory<GenericDirectUploadStepFactory> genericDirectUploadStep;
static RemoteLinuxDeployStepFactory<GenericDeployStepFactory> rsyncDeployStepFactory;
static RemoteLinuxDeployStepFactory<MakeInstallStepFactory> makeInstallStepFactory;
} }
} // RemoteLinux::Internal } // RemoteLinux::Internal