From 181b5ee28bd3427bfe78537329ac7e2f61a43104 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 10 Jul 2023 09:09:02 +0200 Subject: [PATCH] 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 --- .../abstractremotelinuxdeploystep.cpp | 33 ++++++++++--------- .../abstractremotelinuxdeploystep.h | 3 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp b/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp index 64bf07538c5..06cc78c655c 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp @@ -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 diff --git a/src/plugins/remotelinux/abstractremotelinuxdeploystep.h b/src/plugins/remotelinux/abstractremotelinuxdeploystep.h index f83a3215a79..19eedcd79f7 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeploystep.h +++ b/src/plugins/remotelinux/abstractremotelinuxdeploystep.h @@ -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; };