forked from qt-creator/qt-creator
AppMan: Add support to change the Environment in the RunConfiguration
Change-Id: I05e0df8abf40b3f1a55edc1ab1419a04b1060fa7 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
#include <projectexplorer/environmentaspect.h>
|
||||||
|
|
||||||
#include <remotelinux/remotelinux_constants.h>
|
#include <remotelinux/remotelinux_constants.h>
|
||||||
|
|
||||||
@@ -64,7 +65,10 @@ public:
|
|||||||
: AppManagerRunConfiguration(target, id)
|
: AppManagerRunConfiguration(target, id)
|
||||||
{
|
{
|
||||||
setDefaultDisplayName(Tr::tr("Run and Debug an Appman Package"));
|
setDefaultDisplayName(Tr::tr("Run and Debug an Appman Package"));
|
||||||
|
environment.addPreferredBaseEnvironment(Tr::tr("Clean Environment"), {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnvironmentAspect environment{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppManagerRunConfigurationFactory : public RunConfigurationFactory
|
class AppManagerRunConfigurationFactory : public RunConfigurationFactory
|
||||||
|
@@ -57,13 +57,25 @@ public:
|
|||||||
QString appId = runControl->aspect<AppManagerIdAspect>()->value;
|
QString appId = runControl->aspect<AppManagerIdAspect>()->value;
|
||||||
QString instanceId = runControl->aspect<AppManagerInstanceIdAspect>()->value;
|
QString instanceId = runControl->aspect<AppManagerInstanceIdAspect>()->value;
|
||||||
QString documentUrl = runControl->aspect<AppManagerDocumentUrlAspect>()->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
|
// Prevent the write channel to be closed, otherwise the appman-controller will exit
|
||||||
setProcessMode(ProcessMode::Writer);
|
setProcessMode(ProcessMode::Writer);
|
||||||
CommandLine cmd{controller};
|
CommandLine cmd{controller};
|
||||||
if (!instanceId.isEmpty())
|
if (!instanceId.isEmpty())
|
||||||
cmd.addArgs({"--instance-id", instanceId});
|
cmd.addArgs({"--instance-id", instanceId});
|
||||||
cmd.addArgs({"start-application", "-eio", appId});
|
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())
|
if (!documentUrl.isEmpty())
|
||||||
cmd.addArg(documentUrl);
|
cmd.addArg(documentUrl);
|
||||||
setCommandLine(cmd);
|
setCommandLine(cmd);
|
||||||
@@ -106,6 +118,9 @@ public:
|
|||||||
QString appId = runControl->aspect<AppManagerIdAspect>()->value;
|
QString appId = runControl->aspect<AppManagerIdAspect>()->value;
|
||||||
QString instanceId = runControl->aspect<AppManagerInstanceIdAspect>()->value;
|
QString instanceId = runControl->aspect<AppManagerInstanceIdAspect>()->value;
|
||||||
QString documentUrl = runControl->aspect<AppManagerDocumentUrlAspect>()->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 perfPort = m_portsGatherer->gdbServer().port();
|
||||||
const int gdbServerPort = m_portsGatherer->gdbServer().port();
|
const int gdbServerPort = m_portsGatherer->gdbServer().port();
|
||||||
@@ -119,6 +134,7 @@ public:
|
|||||||
|
|
||||||
if (m_useGdbServer || m_useQmlServer) {
|
if (m_useGdbServer || m_useQmlServer) {
|
||||||
QStringList debugArgs;
|
QStringList debugArgs;
|
||||||
|
debugArgs.append(envVars.join(' '));
|
||||||
if (m_useGdbServer) {
|
if (m_useGdbServer) {
|
||||||
debugArgs.append(QString("gdbserver :%1").arg(gdbServerPort));
|
debugArgs.append(QString("gdbserver :%1").arg(gdbServerPort));
|
||||||
}
|
}
|
||||||
@@ -146,6 +162,9 @@ public:
|
|||||||
if (!documentUrl.isEmpty())
|
if (!documentUrl.isEmpty())
|
||||||
cmd.addArg(documentUrl);
|
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
|
// Prevent the write channel to be closed, otherwise the appman-controller will exit
|
||||||
setProcessMode(ProcessMode::Writer);
|
setProcessMode(ProcessMode::Writer);
|
||||||
setCommandLine(cmd);
|
setCommandLine(cmd);
|
||||||
|
Reference in New Issue
Block a user