RemoteLinux: Streamline RsyncDeployStep interface

Change-Id: I5aa5ff477d1c654fd502575c32af667e436a2129
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2022-08-11 13:50:36 +02:00
parent 0df4d22d35
commit e9d6c0f154
3 changed files with 47 additions and 52 deletions

View File

@@ -58,7 +58,7 @@ public:
TarPackageCreationStepFactory tarPackageCreationStepFactory; TarPackageCreationStepFactory tarPackageCreationStepFactory;
TarPackageDeployStepFactory tarPackageDeployStepFactory; TarPackageDeployStepFactory tarPackageDeployStepFactory;
GenericDeployStepFactory<GenericDirectUploadStep> genericDirectUploadStepFactory; GenericDeployStepFactory<GenericDirectUploadStep> genericDirectUploadStepFactory;
GenericDeployStepFactory<RsyncDeployStep> rsyncDeployStepFactory; RsyncDeployStepFactory rsyncDeployStepFactory;
CustomCommandDeployStepFactory customCommandDeployStepFactory; CustomCommandDeployStepFactory customCommandDeployStepFactory;
KillAppStepFactory killAppStepFactory; KillAppStepFactory killAppStepFactory;
GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory; GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory;

View File

@@ -3,6 +3,7 @@
#include "rsyncdeploystep.h" #include "rsyncdeploystep.h"
#include "abstractremotelinuxdeploystep.h"
#include "abstractremotelinuxdeployservice.h" #include "abstractremotelinuxdeployservice.h"
#include "remotelinux_constants.h" #include "remotelinux_constants.h"
#include "remotelinuxtr.h" #include "remotelinuxtr.h"
@@ -10,6 +11,7 @@
#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>
@@ -20,13 +22,12 @@
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace RemoteLinux { namespace RemoteLinux::Internal {
namespace Internal {
class RsyncDeployService : public AbstractRemoteLinuxDeployService class RsyncDeployService : public AbstractRemoteLinuxDeployService
{ {
public: public:
RsyncDeployService(QObject *parent = nullptr) : AbstractRemoteLinuxDeployService(parent) RsyncDeployService()
{ {
connect(&m_mkdir, &QtcProcess::done, this, [this] { connect(&m_mkdir, &QtcProcess::done, this, [this] {
if (m_mkdir.result() != ProcessResult::FinishedWithSuccess) { if (m_mkdir.result() != ProcessResult::FinishedWithSuccess) {
@@ -139,46 +140,48 @@ void RsyncDeployService::setFinished()
handleDeploymentDone(); handleDeploymentDone();
} }
} // namespace Internal // RsyncDeployStep
RsyncDeployStep::RsyncDeployStep(BuildStepList *bsl, Utils::Id id) class RsyncDeployStep : public AbstractRemoteLinuxDeployStep
: AbstractRemoteLinuxDeployStep(bsl, id)
{ {
auto service = createDeployService<Internal::RsyncDeployService>(); public:
RsyncDeployStep(BuildStepList *bsl, Id id)
: AbstractRemoteLinuxDeployStep(bsl, id)
{
auto service = createDeployService<Internal::RsyncDeployService>();
auto flags = addAspect<StringAspect>(); auto flags = addAspect<StringAspect>();
flags->setDisplayStyle(StringAspect::LineEditDisplay); flags->setDisplayStyle(StringAspect::LineEditDisplay);
flags->setSettingsKey("RemoteLinux.RsyncDeployStep.Flags"); flags->setSettingsKey("RemoteLinux.RsyncDeployStep.Flags");
flags->setLabelText(Tr::tr("Flags:")); flags->setLabelText(Tr::tr("Flags:"));
flags->setValue(FileTransferSetupData::defaultRsyncFlags()); flags->setValue(FileTransferSetupData::defaultRsyncFlags());
auto ignoreMissingFiles = addAspect<BoolAspect>(); auto ignoreMissingFiles = addAspect<BoolAspect>();
ignoreMissingFiles->setSettingsKey("RemoteLinux.RsyncDeployStep.IgnoreMissingFiles"); ignoreMissingFiles->setSettingsKey("RemoteLinux.RsyncDeployStep.IgnoreMissingFiles");
ignoreMissingFiles->setLabel(Tr::tr("Ignore missing files:"), ignoreMissingFiles->setLabel(Tr::tr("Ignore missing files:"),
BoolAspect::LabelPlacement::InExtraLabel); BoolAspect::LabelPlacement::InExtraLabel);
ignoreMissingFiles->setValue(false); ignoreMissingFiles->setValue(false);
setInternalInitializer([service, flags, ignoreMissingFiles] { setInternalInitializer([service, flags, ignoreMissingFiles] {
service->setIgnoreMissingFiles(ignoreMissingFiles->value()); service->setIgnoreMissingFiles(ignoreMissingFiles->value());
service->setFlags(flags->value()); service->setFlags(flags->value());
return service->isDeploymentPossible(); return service->isDeploymentPossible();
}); });
setRunPreparer([this, service] { setRunPreparer([this, service] {
service->setDeployableFiles(target()->deploymentData().allFiles()); service->setDeployableFiles(target()->deploymentData().allFiles());
}); });
}
};
// RsyncDeployStepFactory
RsyncDeployStepFactory::RsyncDeployStepFactory()
{
registerStep<RsyncDeployStep>(Constants::RsyncDeployStepId);
setDisplayName(Tr::tr("Deploy files via rsync"));
setSupportedConfiguration(RemoteLinux::Constants::DeployToGenericLinux);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
} }
RsyncDeployStep::~RsyncDeployStep() = default; } // RemoteLinux::Internal
Utils::Id RsyncDeployStep::stepId()
{
return Constants::RsyncDeployStepId;
}
QString RsyncDeployStep::displayName()
{
return Tr::tr("Deploy files via rsync");
}
} // RemoteLinux

View File

@@ -3,22 +3,14 @@
#pragma once #pragma once
#include "remotelinux_export.h" #include <projectexplorer/buildstep.h>
#include "abstractremotelinuxdeploystep.h" namespace RemoteLinux::Internal {
namespace RemoteLinux { class RsyncDeployStepFactory : public ProjectExplorer::BuildStepFactory
class REMOTELINUX_EXPORT RsyncDeployStep : public AbstractRemoteLinuxDeployStep
{ {
Q_OBJECT
public: public:
RsyncDeployStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); RsyncDeployStepFactory();
~RsyncDeployStep() override;
static Utils::Id stepId();
static QString displayName();
}; };
} // RemoteLinux } // RemoteLinux::Internal