forked from qt-creator/qt-creator
Docker: Implement DockerDevice::systemEnvironment() function
For synchronous retrieval of the system environment of the device. Change-Id: I057f9591866b72e37733d495a2a6b203fae91ac4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -294,6 +294,8 @@ public:
|
|||||||
QList<ToolChain *> autoDetectToolChains();
|
QList<ToolChain *> autoDetectToolChains();
|
||||||
void autoDetectCMake();
|
void autoDetectCMake();
|
||||||
|
|
||||||
|
void fetchSystemEnviroment();
|
||||||
|
|
||||||
DockerDevice *q;
|
DockerDevice *q;
|
||||||
DockerDeviceData m_data;
|
DockerDeviceData m_data;
|
||||||
|
|
||||||
@@ -302,6 +304,8 @@ public:
|
|||||||
QString m_container;
|
QString m_container;
|
||||||
QString m_mergedDir;
|
QString m_mergedDir;
|
||||||
QFileSystemWatcher m_mergedDirWatcher;
|
QFileSystemWatcher m_mergedDirWatcher;
|
||||||
|
|
||||||
|
Environment m_cachedEnviroment;
|
||||||
};
|
};
|
||||||
|
|
||||||
DockerDevice::DockerDevice(const DockerDeviceData &data)
|
DockerDevice::DockerDevice(const DockerDeviceData &data)
|
||||||
@@ -730,6 +734,26 @@ void DockerDevice::runProcess(QtcProcess &process) const
|
|||||||
process.start();
|
process.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Environment DockerDevice::systemEnvironment() const
|
||||||
|
{
|
||||||
|
if (d->m_cachedEnviroment.size() == 0)
|
||||||
|
d->fetchSystemEnviroment();
|
||||||
|
|
||||||
|
QTC_CHECK(d->m_cachedEnviroment.size() != 0);
|
||||||
|
return d->m_cachedEnviroment;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockerDevicePrivate::fetchSystemEnviroment()
|
||||||
|
{
|
||||||
|
SynchronousProcess proc;
|
||||||
|
proc.setCommand({"env", {}});
|
||||||
|
|
||||||
|
proc.runBlocking();
|
||||||
|
|
||||||
|
const QString remoteOutput = proc.stdOut();
|
||||||
|
m_cachedEnviroment = Environment(remoteOutput.split('\n', Qt::SkipEmptyParts), q->osType());
|
||||||
|
}
|
||||||
|
|
||||||
int DockerDevicePrivate::runSynchronously(const CommandLine &cmd) const
|
int DockerDevicePrivate::runSynchronously(const CommandLine &cmd) const
|
||||||
{
|
{
|
||||||
CommandLine dcmd{"docker", {"exec", m_container}};
|
CommandLine dcmd{"docker", {"exec", m_container}};
|
||||||
|
@@ -84,6 +84,8 @@ public:
|
|||||||
QByteArray fileContents(const Utils::FilePath &filePath, int limit) const override;
|
QByteArray fileContents(const Utils::FilePath &filePath, int limit) const override;
|
||||||
void runProcess(Utils::QtcProcess &process) const override;
|
void runProcess(Utils::QtcProcess &process) const override;
|
||||||
|
|
||||||
|
Utils::Environment systemEnvironment() const override;
|
||||||
|
|
||||||
const DockerDeviceData &data() const;
|
const DockerDeviceData &data() const;
|
||||||
|
|
||||||
void tryCreateLocalFileAccess() const;
|
void tryCreateLocalFileAccess() const;
|
||||||
|
Reference in New Issue
Block a user