forked from qt-creator/qt-creator
RemoteLinux et al: Use functor for deploy step polishing
More compact. Change-Id: I8adc63aec71de1e57640911300f2699598ef1a01 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -81,6 +81,10 @@ QdbMakeDefaultAppStep::QdbMakeDefaultAppStep(ProjectExplorer::BuildStepList *bsl
|
||||
d = new QdbMakeDefaultAppStepPrivate;
|
||||
setDefaultDisplayName(stepDisplayName());
|
||||
|
||||
setInternalInitializer([this] {
|
||||
d->deployService.setMakeDefault(d->makeDefault);
|
||||
return deployService()->isDeploymentPossible();
|
||||
});
|
||||
}
|
||||
|
||||
QdbMakeDefaultAppStep::~QdbMakeDefaultAppStep()
|
||||
@@ -93,12 +97,6 @@ Core::Id QdbMakeDefaultAppStep::stepId()
|
||||
return "Qdb.MakeDefaultAppStep";
|
||||
}
|
||||
|
||||
RemoteLinux::CheckResult QdbMakeDefaultAppStep::initInternal()
|
||||
{
|
||||
d->deployService.setMakeDefault(d->makeDefault);
|
||||
return deployService()->isDeploymentPossible();
|
||||
}
|
||||
|
||||
RemoteLinux::AbstractRemoteLinuxDeployService *QdbMakeDefaultAppStep::deployService() const
|
||||
{
|
||||
return &d->deployService;
|
||||
|
@@ -47,7 +47,6 @@ public:
|
||||
bool makeDefault() const;
|
||||
|
||||
protected:
|
||||
RemoteLinux::CheckResult initInternal() override;
|
||||
RemoteLinux::AbstractRemoteLinuxDeployService *deployService() const override;
|
||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
|
@@ -42,6 +42,7 @@ QdbStopApplicationStep::QdbStopApplicationStep(ProjectExplorer::BuildStepList *b
|
||||
d = new QdbStopApplicationStepPrivate;
|
||||
setDefaultDisplayName(stepDisplayName());
|
||||
setWidgetExpandedByDefault(false);
|
||||
setInternalInitializer([this] { return deployService()->isDeploymentPossible(); });
|
||||
}
|
||||
|
||||
QdbStopApplicationStep::~QdbStopApplicationStep()
|
||||
@@ -54,11 +55,6 @@ Core::Id QdbStopApplicationStep::stepId()
|
||||
return "Qdb.StopApplicationStep";
|
||||
}
|
||||
|
||||
RemoteLinux::CheckResult QdbStopApplicationStep::initInternal()
|
||||
{
|
||||
return deployService()->isDeploymentPossible();
|
||||
}
|
||||
|
||||
RemoteLinux::AbstractRemoteLinuxDeployService *QdbStopApplicationStep::deployService() const
|
||||
{
|
||||
return &d->deployService;
|
||||
|
@@ -43,7 +43,6 @@ public:
|
||||
static QString stepDisplayName();
|
||||
|
||||
protected:
|
||||
RemoteLinux::CheckResult initInternal() final;
|
||||
RemoteLinux::AbstractRemoteLinuxDeployService *deployService() const final;
|
||||
|
||||
private:
|
||||
|
@@ -40,6 +40,7 @@ class AbstractRemoteLinuxDeployStepPrivate
|
||||
{
|
||||
public:
|
||||
bool hasError;
|
||||
std::function<CheckResult()> internalInit;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
@@ -49,6 +50,11 @@ AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl,
|
||||
{
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployStep::setInternalInitializer(const std::function<CheckResult ()> &init)
|
||||
{
|
||||
d->internalInit = init;
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployStep::~AbstractRemoteLinuxDeployStep()
|
||||
{
|
||||
delete d;
|
||||
@@ -70,7 +76,9 @@ QVariantMap AbstractRemoteLinuxDeployStep::toMap() const
|
||||
bool AbstractRemoteLinuxDeployStep::init()
|
||||
{
|
||||
deployService()->setTarget(target());
|
||||
const CheckResult canDeploy = initInternal();
|
||||
|
||||
QTC_ASSERT(d->internalInit, return false);
|
||||
const CheckResult canDeploy = d->internalInit();
|
||||
if (!canDeploy) {
|
||||
emit addOutput(tr("Cannot deploy: %1").arg(canDeploy.errorMessage()),
|
||||
OutputFormat::ErrorMessage);
|
||||
|
@@ -51,7 +51,8 @@ protected:
|
||||
void doCancel() override;
|
||||
|
||||
explicit AbstractRemoteLinuxDeployStep(ProjectExplorer::BuildStepList *bsl, Core::Id id);
|
||||
virtual CheckResult initInternal() = 0;
|
||||
|
||||
void setInternalInitializer(const std::function<CheckResult()> &init);
|
||||
|
||||
private:
|
||||
void handleProgressMessage(const QString &message);
|
||||
|
@@ -40,8 +40,6 @@ class GenericDirectUploadStepPrivate
|
||||
{
|
||||
public:
|
||||
GenericDirectUploadService deployService;
|
||||
BaseBoolAspect *incrementalAspect;
|
||||
BaseBoolAspect *ignoreMissingFilesAspect;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
@@ -51,17 +49,22 @@ GenericDirectUploadStep::GenericDirectUploadStep(BuildStepList *bsl)
|
||||
{
|
||||
d = new Internal::GenericDirectUploadStepPrivate;
|
||||
|
||||
d->incrementalAspect = addAspect<BaseBoolAspect>();
|
||||
d->incrementalAspect->setSettingsKey("RemoteLinux.GenericDirectUploadStep.Incremental");
|
||||
d->incrementalAspect->setLabel(tr("Incremental deployment"));
|
||||
d->incrementalAspect->setValue(true);
|
||||
d->incrementalAspect->setDefaultValue(true);
|
||||
auto incremental = addAspect<BaseBoolAspect>();
|
||||
incremental->setSettingsKey("RemoteLinux.GenericDirectUploadStep.Incremental");
|
||||
incremental->setLabel(tr("Incremental deployment"));
|
||||
incremental->setValue(true);
|
||||
incremental->setDefaultValue(true);
|
||||
|
||||
d->ignoreMissingFilesAspect = addAspect<BaseBoolAspect>();
|
||||
d->ignoreMissingFilesAspect
|
||||
->setSettingsKey("RemoteLinux.GenericDirectUploadStep.IgnoreMissingFiles");
|
||||
d->ignoreMissingFilesAspect->setLabel(tr("Ignore missing files"));
|
||||
d->ignoreMissingFilesAspect->setValue(false);
|
||||
auto ignoreMissingFiles = addAspect<BaseBoolAspect>();
|
||||
ignoreMissingFiles->setSettingsKey("RemoteLinux.GenericDirectUploadStep.IgnoreMissingFiles");
|
||||
ignoreMissingFiles->setLabel(tr("Ignore missing files"));
|
||||
ignoreMissingFiles->setValue(false);
|
||||
|
||||
setInternalInitializer([this, incremental, ignoreMissingFiles] {
|
||||
d->deployService.setIncrementalDeployment(incremental->value());
|
||||
d->deployService.setIgnoreMissingFiles(ignoreMissingFiles->value());
|
||||
return d->deployService.isDeploymentPossible();
|
||||
});
|
||||
|
||||
setDefaultDisplayName(displayName());
|
||||
}
|
||||
@@ -71,13 +74,6 @@ GenericDirectUploadStep::~GenericDirectUploadStep()
|
||||
delete d;
|
||||
}
|
||||
|
||||
CheckResult GenericDirectUploadStep::initInternal()
|
||||
{
|
||||
d->deployService.setIncrementalDeployment(d->incrementalAspect->value());
|
||||
d->deployService.setIgnoreMissingFiles(d->ignoreMissingFilesAspect->value());
|
||||
return d->deployService.isDeploymentPossible();
|
||||
}
|
||||
|
||||
GenericDirectUploadService *GenericDirectUploadStep::deployService() const
|
||||
{
|
||||
return &d->deployService;
|
||||
|
@@ -40,8 +40,6 @@ public:
|
||||
explicit GenericDirectUploadStep(ProjectExplorer::BuildStepList *bsl);
|
||||
~GenericDirectUploadStep() override;
|
||||
|
||||
CheckResult initInternal() override;
|
||||
|
||||
static Core::Id stepId();
|
||||
static QString displayName();
|
||||
|
||||
|
@@ -36,10 +36,7 @@ using namespace ProjectExplorer;
|
||||
namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
|
||||
const char PathToCheckAspectId[] = "PathToCheckAspectId";
|
||||
const char PathToCheckKey[] = "RemoteLinux.CheckForFreeDiskSpaceStep.PathToCheck";
|
||||
|
||||
const char RequiredSpaceAspectId[] = "RequiredSpaceAspectId";
|
||||
const char RequiredSpaceKey[] = "RemoteLinux.CheckForFreeDiskSpaceStep.RequiredSpace";
|
||||
|
||||
class RemoteLinuxCheckForFreeDiskSpaceStepPrivate
|
||||
@@ -59,20 +56,24 @@ RemoteLinuxCheckForFreeDiskSpaceStep::RemoteLinuxCheckForFreeDiskSpaceStep(Build
|
||||
setDefaultDisplayName(displayName());
|
||||
|
||||
auto pathToCheckAspect = addAspect<BaseStringAspect>();
|
||||
pathToCheckAspect->setId(PathToCheckAspectId);
|
||||
pathToCheckAspect->setSettingsKey(PathToCheckKey);
|
||||
pathToCheckAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
pathToCheckAspect->setValue("/");
|
||||
pathToCheckAspect->setLabelText(tr("Remote path to check for free space:"));
|
||||
|
||||
auto requiredSpaceAspect = addAspect<BaseIntegerAspect>();
|
||||
requiredSpaceAspect->setId(RequiredSpaceAspectId);
|
||||
requiredSpaceAspect->setSettingsKey(RequiredSpaceKey);
|
||||
requiredSpaceAspect->setLabel(tr("Required disk space:"));
|
||||
requiredSpaceAspect->setDisplayScaleFactor(1024*1024);
|
||||
requiredSpaceAspect->setValue(5*1024*1024);
|
||||
requiredSpaceAspect->setSuffix(tr("MB"));
|
||||
requiredSpaceAspect->setRange(1, std::numeric_limits<int>::max());
|
||||
|
||||
setInternalInitializer([this, pathToCheckAspect, requiredSpaceAspect] {
|
||||
d->deployService.setPathToCheck(pathToCheckAspect->value());
|
||||
d->deployService.setRequiredSpaceInBytes(requiredSpaceAspect->value());
|
||||
return CheckResult::success();
|
||||
});
|
||||
}
|
||||
|
||||
RemoteLinuxCheckForFreeDiskSpaceStep::~RemoteLinuxCheckForFreeDiskSpaceStep()
|
||||
@@ -80,15 +81,6 @@ RemoteLinuxCheckForFreeDiskSpaceStep::~RemoteLinuxCheckForFreeDiskSpaceStep()
|
||||
delete d;
|
||||
}
|
||||
|
||||
CheckResult RemoteLinuxCheckForFreeDiskSpaceStep::initInternal()
|
||||
{
|
||||
d->deployService.setPathToCheck(
|
||||
static_cast<BaseStringAspect *>(aspect(PathToCheckAspectId))->value());
|
||||
d->deployService.setRequiredSpaceInBytes(
|
||||
static_cast<BaseIntegerAspect *>(aspect(RequiredSpaceAspectId))->value());
|
||||
return CheckResult::success();
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployService *RemoteLinuxCheckForFreeDiskSpaceStep::deployService() const
|
||||
{
|
||||
return &d->deployService;
|
||||
|
@@ -41,7 +41,6 @@ public:
|
||||
static QString displayName();
|
||||
|
||||
protected:
|
||||
CheckResult initInternal() override;
|
||||
AbstractRemoteLinuxDeployService *deployService() const override;
|
||||
|
||||
private:
|
||||
|
@@ -36,7 +36,6 @@ namespace Internal {
|
||||
class RemoteLinuxCustomCommandDeploymentStepPrivate
|
||||
{
|
||||
public:
|
||||
BaseStringAspect *commandLineAspect;
|
||||
RemoteLinuxCustomCommandDeployService service;
|
||||
};
|
||||
|
||||
@@ -46,11 +45,18 @@ RemoteLinuxCustomCommandDeploymentStep::RemoteLinuxCustomCommandDeploymentStep(B
|
||||
: AbstractRemoteLinuxDeployStep(bsl, stepId())
|
||||
{
|
||||
d = new Internal::RemoteLinuxCustomCommandDeploymentStepPrivate;
|
||||
d->commandLineAspect = addAspect<BaseStringAspect>();
|
||||
d->commandLineAspect->setSettingsKey("RemoteLinuxCustomCommandDeploymentStep.CommandLine");
|
||||
d->commandLineAspect->setLabelText(tr("Command line:"));
|
||||
d->commandLineAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
|
||||
auto commandLine = addAspect<BaseStringAspect>();
|
||||
commandLine->setSettingsKey("RemoteLinuxCustomCommandDeploymentStep.CommandLine");
|
||||
commandLine->setLabelText(tr("Command line:"));
|
||||
commandLine->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
|
||||
setDefaultDisplayName(displayName());
|
||||
|
||||
setInternalInitializer([this, commandLine] {
|
||||
d->service.setCommandLine(commandLine->value().trimmed());
|
||||
return d->service.isDeploymentPossible();
|
||||
});
|
||||
}
|
||||
|
||||
RemoteLinuxCustomCommandDeploymentStep::~RemoteLinuxCustomCommandDeploymentStep()
|
||||
@@ -58,12 +64,6 @@ RemoteLinuxCustomCommandDeploymentStep::~RemoteLinuxCustomCommandDeploymentStep(
|
||||
delete d;
|
||||
}
|
||||
|
||||
CheckResult RemoteLinuxCustomCommandDeploymentStep::initInternal()
|
||||
{
|
||||
d->service.setCommandLine(d->commandLineAspect->value().trimmed());
|
||||
return d->service.isDeploymentPossible();
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployService *RemoteLinuxCustomCommandDeploymentStep::deployService() const
|
||||
{
|
||||
return &d->service;
|
||||
|
@@ -42,7 +42,6 @@ public:
|
||||
static QString displayName();
|
||||
|
||||
private:
|
||||
CheckResult initInternal() override;
|
||||
AbstractRemoteLinuxDeployService *deployService() const override;
|
||||
|
||||
Internal::RemoteLinuxCustomCommandDeploymentStepPrivate *d;
|
||||
|
@@ -42,16 +42,15 @@ RemoteLinuxKillAppStep::RemoteLinuxKillAppStep(BuildStepList *bsl, Core::Id id)
|
||||
{
|
||||
setDefaultDisplayName(displayName());
|
||||
setWidgetExpandedByDefault(false);
|
||||
}
|
||||
|
||||
CheckResult RemoteLinuxKillAppStep::initInternal()
|
||||
{
|
||||
Target * const theTarget = target();
|
||||
QTC_ASSERT(theTarget, return CheckResult::failure());
|
||||
RunConfiguration * const rc = theTarget->activeRunConfiguration();
|
||||
const QString remoteExe = rc ? rc->runnable().executable : QString();
|
||||
m_service->setRemoteExecutable(remoteExe);
|
||||
return CheckResult::success();
|
||||
setInternalInitializer([this] {
|
||||
Target * const theTarget = target();
|
||||
QTC_ASSERT(theTarget, return CheckResult::failure());
|
||||
RunConfiguration * const rc = theTarget->activeRunConfiguration();
|
||||
const QString remoteExe = rc ? rc->runnable().executable : QString();
|
||||
m_service->setRemoteExecutable(remoteExe);
|
||||
return CheckResult::success();
|
||||
});
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployService *RemoteLinuxKillAppStep::deployService() const
|
||||
|
@@ -41,7 +41,6 @@ public:
|
||||
static QString displayName();
|
||||
|
||||
private:
|
||||
CheckResult initInternal() override;
|
||||
AbstractRemoteLinuxDeployService *deployService() const override;
|
||||
|
||||
RemoteLinuxKillAppService * const m_service;
|
||||
|
@@ -181,26 +181,29 @@ class RsyncDeployStep::RsyncDeployStepPrivate
|
||||
{
|
||||
public:
|
||||
Internal::RsyncDeployService deployService;
|
||||
BaseBoolAspect *ignoreMissingFilesAspect;
|
||||
BaseStringAspect *flagsAspect;
|
||||
};
|
||||
|
||||
RsyncDeployStep::RsyncDeployStep(BuildStepList *bsl)
|
||||
: AbstractRemoteLinuxDeployStep(bsl, stepId()), d(new RsyncDeployStepPrivate)
|
||||
{
|
||||
d->flagsAspect = addAspect<BaseStringAspect>();
|
||||
d->flagsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
d->flagsAspect->setSettingsKey("RemoteLinux.RsyncDeployStep.Flags");
|
||||
d->flagsAspect->setLabelText(tr("Flags:"));
|
||||
d->flagsAspect->setValue(defaultFlags());
|
||||
auto flags = addAspect<BaseStringAspect>();
|
||||
flags->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
flags->setSettingsKey("RemoteLinux.RsyncDeployStep.Flags");
|
||||
flags->setLabelText(tr("Flags:"));
|
||||
flags->setValue(defaultFlags());
|
||||
|
||||
d->ignoreMissingFilesAspect = addAspect<BaseBoolAspect>();
|
||||
d->ignoreMissingFilesAspect
|
||||
->setSettingsKey("RemoteLinux.RsyncDeployStep.IgnoreMissingFiles");
|
||||
d->ignoreMissingFilesAspect->setLabel(tr("Ignore missing files"));
|
||||
d->ignoreMissingFilesAspect->setValue(false);
|
||||
auto ignoreMissingFiles = addAspect<BaseBoolAspect>();
|
||||
ignoreMissingFiles->setSettingsKey("RemoteLinux.RsyncDeployStep.IgnoreMissingFiles");
|
||||
ignoreMissingFiles->setLabel(tr("Ignore missing files"));
|
||||
ignoreMissingFiles->setValue(false);
|
||||
|
||||
setDefaultDisplayName(displayName());
|
||||
|
||||
setInternalInitializer([this, flags, ignoreMissingFiles] {
|
||||
d->deployService.setIgnoreMissingFiles(ignoreMissingFiles->value());
|
||||
d->deployService.setFlags(flags->value());
|
||||
return d->deployService.isDeploymentPossible();
|
||||
});
|
||||
}
|
||||
|
||||
RsyncDeployStep::~RsyncDeployStep()
|
||||
@@ -208,13 +211,6 @@ RsyncDeployStep::~RsyncDeployStep()
|
||||
delete d;
|
||||
}
|
||||
|
||||
CheckResult RsyncDeployStep::initInternal()
|
||||
{
|
||||
d->deployService.setIgnoreMissingFiles(d->ignoreMissingFilesAspect->value());
|
||||
d->deployService.setFlags(d->flagsAspect->value());
|
||||
return d->deployService.isDeploymentPossible();
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployService *RsyncDeployStep::deployService() const
|
||||
{
|
||||
return &d->deployService;
|
||||
|
@@ -59,8 +59,6 @@ private:
|
||||
AbstractRemoteLinuxDeployService *deployService() const override;
|
||||
void doRun() override;
|
||||
|
||||
CheckResult initInternal() override;
|
||||
|
||||
class RsyncDeployStepPrivate;
|
||||
RsyncDeployStepPrivate * const d;
|
||||
};
|
||||
|
@@ -67,23 +67,22 @@ UploadAndInstallTarPackageStep::UploadAndInstallTarPackageStep(BuildStepList *bs
|
||||
m_deployService = new UploadAndInstallTarPackageService(this);
|
||||
setDefaultDisplayName(displayName());
|
||||
setWidgetExpandedByDefault(false);
|
||||
}
|
||||
|
||||
CheckResult UploadAndInstallTarPackageStep::initInternal()
|
||||
{
|
||||
const TarPackageCreationStep *pStep = nullptr;
|
||||
setInternalInitializer([this] {
|
||||
const TarPackageCreationStep *pStep = nullptr;
|
||||
|
||||
for (BuildStep *step : deployConfiguration()->stepList()->steps()) {
|
||||
if (step == this)
|
||||
break;
|
||||
if ((pStep = dynamic_cast<TarPackageCreationStep *>(step)))
|
||||
break;
|
||||
}
|
||||
if (!pStep)
|
||||
return CheckResult::failure(tr("No tarball creation step found."));
|
||||
for (BuildStep *step : deployConfiguration()->stepList()->steps()) {
|
||||
if (step == this)
|
||||
break;
|
||||
if ((pStep = dynamic_cast<TarPackageCreationStep *>(step)))
|
||||
break;
|
||||
}
|
||||
if (!pStep)
|
||||
return CheckResult::failure(tr("No tarball creation step found."));
|
||||
|
||||
m_deployService->setPackageFilePath(pStep->packageFilePath());
|
||||
return m_deployService->isDeploymentPossible();
|
||||
m_deployService->setPackageFilePath(pStep->packageFilePath());
|
||||
return m_deployService->isDeploymentPossible();
|
||||
});
|
||||
}
|
||||
|
||||
Core::Id UploadAndInstallTarPackageStep::stepId()
|
||||
|
@@ -55,8 +55,6 @@ class REMOTELINUX_EXPORT UploadAndInstallTarPackageStep : public AbstractRemoteL
|
||||
public:
|
||||
explicit UploadAndInstallTarPackageStep(ProjectExplorer::BuildStepList *bsl);
|
||||
|
||||
CheckResult initInternal() override;
|
||||
|
||||
static Core::Id stepId();
|
||||
static QString displayName();
|
||||
|
||||
|
Reference in New Issue
Block a user