forked from qt-creator/qt-creator
Fix passing environment to remote
After removing Runnable parameter from DeviceProcess::start() (see95c9579c58
) we are now setting the runnable's environment to the remote process directly. This is now used in 2 places: 1. For forming the proper fullCommandLine(), so that the passed environment is expanded to command line arguments 2. For running the remote process itself. Before the mentioned change these two environments were separated (1st was taken from run environment aspect, 2nd was left with its default value - see SshProcess c'tor). After the mentioned change 1 and 2 are equal (i.e. both are env aspect). This affects running app in terminal, as the aspect env is applied to the stub process, so it can't start properly. This change brings the separation back. Amends95c9579c58
Change-Id: I5efe82e19d3fb5608f97e56c2f4b7651643e156a Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -45,6 +45,7 @@ public:
|
|||||||
CommandLine m_commandLine;
|
CommandLine m_commandLine;
|
||||||
FilePath m_workingDirectory;
|
FilePath m_workingDirectory;
|
||||||
Environment m_environment;
|
Environment m_environment;
|
||||||
|
Environment m_remoteEnvironment;
|
||||||
QByteArray m_writeData;
|
QByteArray m_writeData;
|
||||||
QProcess::ProcessChannelMode m_processChannelMode = QProcess::SeparateChannels;
|
QProcess::ProcessChannelMode m_processChannelMode = QProcess::SeparateChannels;
|
||||||
QVariantHash m_extraData;
|
QVariantHash m_extraData;
|
||||||
|
@@ -772,6 +772,16 @@ bool QtcProcess::hasEnvironment() const
|
|||||||
return d->m_setup.m_haveEnv;
|
return d->m_setup.m_haveEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtcProcess::setRemoteEnvironment(const Environment &environment)
|
||||||
|
{
|
||||||
|
d->m_setup.m_remoteEnvironment = environment;
|
||||||
|
}
|
||||||
|
|
||||||
|
Environment QtcProcess::remoteEnvironment() const
|
||||||
|
{
|
||||||
|
return d->m_setup.m_remoteEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
void QtcProcess::setCommand(const CommandLine &cmdLine)
|
void QtcProcess::setCommand(const CommandLine &cmdLine)
|
||||||
{
|
{
|
||||||
if (d->m_setup.m_workingDirectory.needsDevice() && cmdLine.executable().needsDevice()) {
|
if (d->m_setup.m_workingDirectory.needsDevice() && cmdLine.executable().needsDevice()) {
|
||||||
|
@@ -102,6 +102,9 @@ public:
|
|||||||
const Environment &environment() const;
|
const Environment &environment() const;
|
||||||
bool hasEnvironment() const;
|
bool hasEnvironment() const;
|
||||||
|
|
||||||
|
void setRemoteEnvironment(const Environment &env);
|
||||||
|
Environment remoteEnvironment() const;
|
||||||
|
|
||||||
void setCommand(const CommandLine &cmdLine);
|
void setCommand(const CommandLine &cmdLine);
|
||||||
const CommandLine &commandLine() const;
|
const CommandLine &commandLine() const;
|
||||||
|
|
||||||
|
@@ -408,7 +408,7 @@ void ApplicationLauncherPrivate::start(const IDevice::ConstPtr &device, bool loc
|
|||||||
this, &ApplicationLauncherPrivate::handleApplicationFinished);
|
this, &ApplicationLauncherPrivate::handleApplicationFinished);
|
||||||
m_process->setCommand(m_runnable.command);
|
m_process->setCommand(m_runnable.command);
|
||||||
m_process->setWorkingDirectory(m_runnable.workingDirectory);
|
m_process->setWorkingDirectory(m_runnable.workingDirectory);
|
||||||
m_process->setEnvironment(m_runnable.environment);
|
m_process->setRemoteEnvironment(m_runnable.environment);
|
||||||
m_process->setExtraData(m_runnable.extraData);
|
m_process->setExtraData(m_runnable.extraData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ QString QnxDeviceProcess::fullCommandLine() const
|
|||||||
fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(
|
fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(
|
||||||
ProcessArgs::quoteArg(workingDirectory().toString()));
|
ProcessArgs::quoteArg(workingDirectory().toString()));
|
||||||
|
|
||||||
const Environment env = environment();
|
const Environment env = remoteEnvironment();
|
||||||
for (auto it = env.constBegin(); it != env.constEnd(); ++it) {
|
for (auto it = env.constBegin(); it != env.constEnd(); ++it) {
|
||||||
fullCommandLine += QString::fromLatin1("%1='%2' ")
|
fullCommandLine += QString::fromLatin1("%1='%2' ")
|
||||||
.arg(env.key(it)).arg(env.expandedValueForKey(env.key(it)));
|
.arg(env.key(it)).arg(env.expandedValueForKey(env.key(it)));
|
||||||
|
@@ -99,7 +99,7 @@ QString LinuxDeviceProcess::fullCommandLine() const
|
|||||||
if (!usesTerminal())
|
if (!usesTerminal())
|
||||||
cmd.addArgs(QString("echo ") + pidMarker + "$$" + pidMarker + " && ", CommandLine::Raw);
|
cmd.addArgs(QString("echo ") + pidMarker + "$$" + pidMarker + " && ", CommandLine::Raw);
|
||||||
|
|
||||||
const Environment &env = environment();
|
const Environment &env = remoteEnvironment();
|
||||||
for (auto it = env.constBegin(); it != env.constEnd(); ++it)
|
for (auto it = env.constBegin(); it != env.constEnd(); ++it)
|
||||||
cmd.addArgs(env.key(it) + "='" + env.expandedValueForKey(env.key(it)) + '\'', CommandLine::Raw);
|
cmd.addArgs(env.key(it) + "='" + env.expandedValueForKey(env.key(it)) + '\'', CommandLine::Raw);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user