AppMan: Add Aspects to the RunConfiguration

Change-Id: Icf817279d76213bc5875f12ee74151f3d8fb1f44
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Dominik Holland
2024-01-15 13:02:14 +01:00
parent 5dfd572f0f
commit 15d0402694
4 changed files with 124 additions and 18 deletions

View File

@@ -6,8 +6,10 @@
#include "appmanagerrunconfiguration.h" #include "appmanagerrunconfiguration.h"
#include "appmanagerconstants.h" #include "appmanagerconstants.h"
#include "appmanagerstringaspect.h"
#include "appmanagertargetinformation.h" #include "appmanagertargetinformation.h"
#include "appmanagertr.h" #include "appmanagertr.h"
#include "appmanagerutilities.h"
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -29,7 +31,30 @@ public:
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
setDefaultDisplayName(Tr::tr("Run an Appman Package")); setDefaultDisplayName(Tr::tr("Run an Appman Package"));
setUpdater([this, target] {
QList<TargetInformation> tis = TargetInformation::readFromProject(target, buildKey());
if (tis.isEmpty())
return;
const TargetInformation targetInformation = tis.at(0);
controller.setValue(FilePath::fromString(getToolFilePath(Constants::APPMAN_CONTROLLER, target->kit(),
targetInformation.device)));
appId.setValue(targetInformation.manifest.id);
appId.setReadOnly(true);
});
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
connect(target, &Target::deploymentDataChanged, this, &RunConfiguration::update);
connect(target, &Target::kitChanged, this, &RunConfiguration::update);
} }
AppManagerControllerAspect controller{this};
AppManagerIdAspect appId{this};
AppManagerDocumentUrlAspect documentUrl{this};
AppManagerInstanceIdAspect instanceId{this};
}; };
class AppManagerRunAndDebugConfiguration final : public AppManagerRunConfiguration class AppManagerRunAndDebugConfiguration final : public AppManagerRunConfiguration

View File

