2023-12-15 13:09:36 +01:00
|
|
|
// 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 "appmanagerinstallpackagestep.h"
|
|
|
|
|
|
|
|
|
|
#include "appmanagerstringaspect.h"
|
|
|
|
|
#include "appmanagerconstants.h"
|
|
|
|
|
#include "appmanagertargetinformation.h"
|
2024-01-10 18:04:51 +01:00
|
|
|
#include "appmanagertr.h"
|
2023-12-15 13:09:36 +01:00
|
|
|
#include "appmanagerutilities.h"
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/abstractprocessstep.h>
|
2024-01-10 18:04:51 +01:00
|
|
|
#include <projectexplorer/buildstep.h>
|
2023-12-15 13:09:36 +01:00
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
|
|
|
|
#include <projectexplorer/processparameters.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
2023-12-20 10:38:09 +01:00
|
|
|
#include <projectexplorer/kitaspects.h>
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace AppManager::Internal {
|
|
|
|
|
|
|
|
|
|
#define SETTINGSPREFIX "ApplicationManagerPlugin.Deploy.InstallPackageStep."
|
|
|
|
|
|
|
|
|
|
const char ArgumentsDefault[] = "install-package -a";
|
|
|
|
|
|
|
|
|
|
class AppManagerInstallPackageStep final : public AbstractProcessStep
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(AppManager::Internal::AppManagerInstallPackageStep)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
AppManagerInstallPackageStep(BuildStepList *bsl, Id id);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
bool init() final;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
AppManagerFilePathAspect executable{this};
|
|
|
|
|
AppManagerStringAspect arguments{this};
|
|
|
|
|
AppManagerStringAspect packageFileName{this};
|
|
|
|
|
AppManagerFilePathAspect packageDirectory{this};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AppManagerInstallPackageStep::AppManagerInstallPackageStep(BuildStepList *bsl, Id id)
|
|
|
|
|
: AbstractProcessStep(bsl, id)
|
|
|
|
|
{
|
2024-01-10 18:04:51 +01:00
|
|
|
setDisplayName(Tr::tr("Install Application Manager package"));
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
executable.setSettingsKey(SETTINGSPREFIX "Executable");
|
|
|
|
|
executable.setHistoryCompleter(SETTINGSPREFIX "Executable.History");
|
2024-01-10 18:04:51 +01:00
|
|
|
executable.setLabelText(Tr::tr("Executable:"));
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
arguments.setSettingsKey(SETTINGSPREFIX "Arguments");
|
|
|
|
|
arguments.setHistoryCompleter(SETTINGSPREFIX "Arguments.History");
|
|
|
|
|
arguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
2024-01-10 18:04:51 +01:00
|
|
|
arguments.setLabelText(Tr::tr("Arguments:"));
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
packageFileName.setSettingsKey(SETTINGSPREFIX "FileName");
|
|
|
|
|
packageFileName.setHistoryCompleter(SETTINGSPREFIX "FileName.History");
|
|
|
|
|
packageFileName.setDisplayStyle(StringAspect::LineEditDisplay);
|
2024-01-10 18:04:51 +01:00
|
|
|
packageFileName.setLabelText(Tr::tr("File name:"));
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
packageDirectory.setSettingsKey(SETTINGSPREFIX "Directory");
|
|
|
|
|
packageDirectory.setHistoryCompleter(SETTINGSPREFIX "Directory.History");
|
|
|
|
|
packageDirectory.setExpectedKind(PathChooser::Directory);
|
2024-01-10 18:04:51 +01:00
|
|
|
packageDirectory.setLabelText(Tr::tr("Directory:"));
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
const auto updateAspects = [this] {
|
|
|
|
|
const TargetInformation targetInformation(target());
|
|
|
|
|
|
|
|
|
|
executable.setPromptDialogFilter(getToolNameByDevice(Constants::APPMAN_CONTROLLER, targetInformation.device));
|
|
|
|
|
executable.setButtonsVisible(!targetInformation.remote);
|
|
|
|
|
executable.setExpectedKind(targetInformation.remote ? PathChooser::Command : PathChooser::ExistingCommand);
|
|
|
|
|
executable.setPlaceHolderPath(getToolFilePath(Constants::APPMAN_CONTROLLER, target()->kit(), targetInformation.device));
|
|
|
|
|
arguments.setPlaceHolderText(ArgumentsDefault);
|
|
|
|
|
packageFileName.setPlaceHolderText(targetInformation.packageFile.fileName());
|
2023-12-20 10:38:09 +01:00
|
|
|
auto device = DeviceKitAspect::device(target()->kit());
|
2024-01-10 18:04:51 +01:00
|
|
|
bool remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
|
|
|
|
QDir packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath();
|
2023-12-20 10:38:09 +01:00
|
|
|
packageDirectory.setPlaceHolderPath(packageDirectoryPath.absolutePath());
|
2023-12-15 13:09:36 +01:00
|
|
|
packageDirectory.setButtonsVisible(!targetInformation.remote);
|
2023-12-20 10:38:09 +01:00
|
|
|
|
|
|
|
|
setEnabled(!targetInformation.isBuiltin);
|
2023-12-15 13:09:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
connect(target(), &Target::activeRunConfigurationChanged, this, updateAspects);
|
|
|
|
|
connect(target(), &Target::activeDeployConfigurationChanged, this, updateAspects);
|
|
|
|
|
connect(target(), &Target::parsingFinished, this, updateAspects);
|
2023-12-20 10:38:09 +01:00
|
|
|
connect(target(), &Target::runConfigurationsUpdated, this, updateAspects);
|
2023-12-15 13:09:36 +01:00
|
|
|
connect(project(), &Project::displayNameChanged, this, updateAspects);
|
|
|
|
|
updateAspects();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppManagerInstallPackageStep::init()
|
|
|
|
|
{
|
|
|
|
|
if (!AbstractProcessStep::init())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const TargetInformation targetInformation(target());
|
|
|
|
|
if (!targetInformation.isValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const FilePath controller = executable.valueOrDefault(getToolFilePath(Constants::APPMAN_CONTROLLER, target()->kit(), targetInformation.device));
|
|
|
|
|
const QString controllerArguments = arguments.valueOrDefault(ArgumentsDefault);
|
|
|
|
|
const QString packageFile = packageFileName.valueOrDefault(targetInformation.packageFile.fileName());
|
2023-12-20 10:38:09 +01:00
|
|
|
auto device = DeviceKitAspect::device(target()->kit());
|
2024-01-10 18:04:51 +01:00
|
|
|
bool remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
|
|
|
|
QDir packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath();
|
2023-12-20 10:38:09 +01:00
|
|
|
const FilePath packageDir = packageDirectory.valueOrDefault(packageDirectoryPath.absolutePath());
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
CommandLine cmd(targetInformation.device->filePath(controller.path()));
|
|
|
|
|
cmd.addArgs(controllerArguments, CommandLine::Raw);
|
|
|
|
|
cmd.addArg(packageFile);
|
|
|
|
|
processParameters()->setWorkingDirectory(packageDir);
|
|
|
|
|
processParameters()->setCommandLine(cmd);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Factory
|
|
|
|
|
|
2024-01-10 18:04:51 +01:00
|
|
|
class AppManagerInstallPackageStepFactory final : public BuildStepFactory
|
2023-12-15 13:09:36 +01:00
|
|
|
{
|
2024-01-10 18:04:51 +01:00
|
|
|
public:
|
|
|
|
|
AppManagerInstallPackageStepFactory()
|
|
|
|
|
{
|
|
|
|
|
registerStep<AppManagerInstallPackageStep>(Constants::INSTALL_PACKAGE_STEP_ID);
|
|
|
|
|
setDisplayName(Tr::tr("Install Application Manager package"));
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void setupAppManagerInstallPackageStep()
|
|
|
|
|
{
|
|
|
|
|
static AppManagerInstallPackageStepFactory theAppManagerInstallPackageStepFactory;
|
2023-12-15 13:09:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace AppManager::Internal
|