AbstractRemoteLinuxDeployStep: Enclose prechecks in recipe

This is a preparation step toward making the recipe more general.
Add a runRecipe() method (private for now) which
describes the whole step's execution. Later, when
virtual BuildStep::runRecipe() is added, we just
make this newly added method virtual.

Make deployRecipe() pure virtual.

Change-Id: Ic9c4e3eea7d4a3eb95fd419575f4f747224d0499
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2023-07-10 09:09:02 +02:00
parent dddf16226a
commit 181b5ee28b
2 changed files with 19 additions and 17 deletions

View File

@@ -117,20 +117,7 @@ void AbstractRemoteLinuxDeployStep::doRun()
QTC_ASSERT(!d->m_taskTree, return);
const auto canDeploy = isDeploymentPossible();
if (!canDeploy) {
addErrorMessage(canDeploy.error());
handleFinished();
return;
}
if (!isDeploymentNecessary()) {
addProgressMessage(Tr::tr("No deployment action necessary. Skipping."));
handleFinished();
return;
}
d->m_taskTree.reset(new TaskTree(deployRecipe()));
d->m_taskTree.reset(new TaskTree(runRecipe()));
const auto endHandler = [this] {
d->m_taskTree.release()->deleteLater();
handleFinished();
@@ -198,9 +185,23 @@ bool AbstractRemoteLinuxDeployStep::isDeploymentNecessary() const
return true;
}
Group AbstractRemoteLinuxDeployStep::deployRecipe()
Group AbstractRemoteLinuxDeployStep::runRecipe()
{
return {};
const auto onSetup = [this] {
const auto canDeploy = isDeploymentPossible();
if (!canDeploy) {
addErrorMessage(canDeploy.error());
handleFinished();
return SetupResult::StopWithError;
}
if (!isDeploymentNecessary()) {
addProgressMessage(Tr::tr("No deployment action necessary. Skipping."));
handleFinished();
return SetupResult::StopWithDone;
}
return SetupResult::Continue;
};
return Group { onGroupSetup(onSetup), deployRecipe() };
}
} // namespace RemoteLinux

View File

@@ -53,7 +53,8 @@ protected:
private:
virtual bool isDeploymentNecessary() const;
virtual Tasking::Group deployRecipe();
virtual Tasking::Group deployRecipe() = 0;
Tasking::Group runRecipe();
Internal::AbstractRemoteLinuxDeployStepPrivate *d;
};