@@ -6,6 +6,7 @@
#include "appmanagerruncontrol.h" #include "appmanagerruncontrol.h"
#include "appmanagerconstants.h" #include "appmanagerconstants.h"
#include "appmanagerstringaspect.h"
#include "appmanagertargetinformation.h" #include "appmanagertargetinformation.h"
#include "appmanagertr.h" #include "appmanagertr.h"
#include "appmanagerutilities.h" #include "appmanagerutilities.h"
@@ -52,16 +53,20 @@ public:
}); });
setStartModifier([this, runControl] { setStartModifier([this, runControl] {
const auto targetInformation = TargetInformation(runControl->target()); FilePath controller = runControl->aspect<AppManagerControllerAspect>()->filePath;
if (!targetInformation.isValid()) QString appId = runControl->aspect<AppManagerIdAspect>()->value;
return; QString instanceId = runControl->aspect<AppManagerInstanceIdAspect>()->value;
QString documentUrl = runControl->aspect<AppManagerDocumentUrlAspect>()->value;
// Prevent the write channel to be closed, otherwise the appman-controller will exit // Prevent the write channel to be closed, otherwise the appman-controller will exit
setProcessMode(ProcessMode::Writer); setProcessMode(ProcessMode::Writer);
setWorkingDirectory(targetInformation.workingDirectory()); CommandLine cmd{controller};
setCommandLine({FilePath::fromString(getToolFilePath(Constants::APPMAN_CONTROLLER, runControl->kit(), if (!instanceId.isEmpty())
targetInformation.device)), cmd.addArgs({"--instance-id", instanceId});
{"start-application", "-eio", targetInformation.manifest.id}}); cmd.addArgs({"start-application", "-eio", appId});
if (!documentUrl.isEmpty())
cmd.addArg(documentUrl);
setCommandLine(cmd);
}); });
} }
}; };
@@ -97,20 +102,19 @@ public:
addStartDependency(m_portsGatherer); addStartDependency(m_portsGatherer);
setStartModifier([this, runControl] { setStartModifier([this, runControl] {
FilePath controller = runControl->aspect<AppManagerControllerAspect>()->filePath;
const auto targetInformation = TargetInformation(runControl->target()); QString appId = runControl->aspect<AppManagerIdAspect>()->value;
if (!targetInformation.isValid()) { QString instanceId = runControl->aspect<AppManagerInstanceIdAspect>()->value;
reportFailure(); QString documentUrl = runControl->aspect<AppManagerDocumentUrlAspect>()->value;
return;
}
// const int perfPort = m_portsGatherer->gdbServer().port(); // const int perfPort = m_portsGatherer->gdbServer().port();
const int gdbServerPort = m_portsGatherer->gdbServer().port(); const int gdbServerPort = m_portsGatherer->gdbServer().port();
const int qmlServerPort = m_portsGatherer->qmlServer().port(); const int qmlServerPort = m_portsGatherer->qmlServer().port();
CommandLine cmd{FilePath::fromString(getToolFilePath(Constants::APPMAN_CONTROLLER, CommandLine cmd{controller};
runControl->kit(), if (!instanceId.isEmpty())
targetInformation.device))}; cmd.addArgs({"--instance-id", instanceId});
cmd.addArg("debug-application"); cmd.addArg("debug-application");
if (m_useGdbServer || m_useQmlServer) { if (m_useGdbServer || m_useQmlServer) {
@@ -137,12 +141,14 @@ public:
} }
cmd.addArg("-eio"); cmd.addArg("-eio");
cmd.addArg(targetInformation.manifest.id); cmd.addArg(appId);
if (!documentUrl.isEmpty())
cmd.addArg(documentUrl);
// Prevent the write channel to be closed, otherwise the appman-controller will exit // Prevent the write channel to be closed, otherwise the appman-controller will exit
setProcessMode(ProcessMode::Writer); setProcessMode(ProcessMode::Writer);
setCommandLine(cmd); setCommandLine(cmd);
setWorkingDirectory(targetInformation.workingDirectory());
appendMessage(Tr::tr("Starting AppMan Debugging..."), NormalMessageFormat); appendMessage(Tr::tr("Starting AppMan Debugging..."), NormalMessageFormat);
appendMessage(Tr::tr("Using: %1").arg(cmd.toUserOutput()), NormalMessageFormat); appendMessage(Tr::tr("Using: %1").arg(cmd.toUserOutput()), NormalMessageFormat);

View File

@@ -17,6 +17,39 @@ using namespace Utils;
namespace AppManager { namespace AppManager {
namespace Internal { namespace Internal {
AppManagerIdAspect::AppManagerIdAspect(Utils::AspectContainer *container)
: StringAspect(container)
{
setSettingsKey("ApplicationManagerPlugin.ApplicationId");
setDisplayStyle(StringAspect::LineEditDisplay);
setLabelText(Tr::tr("Application Id:"));
// setReadOnly(true);
}
AppManagerInstanceIdAspect::AppManagerInstanceIdAspect(Utils::AspectContainer *container)
: StringAspect(container)
{
setSettingsKey("ApplicationManagerPlugin.InstanceId");
setDisplayStyle(StringAspect::LineEditDisplay);
setLabelText(Tr::tr("AppMan Instance Id:"));
}
AppManagerDocumentUrlAspect::AppManagerDocumentUrlAspect(Utils::AspectContainer *container)
: StringAspect(container)
{
setSettingsKey("ApplicationManagerPlugin.DocumentUrl");
setDisplayStyle(StringAspect::LineEditDisplay);
setLabelText(Tr::tr("Document Url:"));
}
AppManagerControllerAspect::AppManagerControllerAspect(Utils::AspectContainer *container)
: FilePathAspect(container)
{
setSettingsKey("ApplicationManagerPlugin.AppControllerPath");
setLabelText(Tr::tr("Controller:"));
setPlaceHolderText(Tr::tr("-"));
}
AppManagerStringAspect::AppManagerStringAspect(AspectContainer *container) AppManagerStringAspect::AppManagerStringAspect(AspectContainer *container)
: StringAspect(container) : StringAspect(container)
{ {

View File

@@ -5,10 +5,52 @@
#pragma once #pragma once
#include "appmanagertr.h"
#include <utils/aspects.h> #include <utils/aspects.h>
namespace AppManager::Internal { namespace AppManager::Internal {
class AppManagerIdAspect final : public Utils::StringAspect
{
Q_OBJECT
public:
AppManagerIdAspect(Utils::AspectContainer *container = nullptr);
~AppManagerIdAspect() final = default;
};
class AppManagerInstanceIdAspect final : public Utils::StringAspect
{
Q_OBJECT
public:
AppManagerInstanceIdAspect(Utils::AspectContainer *container = nullptr);
~AppManagerInstanceIdAspect() final = default;
};
class AppManagerDocumentUrlAspect final : public Utils::StringAspect
{
Q_OBJECT
public:
AppManagerDocumentUrlAspect(Utils::AspectContainer *container = nullptr);
~AppManagerDocumentUrlAspect() final = default;
};
class AppManagerControllerAspect final : public Utils::FilePathAspect
{
Q_OBJECT
public:
AppManagerControllerAspect(Utils::AspectContainer *container = nullptr);
~AppManagerControllerAspect() final = default;
};
class AppManagerStringAspect : public Utils::StringAspect class AppManagerStringAspect : public Utils::StringAspect
{ {
public: public: