Utils: Introduce QtcProcess::controlEnvironment()

... and drop QtcProcess::removeEnvironment()

This shifts the meaning of the unqualified QtcProcess::environment()
to always refer to (possibly remote) "main" process this QtcProcess
wraps. The controlEnvironment is now referring to secondary helper
processes (if any...) typically(?) running on the host system.

This helps to avoid local/remote distinctions in some places.

Change-Id: Ib7cd15dd226617484b5358acd7deaed29e751883
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-05-09 15:02:23 +02:00
parent 9bf0efcbb9
commit e657bc8781
9 changed files with 36 additions and 48 deletions

View File

@@ -595,7 +595,7 @@ QString LinuxProcessInterface::fullCommandLine(const CommandLine &commandLine) c
if (m_setup.m_terminalMode == TerminalMode::Off)
cmd.addArgs(QString("echo ") + s_pidMarker + "$$" + s_pidMarker + " && ", CommandLine::Raw);
const Environment &env = m_setup.m_remoteEnvironment;
const Environment &env = m_setup.m_environment;
for (auto it = env.constBegin(); it != env.constEnd(); ++it)
cmd.addArgs(env.key(it) + "='" + env.expandedValueForKey(env.key(it)) + '\'', CommandLine::Raw);
@@ -760,11 +760,11 @@ void SshProcessInterfacePrivate::doStart()
// TODO: what about other fields from m_setup?
SshConnectionParameters::setupSshEnvironment(&m_process);
if (!m_sshParameters.x11DisplayName.isEmpty()) {
Environment env = m_process.environment();
Environment env = m_process.controlEnvironment();
// Note: it seems this is no-op when shared connection is used.
// In this case the display is taken from master process.
env.set("DISPLAY", m_sshParameters.x11DisplayName);
m_process.setEnvironment(env);
m_process.setControlEnvironment(env);
}
m_process.setCommand(fullLocalCommandLine());
m_process.start();
@@ -1030,7 +1030,6 @@ LinuxDevice::LinuxDevice()
proc->setCommand({ mapToGlobalPath({}), {}});
proc->setTerminalMode(TerminalMode::On);
proc->setEnvironment(env);
proc->setRemoteEnvironment(env);
proc->setWorkingDirectory(workingDir);
proc->start();
});
@@ -1133,6 +1132,11 @@ ProcessInterface *LinuxDevice::createProcessInterface() const
return new LinuxProcessInterface(this);
}
Environment LinuxDevice::systemEnvironment() const
{
return {}; // FIXME. See e.g. Docker implementation.
}
LinuxDevicePrivate::LinuxDevicePrivate(LinuxDevice *parent)
: q(parent)
{