AppMan: Use current setup pattern for build steps

Change-Id: Ia69b9ea67fdec6a33f13fba665ee4589e82a2574
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2024-01-10 18:04:51 +01:00
parent f6cc15c2b7
commit 1936103fe6
13 changed files with 239 additions and 232 deletions

View File

@@ -7,7 +7,9 @@
#include "appmanagerconstants.h" #include "appmanagerconstants.h"
#include "appmanagertargetinformation.h" #include "appmanagertargetinformation.h"
#include "appmanagertr.h"
#include <projectexplorer/buildstep.h>
#include <projectexplorer/deployconfiguration.h> #include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/processparameters.h> #include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -16,19 +18,20 @@
#include <cmakeprojectmanager/cmakeprojectconstants.h> #include <cmakeprojectmanager/cmakeprojectconstants.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace CMakeProjectManager;
using namespace Utils; using namespace Utils;
namespace AppManager { namespace AppManager::Internal {
namespace Internal {
AppManagerCMakePackageStepFactory::AppManagerCMakePackageStepFactory() class AppManagerCMakePackageStepFactory final : public BuildStepFactory
{
public:
AppManagerCMakePackageStepFactory()
{ {
cloneStepCreator(CMakeProjectManager::Constants::CMAKE_BUILD_STEP_ID, Constants::CMAKE_PACKAGE_STEP_ID); cloneStepCreator(CMakeProjectManager::Constants::CMAKE_BUILD_STEP_ID, Constants::CMAKE_PACKAGE_STEP_ID);
setExtraInit([] (BuildStep *step) { setExtraInit([] (BuildStep *step) {
// We update the build targets when the active run configuration changes // We update the build targets when the active run configuration changes
const auto updaterSlot = [step] { const auto updaterSlot = [step] {
const auto targetInformation = TargetInformation(step->target()); const TargetInformation targetInformation(step->target());
step->setBuildTargets({targetInformation.cmakeBuildTarget}); step->setBuildTargets({targetInformation.cmakeBuildTarget});
step->setEnabled(!targetInformation.isBuiltin); step->setEnabled(!targetInformation.isBuiltin);
}; };
@@ -39,9 +42,14 @@ AppManagerCMakePackageStepFactory::AppManagerCMakePackageStepFactory()
QObject::connect(step->project(), &Project::displayNameChanged, step, updaterSlot); QObject::connect(step->project(), &Project::displayNameChanged, step, updaterSlot);
}); });
setDisplayName(tr("Create Appman package with CMake")); setDisplayName(Tr::tr("Create Appman package with CMake"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
} }
};
} // namespace Internal void setupAppManagerCMakePackageStep()
} // namespace AppManager {
static AppManagerCMakePackageStepFactory theAppManagerCMakePackageStepFactory;
}
} // AppManager::Internal

View File

@@ -5,20 +5,8 @@
#pragma once #pragma once
#include <projectexplorer/buildstep.h> namespace AppManager::Internal {
#include <QCoreApplication> void setupAppManagerCMakePackageStep();
namespace AppManager { } // AppManager::Internal
namespace Internal {
class AppManagerCMakePackageStepFactory final : public ProjectExplorer::BuildStepFactory
{
Q_DECLARE_TR_FUNCTIONS(Qtc::AppManager)
public:
AppManagerCMakePackageStepFactory();
};
} // namespace Internal
} // namespace AppManager

View File

