AppMan: Add support to change the Environment in the RunConfiguration

Change-Id: I05e0df8abf40b3f1a55edc1ab1419a04b1060fa7
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Dominik Holland
2024-01-17 15:41:44 +01:00
parent 09c549d12f
commit 1d3db8afc3
2 changed files with 24 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <projectexplorer/environmentaspect.h>
#include <remotelinux/remotelinux_constants.h>
@@ -64,7 +65,10 @@ public:
: AppManagerRunConfiguration(target, id)
{
setDefaultDisplayName(Tr::tr("Run and Debug an Appman Package"));
environment.addPreferredBaseEnvironment(Tr::tr("Clean Environment"), {});
}
EnvironmentAspect environment{this};
};
class AppManagerRunConfigurationFactory : public RunConfigurationFactory

View File

@@ -57,13 +57,25 @@ public:
QString appId = runControl->aspect<AppManagerIdAspect>()->value;
QString instanceId = runControl->aspect<AppManagerInstanceIdAspect>()->value;
QString documentUrl = runControl->aspect<AppManagerDocumentUrlAspect>()->value;
QStringList envVars;
if (auto envAspect = runControl->aspect<EnvironmentAspect>())
envVars = envAspect->environment.toStringList();
// Always use the default environment to start the appman-controller in
// The env variables from the EnvironmentAspect are set through the controller
setEnvironment({});
// Prevent the write channel to be closed, otherwise the appman-controller will exit
setProcessMode(ProcessMode::Writer);
CommandLine cmd{controller};
if (!instanceId.isEmpty())
cmd.addArgs({"--instance-id", instanceId});
if (envVars.isEmpty()) {
cmd.addArgs({"start-application", "-eio", appId});
} else {
cmd.addArgs({"debug-application", "-eio"});
cmd.addArg(envVars.join(' '));
cmd.addArg(appId);
}
if (!documentUrl.isEmpty())
cmd.addArg(documentUrl);
setCommandLine(cmd);
@@ -106,6 +118,9 @@ public:
QString appId = runControl->aspect<AppManagerIdAspect>()->value;
QString instanceId = runControl->aspect<AppManagerInstanceIdAspect>()->value;
QString documentUrl = runControl->aspect<AppManagerDocumentUrlAspect>()->value;
QStringList envVars;
if (auto envAspect = runControl->aspect<EnvironmentAspect>())
envVars = envAspect->environment.toStringList();
// const int perfPort = m_portsGatherer->gdbServer().port();
const int gdbServerPort = m_portsGatherer->gdbServer().port();
@@ -119,6 +134,7 @@ public:
if (m_useGdbServer || m_useQmlServer) {
QStringList debugArgs;
debugArgs.append(envVars.join(' '));
if (m_useGdbServer) {
debugArgs.append(QString("gdbserver :%1").arg(gdbServerPort));
}
@@ -146,6 +162,9 @@ public:
if (!documentUrl.isEmpty())
cmd.addArg(documentUrl);
// Always use the default environment to start the appman-controller in
// The env variables from the EnvironmentAspect are set through the controller
setEnvironment({});
// Prevent the write channel to be closed, otherwise the appman-controller will exit
setProcessMode(ProcessMode::Writer);
setCommandLine(cmd);