forked from qt-creator/qt-creator
AppMan: Remove the "Remote Package installation" step
Instead of having a local and a remote step, we can use a single step for both cases. The code of the remote step is now used also locally. Change-Id: I08d3b07761b77b3618f3db001a0d83d1eea65421 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -12,7 +12,6 @@ add_qtc_plugin(QtApplicationManagerIntegration
|
||||
appmanagerdeployconfigurationfactory.cpp appmanagerdeployconfigurationfactory.h
|
||||
appmanagerdeploypackagestep.cpp appmanagerdeploypackagestep.h
|
||||
appmanagerinstallpackagestep.cpp appmanagerinstallpackagestep.h
|
||||
appmanagerremoteinstallpackagestep.cpp appmanagerremoteinstallpackagestep.h
|
||||
appmanagercmakepackagestep.cpp appmanagercmakepackagestep.h
|
||||
appmanagerplugin.cpp
|
||||
appmanagerrunconfiguration.cpp appmanagerrunconfiguration.h
|
||||
|
@@ -20,7 +20,6 @@ const char CMAKE_PACKAGE_STEP_ID[] = "ApplicationManagerPlugin.Deploy.CMakePacka
|
||||
const char CREATE_PACKAGE_STEP_ID[] = "ApplicationManagerPlugin.Deploy.CreatePackageStep";
|
||||
const char DEPLOY_PACKAGE_STEP_ID[] = "ApplicationManagerPlugin.Deploy.DeployPackageStep";
|
||||
const char INSTALL_PACKAGE_STEP_ID[] = "ApplicationManagerPlugin.Deploy.InstallPackageStep";
|
||||
const char REMOTE_INSTALL_PACKAGE_STEP_ID[] = "ApplicationManagerPlugin.Deploy.RemoteInstallPackageStep";
|
||||
const char RUNCONFIGURATION_ID[] = "ApplicationManagerPlugin.Run.Configuration";
|
||||
const char RUNANDDEBUGCONFIGURATION_ID[] = "ApplicationManagerPlugin.RunAndDebug.Configuration";
|
||||
|
||||
|
@@ -37,11 +37,8 @@ public:
|
||||
addSupportedTargetDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
|
||||
|
||||
addInitialStep(Constants::CMAKE_PACKAGE_STEP_ID);
|
||||
addInitialStep(Constants::INSTALL_PACKAGE_STEP_ID, [](Target *target) {
|
||||
return !isNecessaryToDeploy(target);
|
||||
});
|
||||
addInitialStep(Constants::DEPLOY_PACKAGE_STEP_ID, isNecessaryToDeploy);
|
||||
addInitialStep(Constants::REMOTE_INSTALL_PACKAGE_STEP_ID, isNecessaryToDeploy);
|
||||
addInitialStep(Constants::INSTALL_PACKAGE_STEP_ID);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -11,17 +11,22 @@
|
||||
#include "appmanagertr.h"
|
||||
#include "appmanagerutilities.h"
|
||||
|
||||
#include <projectexplorer/abstractprocessstep.h>
|
||||
#include <remotelinux/abstractremotelinuxdeploystep.h>
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/deployconfiguration.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/processparameters.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
|
||||
#include <utils/process.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
using namespace Tasking;
|
||||
|
||||
namespace AppManager::Internal {
|
||||
|
||||
@@ -29,13 +34,13 @@ namespace AppManager::Internal {
|
||||
|
||||
const char ArgumentsDefault[] = "install-package --acknowledge";
|
||||
|
||||
class AppManagerInstallPackageStep final : public AbstractProcessStep
|
||||
class AppManagerInstallPackageStep final : public RemoteLinux::AbstractRemoteLinuxDeployStep
|
||||
{
|
||||
public:
|
||||
AppManagerInstallPackageStep(BuildStepList *bsl, Id id);
|
||||
|
||||
protected:
|
||||
bool init() final;
|
||||
private:
|
||||
GroupItem deployRecipe() final;
|
||||
|
||||
private:
|
||||
AppManagerCustomizeAspect customizeStep{this};
|
||||
@@ -45,11 +50,13 @@ private:
|
||||
};
|
||||
|
||||
AppManagerInstallPackageStep::AppManagerInstallPackageStep(BuildStepList *bsl, Id id)
|
||||
: AbstractProcessStep(bsl, id)
|
||||
: AbstractRemoteLinuxDeployStep(bsl, id)
|
||||
{
|
||||
setDisplayName(Tr::tr("Install Application Manager package"));
|
||||
setDisplayName(tr("Install Application Manager package"));
|
||||
|
||||
controller.setDefaultValue(getToolFilePath(Constants::APPMAN_CONTROLLER, kit()));
|
||||
controller.setDefaultValue(getToolFilePath(Constants::APPMAN_CONTROLLER,
|
||||
target()->kit(),
|
||||
DeviceKitAspect::device(target()->kit())));
|
||||
|
||||
arguments.setSettingsKey(SETTINGSPREFIX "Arguments");
|
||||
arguments.setResetter([] { return QLatin1String(ArgumentsDefault); });
|
||||
@@ -59,13 +66,21 @@ AppManagerInstallPackageStep::AppManagerInstallPackageStep(BuildStepList *bsl, I
|
||||
packageFile.setLabelText(Tr::tr("Package file:"));
|
||||
packageFile.setEnabler(&customizeStep);
|
||||
|
||||
setInternalInitializer([this] { return isDeploymentPossible(); });
|
||||
|
||||
const auto updateAspects = [this] {
|
||||
if (customizeStep.value())
|
||||
return;
|
||||
|
||||
const TargetInformation targetInformation(target());
|
||||
|
||||
packageFile.setDefaultValue(targetInformation.packageFilePath.toUserOutput());
|
||||
if (DeviceKitAspect::device(kit())->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
packageFile.setDefaultValue(targetInformation.packageFilePath.toUserOutput());
|
||||
} else {
|
||||
const Utils::FilePath packageFilePath = targetInformation.runDirectory.pathAppended(
|
||||
targetInformation.packageFilePath.fileName());
|
||||
packageFile.setDefaultValue(packageFilePath.toUserOutput());
|
||||
}
|
||||
|
||||
setEnabled(!targetInformation.isBuiltin);
|
||||
};
|
||||
@@ -79,10 +94,9 @@ AppManagerInstallPackageStep::AppManagerInstallPackageStep(BuildStepList *bsl, I
|
||||
updateAspects();
|
||||
}
|
||||
|
||||
bool AppManagerInstallPackageStep::init()
|
||||
GroupItem AppManagerInstallPackageStep::deployRecipe()
|
||||
{
|
||||
if (!AbstractProcessStep::init())
|
||||
return false;
|
||||
const TargetInformation targetInformation(target());
|
||||
|
||||
const FilePath controllerPath = controller().isEmpty() ?
|
||||
FilePath::fromString(controller.defaultValue()) :
|
||||
@@ -92,12 +106,39 @@ bool AppManagerInstallPackageStep::init()
|
||||
FilePath::fromString(packageFile.defaultValue()) :
|
||||
packageFile();
|
||||
|
||||
CommandLine cmd(controllerPath);
|
||||
cmd.addArgs(controllerArguments, CommandLine::Raw);
|
||||
cmd.addArg(packageFilePath.nativePath());
|
||||
processParameters()->setCommandLine(cmd);
|
||||
const auto setupHandler = [=](Process &process) {
|
||||
CommandLine cmd(controllerPath);
|
||||
cmd.addArgs(controllerArguments, CommandLine::Raw);
|
||||
cmd.addArg(packageFilePath.nativePath());
|
||||
|
||||
return true;
|
||||
addProgressMessage(Tr::tr("Starting command \"%1\".").arg(cmd.displayName()));
|
||||
|
||||
process.setCommand(cmd);
|
||||
// Prevent the write channel to be closed, otherwise the appman-controller will exit
|
||||
process.setProcessMode(ProcessMode::Writer);
|
||||
Process *proc = &process;
|
||||
connect(proc, &Process::readyReadStandardOutput, this, [this, proc] {
|
||||
handleStdOutData(proc->readAllStandardOutput());
|
||||
});
|
||||
connect(proc, &Process::readyReadStandardError, this, [this, proc] {
|
||||
handleStdErrData(proc->readAllStandardError());
|
||||
});
|
||||
};
|
||||
const auto doneHandler = [this](const Process &process, DoneWith result) {
|
||||
if (result == DoneWith::Success) {
|
||||
addProgressMessage(tr("Command finished successfully."));
|
||||
} else {
|
||||
if (process.error() != QProcess::UnknownError
|
||||
|| process.exitStatus() != QProcess::NormalExit) {
|
||||
addErrorMessage(Tr::tr("Process failed: %1").arg(process.errorString()));
|
||||
} else if (process.exitCode() != 0) {
|
||||
addErrorMessage(Tr::tr("Process finished with exit code %1.")
|
||||
.arg(process.exitCode()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return ProcessTask(setupHandler, doneHandler);
|
||||
}
|
||||
|
||||
// Factory
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#include "appmanagerdeployconfigurationfactory.h"
|
||||
#include "appmanagerdeploypackagestep.h"
|
||||
#include "appmanagerinstallpackagestep.h"
|
||||
#include "appmanagerremoteinstallpackagestep.h"
|
||||
#include "appmanagercmakepackagestep.h"
|
||||
#include "appmanagerrunconfiguration.h"
|
||||
#include "appmanagerruncontrol.h"
|
||||
@@ -28,7 +27,6 @@ class AppManagerPlugin final : public ExtensionSystem::IPlugin
|
||||
setupAppManagerCreatePackageStep();
|
||||
setupAppManagerDeployPackageStep();
|
||||
setupAppManagerInstallPackageStep();
|
||||
setupAppManagerRemoteInstallPackageStep();
|
||||
|
||||
setupAppManagerDeployConfiguration();
|
||||
setupAppManagerDeployConfigurationAutoSwitcher();
|
||||
|
@@ -1,160 +0,0 @@
|
||||
// Copyright (C) 2019 Luxoft Sweden AB
|
||||
// Copyright (C) 2018 Pelagicore AG
|
||||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "appmanagerremoteinstallpackagestep.h"
|
||||
|
||||
#include "appmanagerstringaspect.h"
|
||||
#include "appmanagerconstants.h"
|
||||
#include "appmanagertargetinformation.h"
|
||||
#include "appmanagertr.h"
|
||||
#include "appmanagerutilities.h"
|
||||
|
||||
#include <remotelinux/abstractremotelinuxdeploystep.h>
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/deployconfiguration.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/processparameters.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
|
||||
#include <utils/process.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
using namespace Tasking;
|
||||
|
||||
namespace AppManager::Internal {
|
||||
|
||||
#define SETTINGSPREFIX "ApplicationManagerPlugin.Deploy.RemoteInstallPackageStep."
|
||||
|
||||
const char ArgumentsDefault[] = "install-package --acknowledge";
|
||||
|
||||
class AppManagerRemoteInstallPackageStep final : public RemoteLinux::AbstractRemoteLinuxDeployStep
|
||||
{
|
||||
public:
|
||||
AppManagerRemoteInstallPackageStep(BuildStepList *bsl, Id id);
|
||||
|
||||
private:
|
||||
GroupItem deployRecipe() final;
|
||||
|
||||
private:
|
||||
AppManagerCustomizeAspect customizeStep{this};
|
||||
AppManagerControllerAspect controller{this};
|
||||
ProjectExplorer::ArgumentsAspect arguments{this};
|
||||
FilePathAspect packageFile{this};
|
||||
};
|
||||
|
||||
AppManagerRemoteInstallPackageStep::AppManagerRemoteInstallPackageStep(BuildStepList *bsl, Id id)
|
||||
: AbstractRemoteLinuxDeployStep(bsl, id)
|
||||
{
|
||||
setDisplayName(tr("Remote Install Application Manager package"));
|
||||
|
||||
controller.setDefaultValue(getToolFilePath(Constants::APPMAN_CONTROLLER,
|
||||
target()->kit(),
|
||||
DeviceKitAspect::device(target()->kit())));
|
||||
|
||||
arguments.setSettingsKey(SETTINGSPREFIX "Arguments");
|
||||
arguments.setResetter([] { return QLatin1String(ArgumentsDefault); });
|
||||
arguments.resetArguments();
|
||||
|
||||
packageFile.setSettingsKey(SETTINGSPREFIX "FileName");
|
||||
packageFile.setLabelText(Tr::tr("Package file:"));
|
||||
packageFile.setEnabler(&customizeStep);
|
||||
|
||||
setInternalInitializer([this] { return isDeploymentPossible(); });
|
||||
|
||||
const auto updateAspects = [this] {
|
||||
if (customizeStep.value())
|
||||
return;
|
||||
|
||||
const TargetInformation targetInformation(target());
|
||||
|
||||
const Utils::FilePath packageFilePath =
|
||||
targetInformation.runDirectory.pathAppended(targetInformation.packageFilePath.fileName());
|
||||
|
||||
packageFile.setDefaultValue(packageFilePath.toUserOutput());
|
||||
|
||||
setEnabled(!targetInformation.isBuiltin);
|
||||
};
|
||||
|
||||
connect(target(), &Target::activeRunConfigurationChanged, this, updateAspects);
|
||||
connect(target(), &Target::activeDeployConfigurationChanged, this, updateAspects);
|
||||
connect(target(), &Target::parsingFinished, this, updateAspects);
|
||||
connect(target(), &Target::runConfigurationsUpdated, this, updateAspects);
|
||||
connect(project(), &Project::displayNameChanged, this, updateAspects);
|
||||
connect(&customizeStep, &BaseAspect::changed, this, updateAspects);
|
||||
updateAspects();
|
||||
}
|
||||
|
||||
GroupItem AppManagerRemoteInstallPackageStep::deployRecipe()
|
||||
{
|
||||
const TargetInformation targetInformation(target());
|
||||
|
||||
const FilePath controllerPath = controller().isEmpty() ?
|
||||
FilePath::fromString(controller.defaultValue()) :
|
||||
controller();
|
||||
const QString controllerArguments = arguments();
|
||||
const FilePath packageFilePath = packageFile().isEmpty() ?
|
||||
FilePath::fromString(packageFile.defaultValue()) :
|
||||
packageFile();
|
||||
|
||||
const auto setupHandler = [=](Process &process) {
|
||||
CommandLine remoteCmd(controllerPath);
|
||||
remoteCmd.addArgs(controllerArguments, CommandLine::Raw);
|
||||
remoteCmd.addArg(packageFilePath.nativePath());
|
||||
|
||||
CommandLine cmd(deviceConfiguration()->filePath("/bin/sh"));
|
||||
cmd.addArg("-c");
|
||||
cmd.addCommandLineAsSingleArg(remoteCmd);
|
||||
|
||||
addProgressMessage(Tr::tr("Starting remote command \"%1\"...").arg(cmd.toUserOutput()));
|
||||
process.setCommand(cmd);
|
||||
Process *proc = &process;
|
||||
connect(proc, &Process::readyReadStandardOutput, this, [this, proc] {
|
||||
handleStdOutData(proc->readAllStandardOutput());
|
||||
});
|
||||
connect(proc, &Process::readyReadStandardError, this, [this, proc] {
|
||||
handleStdErrData(proc->readAllStandardError());
|
||||
});
|
||||
};
|
||||
const auto doneHandler = [this](const Process &process, DoneWith result) {
|
||||
if (result == DoneWith::Success) {
|
||||
addProgressMessage(tr("Remote command finished successfully."));
|
||||
} else {
|
||||
if (process.error() != QProcess::UnknownError
|
||||
|| process.exitStatus() != QProcess::NormalExit) {
|
||||
addErrorMessage(Tr::tr("Remote process failed: %1").arg(process.errorString()));
|
||||
} else if (process.exitCode() != 0) {
|
||||
addErrorMessage(Tr::tr("Remote process finished with exit code %1.")
|
||||
.arg(process.exitCode()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return ProcessTask(setupHandler, doneHandler);
|
||||
}
|
||||
|
||||
// Factory
|
||||
|
||||
class AppManagerRemoteInstallPackageStepFactory final : public BuildStepFactory
|
||||
{
|
||||
public:
|
||||
AppManagerRemoteInstallPackageStepFactory()
|
||||
{
|
||||
registerStep<AppManagerRemoteInstallPackageStep>(Constants::REMOTE_INSTALL_PACKAGE_STEP_ID);
|
||||
setDisplayName(Tr::tr("Remote Install Application Manager package"));
|
||||
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
||||
}
|
||||
};
|
||||
|
||||
void setupAppManagerRemoteInstallPackageStep()
|
||||
{
|
||||
static AppManagerRemoteInstallPackageStepFactory theAppManagerRemoteInstallPackageStepFactory;
|
||||
}
|
||||
|
||||
} // namespace AppManager::Internal
|
@@ -1,12 +0,0 @@
|
||||
// Copyright (C) 2019 Luxoft Sweden AB
|
||||
// Copyright (C) 2018 Pelagicore AG
|
||||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace AppManager::Internal {
|
||||
|
||||
void setupAppManagerRemoteInstallPackageStep();
|
||||
|
||||
} // namespace AppManager::Internal
|
@@ -37,8 +37,6 @@ QtcPlugin {
|
||||
"appmanagerinstallpackagestep.cpp",
|
||||
"appmanagerinstallpackagestep.h",
|
||||
"appmanagerplugin.cpp",
|
||||
"appmanagerremoteinstallpackagestep.cpp",
|
||||
"appmanagerremoteinstallpackagestep.h",
|
||||
"appmanagerrunconfiguration.cpp",
|
||||
"appmanagerrunconfiguration.h",
|
||||
"appmanagerruncontrol.cpp",
|
||||
|
Reference in New Issue
Block a user