@@ -8,9 +8,11 @@
#include "appmanagerconstants.h" #include "appmanagerconstants.h"
#include "appmanagerstringaspect.h" #include "appmanagerstringaspect.h"
#include "appmanagertargetinformation.h" #include "appmanagertargetinformation.h"
#include "appmanagertr.h"
#include "appmanagerutilities.h" #include "appmanagerutilities.h"
#include <projectexplorer/abstractprocessstep.h> #include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/deployconfiguration.h> #include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/processparameters.h> #include <projectexplorer/processparameters.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -21,8 +23,7 @@
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace AppManager { namespace AppManager::Internal {
namespace Internal {
#define SETTINGSPREFIX "ApplicationManagerPlugin.Deploy.CreatePackageStep." #define SETTINGSPREFIX "ApplicationManagerPlugin.Deploy.CreatePackageStep."
@@ -31,48 +32,36 @@ const char ArgumentsDefault[] = "create-package --verbose --json";
class AppManagerCreatePackageStep final : public AbstractProcessStep class AppManagerCreatePackageStep final : public AbstractProcessStep
{ {
public: public:
AppManagerCreatePackageStep(BuildStepList *bsl, Id id); AppManagerCreatePackageStep(BuildStepList *bsl, Id id)
bool init() final;
private:
AppManagerFilePathAspect executable{this};
AppManagerStringAspect arguments{this};
AppManagerFilePathAspect sourceDirectory{this};
AppManagerFilePathAspect buildDirectory{this};
AppManagerStringAspect packageFileName{this};
};
AppManagerCreatePackageStep::AppManagerCreatePackageStep(BuildStepList *bsl, Id id)
: AbstractProcessStep(bsl, id) : AbstractProcessStep(bsl, id)
{ {
setDisplayName(tr("Create Application Manager package")); setDisplayName(Tr::tr("Create Application Manager package"));
executable.setSettingsKey(SETTINGSPREFIX "Executable"); executable.setSettingsKey(SETTINGSPREFIX "Executable");
executable.setHistoryCompleter(SETTINGSPREFIX "Executable.History"); executable.setHistoryCompleter(SETTINGSPREFIX "Executable.History");
executable.setExpectedKind(PathChooser::ExistingCommand); executable.setExpectedKind(PathChooser::ExistingCommand);
executable.setLabelText(tr("Executable:")); executable.setLabelText(Tr::tr("Executable:"));
executable.setPromptDialogFilter(getToolNameByDevice(Constants::APPMAN_PACKAGER)); executable.setPromptDialogFilter(getToolNameByDevice(Constants::APPMAN_PACKAGER));
arguments.setSettingsKey(SETTINGSPREFIX "Arguments"); arguments.setSettingsKey(SETTINGSPREFIX "Arguments");
arguments.setHistoryCompleter(SETTINGSPREFIX "Arguments.History"); arguments.setHistoryCompleter(SETTINGSPREFIX "Arguments.History");
arguments.setDisplayStyle(StringAspect::LineEditDisplay); arguments.setDisplayStyle(StringAspect::LineEditDisplay);
arguments.setLabelText(tr("Arguments:")); arguments.setLabelText(Tr::tr("Arguments:"));
sourceDirectory.setSettingsKey(SETTINGSPREFIX "SourceDirectory"); sourceDirectory.setSettingsKey(SETTINGSPREFIX "SourceDirectory");
sourceDirectory.setHistoryCompleter(SETTINGSPREFIX "SourceDirectory.History"); sourceDirectory.setHistoryCompleter(SETTINGSPREFIX "SourceDirectory.History");
sourceDirectory.setExpectedKind(PathChooser::Directory); sourceDirectory.setExpectedKind(PathChooser::Directory);
sourceDirectory.setLabelText(tr("Source directory:")); sourceDirectory.setLabelText(Tr::tr("Source directory:"));
buildDirectory.setSettingsKey(SETTINGSPREFIX "BuildDirectory"); buildDirectory.setSettingsKey(SETTINGSPREFIX "BuildDirectory");
buildDirectory.setHistoryCompleter(SETTINGSPREFIX "BuildDirectory.History"); buildDirectory.setHistoryCompleter(SETTINGSPREFIX "BuildDirectory.History");
buildDirectory.setExpectedKind(PathChooser::Directory); buildDirectory.setExpectedKind(PathChooser::Directory);
buildDirectory.setLabelText(tr("Build directory:")); buildDirectory.setLabelText(Tr::tr("Build directory:"));
packageFileName.setSettingsKey(SETTINGSPREFIX "FileName"); packageFileName.setSettingsKey(SETTINGSPREFIX "FileName");
packageFileName.setHistoryCompleter(SETTINGSPREFIX "FileName.History"); packageFileName.setHistoryCompleter(SETTINGSPREFIX "FileName.History");
packageFileName.setDisplayStyle(StringAspect::LineEditDisplay); packageFileName.setDisplayStyle(StringAspect::LineEditDisplay);
packageFileName.setLabelText(tr("Package file name:")); packageFileName.setLabelText(Tr::tr("Package file name:"));
const auto updateAspects = [this] { const auto updateAspects = [this] {
const auto targetInformation = TargetInformation(target()); const auto targetInformation = TargetInformation(target());
@@ -94,7 +83,7 @@ AppManagerCreatePackageStep::AppManagerCreatePackageStep(BuildStepList *bsl, Id
updateAspects(); updateAspects();
} }
bool AppManagerCreatePackageStep::init() bool init() final
{ {
if (!AbstractProcessStep::init()) if (!AbstractProcessStep::init())
return false; return false;
@@ -118,14 +107,30 @@ bool AppManagerCreatePackageStep::init()
return true; return true;
} }
private:
AppManagerFilePathAspect executable{this};
AppManagerStringAspect arguments{this};
AppManagerFilePathAspect sourceDirectory{this};
AppManagerFilePathAspect buildDirectory{this};
AppManagerStringAspect packageFileName{this};
};
// Factory // Factory
AppManagerCreatePackageStepFactory::AppManagerCreatePackageStepFactory() class AppManagerCreatePackageStepFactory final : public BuildStepFactory
{
public:
AppManagerCreatePackageStepFactory()
{ {
registerStep<AppManagerCreatePackageStep>(Constants::CREATE_PACKAGE_STEP_ID); registerStep<AppManagerCreatePackageStep>(Constants::CREATE_PACKAGE_STEP_ID);
setDisplayName(AppManagerCreatePackageStep::tr("Create Application Manager package")); setDisplayName(Tr::tr("Create Application Manager package"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
} }
};
} // namespace Internal void setupAppManagerCreatePackageStep()
} // namespace AppManager {
static AppManagerCreatePackageStepFactory theAppManagerCreatePackageStepFactory;
}
} // AppManager::Internal

View File

@@ -5,16 +5,8 @@
#pragma once #pragma once
#include <projectexplorer/buildstep.h> namespace AppManager::Internal {
namespace AppManager { void setupAppManagerCreatePackageStep();
namespace Internal {
class AppManagerCreatePackageStepFactory final : public ProjectExplorer::BuildStepFactory } // AppManager::Internal
{
public:
AppManagerCreatePackageStepFactory();
};
} // namespace Internal
} // namespace AppManager

View File

@@ -8,7 +8,9 @@
#include "appmanagerconstants.h" #include "appmanagerconstants.h"
#include "appmanagerstringaspect.h" #include "appmanagerstringaspect.h"
#include "appmanagertargetinformation.h" #include "appmanagertargetinformation.h"
#include "appmanagertr.h"
#include <projectexplorer/buildstep.h>
#include <projectexplorer/deployconfiguration.h> #include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -30,27 +32,25 @@ namespace AppManager::Internal {
class AppManagerDeployPackageStep : public BuildStep class AppManagerDeployPackageStep : public BuildStep
{ {
Q_DECLARE_TR_FUNCTIONS(AppManager::Internal::AppManagerDeployPackageStep)
public: public:
AppManagerDeployPackageStep(BuildStepList *bsl, Id id) AppManagerDeployPackageStep(BuildStepList *bsl, Id id)
: BuildStep(bsl, id) : BuildStep(bsl, id)
{ {
setDisplayName(tr("Deploy Application Manager package")); setDisplayName(Tr::tr("Deploy Application Manager package"));
packageFilePath.setSettingsKey(SETTINGSPREFIX "FilePath"); packageFilePath.setSettingsKey(SETTINGSPREFIX "FilePath");
packageFilePath.setHistoryCompleter(SETTINGSPREFIX "FilePath.History"); packageFilePath.setHistoryCompleter(SETTINGSPREFIX "FilePath.History");
packageFilePath.setExpectedKind(PathChooser::File); packageFilePath.setExpectedKind(PathChooser::File);
packageFilePath.setLabelText(tr("Package file path:")); packageFilePath.setLabelText(Tr::tr("Package file path:"));
targetDirectory.setSettingsKey(SETTINGSPREFIX "TargetDirectory"); targetDirectory.setSettingsKey(SETTINGSPREFIX "TargetDirectory");
targetDirectory.setHistoryCompleter(SETTINGSPREFIX "TargetDirectory.History"); targetDirectory.setHistoryCompleter(SETTINGSPREFIX "TargetDirectory.History");
targetDirectory.setExpectedKind(PathChooser::Directory); targetDirectory.setExpectedKind(PathChooser::Directory);
targetDirectory.setLabelText(tr("Target directory:")); targetDirectory.setLabelText(Tr::tr("Target directory:"));
targetDirectory.setButtonsVisible(false); targetDirectory.setButtonsVisible(false);
const auto updateAspects = [this] { const auto updateAspects = [this] {
const auto targetInformation = TargetInformation(target()); const TargetInformation targetInformation(target());
packageFilePath.setPlaceHolderPath(targetInformation.packageFile.absoluteFilePath()); packageFilePath.setPlaceHolderPath(targetInformation.packageFile.absoluteFilePath());
targetDirectory.setPlaceHolderPath(targetInformation.runDirectory.absolutePath()); targetDirectory.setPlaceHolderPath(targetInformation.runDirectory.absolutePath());
@@ -68,8 +68,13 @@ public:
} }
private: private:
bool init() final { return TargetInformation(target()).isValid(); } bool init() final
GroupItem runRecipe() final { {
return TargetInformation(target()).isValid();
}
GroupItem runRecipe() final
{
const auto onSetup = [this](FileStreamer &streamer) { const auto onSetup = [this](FileStreamer &streamer) {
const TargetInformation targetInformation(target()); const TargetInformation targetInformation(target());
const FilePath source = packageFilePath.valueOrDefault( const FilePath source = packageFilePath.valueOrDefault(
@@ -84,9 +89,9 @@ private:
}; };
const auto onDone = [this](DoneWith result) { const auto onDone = [this](DoneWith result) {
if (result == DoneWith::Success) if (result == DoneWith::Success)
emit addOutput(tr("Uploading finished"), OutputFormat::NormalMessage); emit addOutput(Tr::tr("Uploading finished"), OutputFormat::NormalMessage);
else else
emit addOutput(tr("Uploading failed"), OutputFormat::ErrorMessage); emit addOutput(Tr::tr("Uploading failed"), OutputFormat::ErrorMessage);
}; };
return FileStreamerTask(onSetup, onDone); return FileStreamerTask(onSetup, onDone);
} }
@@ -97,11 +102,20 @@ private:
// Factory // Factory
AppManagerDeployPackageStepFactory::AppManagerDeployPackageStepFactory() class AppManagerDeployPackageStepFactory final : public BuildStepFactory
{
public:
AppManagerDeployPackageStepFactory()
{ {
registerStep<AppManagerDeployPackageStep>(Constants::DEPLOY_PACKAGE_STEP_ID); registerStep<AppManagerDeployPackageStep>(Constants::DEPLOY_PACKAGE_STEP_ID);
setDisplayName(AppManagerDeployPackageStep::tr("Deploy Application Manager package")); setDisplayName(Tr::tr("Deploy Application Manager package"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
} }
};
void setupAppManagerDeployPackageStep()
{
static AppManagerDeployPackageStepFactory theAppManagerDeployPackageStepFactory;
}
} // namespace AppManager::Internal } // namespace AppManager::Internal

View File

@@ -5,14 +5,8 @@
#pragma once #pragma once
#include <projectexplorer/buildstep.h>
namespace AppManager::Internal { namespace AppManager::Internal {
class AppManagerDeployPackageStepFactory final : public ProjectExplorer::BuildStepFactory void setupAppManagerDeployPackageStep();
{
public:
AppManagerDeployPackageStepFactory();
};
} // namespace AppManager::Internal } // AppManager::Internal

View File

@@ -8,9 +8,11 @@
#include "appmanagerstringaspect.h" #include "appmanagerstringaspect.h"
#include "appmanagerconstants.h" #include "appmanagerconstants.h"
#include "appmanagertargetinformation.h" #include "appmanagertargetinformation.h"
#include "appmanagertr.h"
#include "appmanagerutilities.h" #include "appmanagerutilities.h"
#include <projectexplorer/abstractprocessstep.h> #include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/deployconfiguration.h> #include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/processparameters.h> #include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
@@ -46,26 +48,26 @@ private:
AppManagerInstallPackageStep::AppManagerInstallPackageStep(BuildStepList *bsl, Id id) AppManagerInstallPackageStep::AppManagerInstallPackageStep(BuildStepList *bsl, Id id)
: AbstractProcessStep(bsl, id) : AbstractProcessStep(bsl, id)
{ {
setDisplayName(tr("Install Application Manager package")); setDisplayName(Tr::tr("Install Application Manager package"));
executable.setSettingsKey(SETTINGSPREFIX "Executable"); executable.setSettingsKey(SETTINGSPREFIX "Executable");
executable.setHistoryCompleter(SETTINGSPREFIX "Executable.History"); executable.setHistoryCompleter(SETTINGSPREFIX "Executable.History");
executable.setLabelText(tr("Executable:")); executable.setLabelText(Tr::tr("Executable:"));
arguments.setSettingsKey(SETTINGSPREFIX "Arguments"); arguments.setSettingsKey(SETTINGSPREFIX "Arguments");
arguments.setHistoryCompleter(SETTINGSPREFIX "Arguments.History"); arguments.setHistoryCompleter(SETTINGSPREFIX "Arguments.History");
arguments.setDisplayStyle(StringAspect::LineEditDisplay); arguments.setDisplayStyle(StringAspect::LineEditDisplay);
arguments.setLabelText(tr("Arguments:")); arguments.setLabelText(Tr::tr("Arguments:"));
packageFileName.setSettingsKey(SETTINGSPREFIX "FileName"); packageFileName.setSettingsKey(SETTINGSPREFIX "FileName");
packageFileName.setHistoryCompleter(SETTINGSPREFIX "FileName.History"); packageFileName.setHistoryCompleter(SETTINGSPREFIX "FileName.History");
packageFileName.setDisplayStyle(StringAspect::LineEditDisplay); packageFileName.setDisplayStyle(StringAspect::LineEditDisplay);
packageFileName.setLabelText(tr("File name:")); packageFileName.setLabelText(Tr::tr("File name:"));
packageDirectory.setSettingsKey(SETTINGSPREFIX "Directory"); packageDirectory.setSettingsKey(SETTINGSPREFIX "Directory");
packageDirectory.setHistoryCompleter(SETTINGSPREFIX "Directory.History"); packageDirectory.setHistoryCompleter(SETTINGSPREFIX "Directory.History");
packageDirectory.setExpectedKind(PathChooser::Directory); packageDirectory.setExpectedKind(PathChooser::Directory);
packageDirectory.setLabelText(tr("Directory:")); packageDirectory.setLabelText(Tr::tr("Directory:"));
const auto updateAspects = [this] { const auto updateAspects = [this] {
const TargetInformation targetInformation(target()); const TargetInformation targetInformation(target());
@@ -77,8 +79,8 @@ AppManagerInstallPackageStep::AppManagerInstallPackageStep(BuildStepList *bsl, I
arguments.setPlaceHolderText(ArgumentsDefault); arguments.setPlaceHolderText(ArgumentsDefault);
packageFileName.setPlaceHolderText(targetInformation.packageFile.fileName()); packageFileName.setPlaceHolderText(targetInformation.packageFile.fileName());
auto device = DeviceKitAspect::device(target()->kit()); auto device = DeviceKitAspect::device(target()->kit());
auto remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; bool remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
auto packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath(); QDir packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath();
packageDirectory.setPlaceHolderPath(packageDirectoryPath.absolutePath()); packageDirectory.setPlaceHolderPath(packageDirectoryPath.absolutePath());
packageDirectory.setButtonsVisible(!targetInformation.remote); packageDirectory.setButtonsVisible(!targetInformation.remote);
@@ -106,8 +108,8 @@ bool AppManagerInstallPackageStep::init()
const QString controllerArguments = arguments.valueOrDefault(ArgumentsDefault); const QString controllerArguments = arguments.valueOrDefault(ArgumentsDefault);
const QString packageFile = packageFileName.valueOrDefault(targetInformation.packageFile.fileName()); const QString packageFile = packageFileName.valueOrDefault(targetInformation.packageFile.fileName());
auto device = DeviceKitAspect::device(target()->kit()); auto device = DeviceKitAspect::device(target()->kit());
auto remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; bool remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
auto packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath(); QDir packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath();
const FilePath packageDir = packageDirectory.valueOrDefault(packageDirectoryPath.absolutePath()); const FilePath packageDir = packageDirectory.valueOrDefault(packageDirectoryPath.absolutePath());
CommandLine cmd(targetInformation.device->filePath(controller.path())); CommandLine cmd(targetInformation.device->filePath(controller.path()));
@@ -121,11 +123,20 @@ bool AppManagerInstallPackageStep::init()
// Factory // Factory
AppManagerInstallPackageStepFactory::AppManagerInstallPackageStepFactory() class AppManagerInstallPackageStepFactory final : public BuildStepFactory
{
public:
AppManagerInstallPackageStepFactory()
{ {
registerStep<AppManagerInstallPackageStep>(Constants::INSTALL_PACKAGE_STEP_ID); registerStep<AppManagerInstallPackageStep>(Constants::INSTALL_PACKAGE_STEP_ID);
setDisplayName(AppManagerInstallPackageStep::tr("Install Application Manager package")); setDisplayName(Tr::tr("Install Application Manager package"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
} }
};
void setupAppManagerInstallPackageStep()
{
static AppManagerInstallPackageStepFactory theAppManagerInstallPackageStepFactory;
}
} // namespace AppManager::Internal } // namespace AppManager::Internal

View File

@@ -5,14 +5,8 @@
#pragma once #pragma once
#include <projectexplorer/buildstep.h>
namespace AppManager::Internal { namespace AppManager::Internal {
class AppManagerInstallPackageStepFactory final : public ProjectExplorer::BuildStepFactory void setupAppManagerInstallPackageStep();
{
public:
AppManagerInstallPackageStepFactory();
};
} // namespace AppManager::Internal } // namespace AppManager::Internal

View File

@@ -8,6 +8,7 @@
#include "appmanagerconstants.h" #include "appmanagerconstants.h"
#include "appmanagertargetinformation.h" #include "appmanagertargetinformation.h"
#include <projectexplorer/makestep.h>
#include <projectexplorer/processparameters.h> #include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -15,15 +16,12 @@
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace AppManager { namespace AppManager::Internal {
namespace Internal {
class AppManagerMakeInstallStep final : public ProjectExplorer::MakeStep class AppManagerMakeInstallStep final : public MakeStep
{ {
Q_DECLARE_TR_FUNCTIONS(AppManager::Internal::AppManagerMakeInstallStep)
public: public:
AppManagerMakeInstallStep(BuildStepList *bsl, Utils::Id id) AppManagerMakeInstallStep(BuildStepList *bsl, Id id)
: MakeStep(bsl, id) : MakeStep(bsl, id)
{ {
setSelectedBuildTarget("install"); setSelectedBuildTarget("install");
@@ -34,16 +32,16 @@ public:
if (!MakeStep::init()) if (!MakeStep::init())
return false; return false;
const auto targetInformation = TargetInformation(target()); const TargetInformation targetInformation(target());
if (!targetInformation.isValid()) if (!targetInformation.isValid())
return false; return false;
const auto buildDirectoryPath = targetInformation.buildDirectory.absolutePath(); const QString buildDirectoryPath = targetInformation.buildDirectory.absolutePath();
if (buildDirectoryPath.isEmpty()) if (buildDirectoryPath.isEmpty())
return false; return false;
const auto buildDirectoryPathQuoted = ProcessArgs::quoteArg(QDir::toNativeSeparators(buildDirectoryPath)); const QString buildDirectoryPathQuoted = ProcessArgs::quoteArg(QDir::toNativeSeparators(buildDirectoryPath));
const auto installRoot = QString("INSTALL_ROOT=%1").arg(buildDirectoryPathQuoted); const QString installRoot = QString("INSTALL_ROOT=%1").arg(buildDirectoryPathQuoted);
processParameters()->setWorkingDirectory(FilePath::fromString(buildDirectoryPath)); processParameters()->setWorkingDirectory(FilePath::fromString(buildDirectoryPath));
@@ -55,14 +53,20 @@ public:
} }
}; };
// Factory class AppManagerMakeInstallStepFactory final : public BuildStepFactory
{
AppManagerMakeInstallStepFactory::AppManagerMakeInstallStepFactory() public:
AppManagerMakeInstallStepFactory()
{ {
registerStep<AppManagerMakeInstallStep>(Constants::MAKE_INSTALL_STEP_ID); registerStep<AppManagerMakeInstallStep>(Constants::MAKE_INSTALL_STEP_ID);
setDisplayName(AppManagerMakeInstallStep::tr("Make install")); setDisplayName(AppManagerMakeInstallStep::tr("Make install"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
} }
};
} // namespace Internal void setupAppManagerMakeInstallStep()
} // namespace AppManager {
static AppManagerMakeInstallStepFactory theAppManagerMakeInstallStepFactory;
}
} // AppManager::Internal

View File

@@ -5,16 +5,8 @@
#pragma once #pragma once
#include <projectexplorer/makestep.h> namespace AppManager::Internal {
namespace AppManager { void setupAppManagerMakeInstallStep();
namespace Internal {
class AppManagerMakeInstallStepFactory final : public ProjectExplorer::BuildStepFactory } // AppManager::Internal
{
public:
AppManagerMakeInstallStepFactory();
};
} // namespace Internal
} // namespace AppManager

View File

@@ -5,7 +5,6 @@
#include "appmanagerplugin.h" #include "appmanagerplugin.h"
#include "appmanagerconstants.h"
#include "appmanagercreatepackagestep.h" #include "appmanagercreatepackagestep.h"
#include "appmanagerdeployconfigurationautoswitcher.h" #include "appmanagerdeployconfigurationautoswitcher.h"
#include "appmanagerdeployconfigurationfactory.h" #include "appmanagerdeployconfigurationfactory.h"
@@ -74,13 +73,6 @@ void cloneAutodetectedBoot2QtKits()
class AppManagerPluginPrivate class AppManagerPluginPrivate
{ {
public: public:
AppManagerCMakePackageStepFactory cmakePackageStepFactory;
AppManagerMakeInstallStepFactory makeInstallStepFactory;
AppManagerCreatePackageStepFactory createPackageStepFactory;
AppManagerDeployPackageStepFactory deployPackageStepFactory;
AppManagerInstallPackageStepFactory installPackageStepFactory;
AppManagerRemoteInstallPackageStepFactory remoteInstallPackageStepFactory;
AppManagerDeployConfigurationAutoSwitcher deployConfigurationAutoSwitcher; AppManagerDeployConfigurationAutoSwitcher deployConfigurationAutoSwitcher;
AppManagerDeployConfigurationFactory deployConfigFactory; AppManagerDeployConfigurationFactory deployConfigFactory;
@@ -96,6 +88,13 @@ AppManagerPlugin::~AppManagerPlugin()
void AppManagerPlugin::initialize() void AppManagerPlugin::initialize()
{ {
setupAppManagerCMakePackageStep();
setupAppManagerMakeInstallStep();
setupAppManagerCreatePackageStep();
setupAppManagerDeployPackageStep();
setupAppManagerInstallPackageStep();
setupAppManagerRemoteInstallPackageStep();
d = new AppManagerPluginPrivate; d = new AppManagerPluginPrivate;
d->deployConfigurationAutoSwitcher.initialize(); d->deployConfigurationAutoSwitcher.initialize();

View File

@@ -8,16 +8,19 @@
#include "appmanagerstringaspect.h" #include "appmanagerstringaspect.h"
#include "appmanagerconstants.h" #include "appmanagerconstants.h"
#include "appmanagertargetinformation.h" #include "appmanagertargetinformation.h"
#include "appmanagertr.h"
#include "appmanagerutilities.h" #include "appmanagerutilities.h"
#include <remotelinux/abstractremotelinuxdeploystep.h> #include <remotelinux/abstractremotelinuxdeploystep.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/deployconfiguration.h> #include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/kitaspects.h>
#include <projectexplorer/processparameters.h> #include <projectexplorer/processparameters.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/kitaspects.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <utils/process.h> #include <utils/process.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -83,8 +86,8 @@ AppManagerRemoteInstallPackageStep::AppManagerRemoteInstallPackageStep(BuildStep
arguments.setPlaceHolderText(ArgumentsDefault); arguments.setPlaceHolderText(ArgumentsDefault);
packageFileName.setPlaceHolderText(targetInformation.packageFile.fileName()); packageFileName.setPlaceHolderText(targetInformation.packageFile.fileName());
auto device = DeviceKitAspect::device(target()->kit()); auto device = DeviceKitAspect::device(target()->kit());
auto remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; bool remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
auto packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath(); QDir packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath();
packageDirectory.setPlaceHolderPath(packageDirectoryPath.absolutePath()); packageDirectory.setPlaceHolderPath(packageDirectoryPath.absolutePath());
packageDirectory.setButtonsVisible(!targetInformation.remote); packageDirectory.setButtonsVisible(!targetInformation.remote);
@@ -107,8 +110,8 @@ GroupItem AppManagerRemoteInstallPackageStep::deployRecipe()
const QString controllerArguments = arguments.valueOrDefault(ArgumentsDefault); const QString controllerArguments = arguments.valueOrDefault(ArgumentsDefault);
const QString packageFile = packageFileName.valueOrDefault(targetInformation.packageFile.fileName()); const QString packageFile = packageFileName.valueOrDefault(targetInformation.packageFile.fileName());
auto device = DeviceKitAspect::device(target()->kit()); auto device = DeviceKitAspect::device(target()->kit());
auto remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; bool remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
auto packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath(); QDir packageDirectoryPath = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : targetInformation.packageFile.absolutePath();
const FilePath packageDir = packageDirectory.valueOrDefault(packageDirectoryPath.absolutePath()); const FilePath packageDir = packageDirectory.valueOrDefault(packageDirectoryPath.absolutePath());
const auto setupHandler = [=](Process &process) { const auto setupHandler = [=](Process &process) {
@@ -120,7 +123,7 @@ GroupItem AppManagerRemoteInstallPackageStep::deployRecipe()
cmd.addArg("-c"); cmd.addArg("-c");
cmd.addCommandLineAsSingleArg(remoteCmd); cmd.addCommandLineAsSingleArg(remoteCmd);
addProgressMessage(tr("Starting remote command \"%1\"...").arg(cmd.toUserOutput())); addProgressMessage(Tr::tr("Starting remote command \"%1\"...").arg(cmd.toUserOutput()));
process.setCommand(cmd); process.setCommand(cmd);
Process *proc = &process; Process *proc = &process;
connect(proc, &Process::readyReadStandardOutput, this, [this, proc] { connect(proc, &Process::readyReadStandardOutput, this, [this, proc] {
@@ -136,9 +139,9 @@ GroupItem AppManagerRemoteInstallPackageStep::deployRecipe()
} else { } else {
if (process.error() != QProcess::UnknownError if (process.error() != QProcess::UnknownError
|| process.exitStatus() != QProcess::NormalExit) { || process.exitStatus() != QProcess::NormalExit) {
addErrorMessage(tr("Remote process failed: %1").arg(process.errorString())); addErrorMessage(Tr::tr("Remote process failed: %1").arg(process.errorString()));
} else if (process.exitCode() != 0) { } else if (process.exitCode() != 0) {
addErrorMessage(tr("Remote process finished with exit code %1.") addErrorMessage(Tr::tr("Remote process finished with exit code %1.")
.arg(process.exitCode())); .arg(process.exitCode()));
} }
} }
@@ -149,11 +152,20 @@ GroupItem AppManagerRemoteInstallPackageStep::deployRecipe()
// Factory // Factory
AppManagerRemoteInstallPackageStepFactory::AppManagerRemoteInstallPackageStepFactory() class AppManagerRemoteInstallPackageStepFactory final : public BuildStepFactory
{
public:
AppManagerRemoteInstallPackageStepFactory()
{ {
registerStep<AppManagerRemoteInstallPackageStep>(Constants::REMOTE_INSTALL_PACKAGE_STEP_ID); registerStep<AppManagerRemoteInstallPackageStep>(Constants::REMOTE_INSTALL_PACKAGE_STEP_ID);
setDisplayName(AppManagerRemoteInstallPackageStep::tr("Remote Install Application Manager package")); setDisplayName(Tr::tr("Remote Install Application Manager package"));
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
} }
};
void setupAppManagerRemoteInstallPackageStep()
{
static AppManagerRemoteInstallPackageStepFactory theAppManagerRemoteInstallPackageStepFactory;
}
} // namespace AppManager::Internal } // namespace AppManager::Internal

View File

@@ -5,14 +5,8 @@
#pragma once #pragma once
#include <projectexplorer/buildstep.h>
namespace AppManager::Internal { namespace AppManager::Internal {
class AppManagerRemoteInstallPackageStepFactory final : public ProjectExplorer::BuildStepFactory void setupAppManagerRemoteInstallPackageStep();
{
public:
AppManagerRemoteInstallPackageStepFactory();
};
} // namespace AppManager::Internal } // namespace AppManager::Internal