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>
|
2024-01-15 17:18:47 +01:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2023-12-15 13:09:36 +01:00
|
|
|
#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."
|
|
|
|
|
|
2024-01-17 18:03:04 +01:00
|
|
|
const char ArgumentsDefault[] = "install-package --acknowledge";
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
class AppManagerInstallPackageStep final : public AbstractProcessStep
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AppManagerInstallPackageStep(BuildStepList *bsl, Id id);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
bool init() final;
|
|
|
|
|
|
|
|
|
|
private:
|
2024-01-17 18:03:04 +01:00
|
|
|
AppManagerCustomizeAspect customizeStep{this};
|
2024-01-15 17:18:47 +01:00
|
|
|
AppManagerControllerAspect controller{this};
|
|
|
|
|
ProjectExplorer::ArgumentsAspect arguments{this};
|
|
|
|
|
FilePathAspect packageFile{this};
|
2023-12-15 13:09:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2024-01-17 18:03:04 +01:00
|
|
|
controller.setDefaultValue(getToolFilePath(Constants::APPMAN_CONTROLLER,
|
|
|
|
|
kit(),
|
|
|
|
|
DeviceKitAspect::device(kit())));
|
|
|
|
|
|
2023-12-15 13:09:36 +01:00
|
|
|
arguments.setSettingsKey(SETTINGSPREFIX "Arguments");
|
2024-01-17 18:03:04 +01:00
|
|
|
arguments.setResetter([] { return QLatin1String(ArgumentsDefault); });
|
|
|
|
|
arguments.resetArguments();
|
2023-12-15 13:09:36 +01:00
|
|
|
|
2024-01-15 17:18:47 +01:00
|
|
|
packageFile.setSettingsKey(SETTINGSPREFIX "FileName");
|
|
|
|
|
packageFile.setLabelText(Tr::tr("Package file:"));
|
2024-01-17 18:03:04 +01:00
|
|
|
packageFile.setEnabler(&customizeStep);
|
2023-12-15 13:09:36 +01:00
|
|
|
|
|
|
|
|
const auto updateAspects = [this] {
|
2024-01-17 18:03:04 +01:00
|
|
|
if (customizeStep.value())
|
|
|
|
|
return;
|
2023-12-15 13:09:36 +01:00
|
|
|
|
2024-01-17 18:03:04 +01:00
|
|
|
const TargetInformation targetInformation(target());
|
2024-01-15 17:18:47 +01:00
|
|
|
|
2024-01-17 18:03:04 +01:00
|
|
|
packageFile.setDefaultValue(targetInformation.packageFile.absoluteFilePath());
|
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);
|
2024-01-17 18:03:04 +01:00
|
|
|
connect(&customizeStep, &BaseAspect::changed, this, updateAspects);
|
2023-12-15 13:09:36 +01:00
|
|
|
updateAspects();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppManagerInstallPackageStep::init()
|
|
|
|
|
{
|
|
|
|
|
if (!AbstractProcessStep::init())
|
|
|
|
|
return false;
|
|
|
|
|
|
2024-01-15 17:18:47 +01:00
|
|
|
const FilePath controllerPath = controller().isEmpty() ?
|
|
|
|
|
FilePath::fromString(controller.defaultValue()) :
|
|
|
|
|
controller();
|
|
|
|
|
const QString controllerArguments = arguments();
|
|
|
|
|
const FilePath packageFilePath = packageFile().isEmpty() ?
|
|
|
|
|
FilePath::fromString(packageFile.defaultValue()) :
|
|
|
|
|
packageFile();
|
2023-12-15 13:09:36 +01:00
|
|
|
|
2024-01-15 17:18:47 +01:00
|
|
|
CommandLine cmd(controllerPath);
|
2023-12-15 13:09:36 +01:00
|
|
|
cmd.addArgs(controllerArguments, CommandLine::Raw);
|
2024-01-15 17:18:47 +01:00
|
|
|
cmd.addArg(packageFilePath.nativePath());
|
2023-12-15 13:09:36 +01:00
|
|
|
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
|