2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2022-05-26 15:10:06 +02:00
|
|
|
|
|
|
|
|
#include "killappstep.h"
|
|
|
|
|
|
2022-07-01 15:59:17 +02:00
|
|
|
#include "abstractremotelinuxdeploystep.h"
|
2022-05-26 15:10:06 +02:00
|
|
|
#include "remotelinux_constants.h"
|
2022-07-01 15:59:17 +02:00
|
|
|
#include "remotelinuxtr.h"
|
2022-05-26 15:10:06 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/devicesupport/idevice.h>
|
2022-07-01 15:59:17 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2023-08-16 19:24:06 +02:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2022-05-26 15:10:06 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2022-07-01 15:59:17 +02:00
|
|
|
|
2023-08-16 19:24:06 +02:00
|
|
|
#include <utils/processinterface.h>
|
2022-05-26 15:10:06 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
2023-05-10 19:54:52 +02:00
|
|
|
using namespace Tasking;
|
2022-05-26 15:10:06 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2022-07-01 15:59:17 +02:00
|
|
|
namespace RemoteLinux::Internal {
|
2022-05-26 15:10:06 +02:00
|
|
|
|
2023-03-21 16:07:20 +01:00
|
|
|
class KillAppStep : public AbstractRemoteLinuxDeployStep
|
2022-05-26 15:10:06 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2023-03-21 16:07:20 +01:00
|
|
|
KillAppStep(BuildStepList *bsl, Id id) : AbstractRemoteLinuxDeployStep(bsl, id)
|
|
|
|
|
{
|
|
|
|
|
setWidgetExpandedByDefault(false);
|
|
|
|
|
|
2023-07-07 11:40:12 +02:00
|
|
|
setInternalInitializer([this]() -> expected_str<void> {
|
2023-03-21 16:07:20 +01:00
|
|
|
Target * const theTarget = target();
|
2023-07-07 11:40:12 +02:00
|
|
|
QTC_ASSERT(theTarget, return make_unexpected(QString()));
|
2023-03-21 16:07:20 +01:00
|
|
|
RunConfiguration * const rc = theTarget->activeRunConfiguration();
|
|
|
|
|
m_remoteExecutable = rc ? rc->runnable().command.executable() : FilePath();
|
2023-07-07 11:40:12 +02:00
|
|
|
return {};
|
2023-03-21 16:07:20 +01:00
|
|
|
});
|
|
|
|
|
}
|
2022-05-26 15:10:06 +02:00
|
|
|
|
|
|
|
|
private:
|
2023-07-10 09:25:59 +02:00
|
|
|
GroupItem deployRecipe() final;
|
2022-05-26 15:10:06 +02:00
|
|
|
|
2022-09-01 08:00:21 +02:00
|
|
|
FilePath m_remoteExecutable;
|
2022-05-26 15:10:06 +02:00
|
|
|
};
|
|
|
|
|
|
2023-07-10 09:25:59 +02:00
|
|
|
GroupItem KillAppStep::deployRecipe()
|
2022-05-26 15:10:06 +02:00
|
|
|
{
|
2023-11-02 16:14:50 +01:00
|
|
|
const auto onSetup = [this](DeviceProcessKiller &killer) {
|
2023-10-23 17:13:41 +02:00
|
|
|
if (m_remoteExecutable.isEmpty()) {
|
|
|
|
|
addSkipDeploymentMessage();
|
2023-11-04 12:57:23 +01:00
|
|
|
return SetupResult::StopWithSuccess;
|
2023-10-23 17:13:41 +02:00
|
|
|
}
|
2022-11-24 16:09:29 +01:00
|
|
|
killer.setProcessPath(m_remoteExecutable);
|
2023-03-22 09:34:34 +01:00
|
|
|
addProgressMessage(Tr::tr("Trying to kill \"%1\" on remote device...")
|
|
|
|
|
.arg(m_remoteExecutable.path()));
|
2023-10-23 17:13:41 +02:00
|
|
|
return SetupResult::Continue;
|
2022-11-24 16:09:29 +01:00
|
|
|
};
|
2023-11-03 14:42:55 +01:00
|
|
|
const auto onDone = [this](DoneWith result) {
|
2023-11-03 09:42:55 +01:00
|
|
|
const QString message = result == DoneWith::Success ? Tr::tr("Remote application killed.")
|
|
|
|
|
: Tr::tr("Failed to kill remote application. Assuming it was not running.");
|
2023-11-02 16:14:50 +01:00
|
|
|
addProgressMessage(message);
|
2022-11-24 16:09:29 +01:00
|
|
|
};
|
2023-11-02 16:14:50 +01:00
|
|
|
return DeviceProcessKillerTask(onSetup, onDone);
|
2022-05-26 15:10:06 +02:00
|
|
|
}
|
|
|
|
|
|
2023-11-17 15:08:12 +01:00
|
|
|
class KillAppStepFactory final : public BuildStepFactory
|
2022-05-26 15:10:06 +02:00
|
|
|
{
|
2023-11-17 15:08:12 +01:00
|
|
|
public:
|
|
|
|
|
KillAppStepFactory()
|
|
|
|
|
{
|
|
|
|
|
registerStep<KillAppStep>(Constants::KillAppStepId);
|
|
|
|
|
setDisplayName(Tr::tr("Kill current application instance"));
|
|
|
|
|
setSupportedConfiguration(RemoteLinux::Constants::DeployToGenericLinux);
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void setupKillAppStep()
|
|
|
|
|
{
|
|
|
|
|
static KillAppStepFactory theKillAppStepFactory;
|
2022-05-26 15:10:06 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-01 15:59:17 +02:00
|
|
|
} // RemoteLinux::Internal
|