summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2021-05-26 17:40:57 +0200
committerhjk <hjk@qt.io>2021-05-27 09:33:18 +0000
commit6de05306d66c936ae3a080bd3cd8594560a71959 (patch)
treec6611127cbce207b5d53286493d9c53ce81ccab3 /src/plugins/projectexplorer
parent125cdcc3a03e1cb0ce7e8260618d4d9abe7d383e (diff)
downloadqt-creator-6de05306d66c936ae3a080bd3cd8594560a71959.tar.gz
Utils: Use a structure to specify several QtcProcess device hooks
... and add a QtcProcess::systemEnvironmentForBinary(filePath) redirecting to IDevice::systemEnvironment() of the device implicitly given by filePath. A device implied by e.g. a qmake binary or a compiler binary is a common scenario. Change-Id: Ieb2c724ae66f1a1752132e4e4648a604390ca369 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicemanager.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
index b3c55f9892..8ad2ff67f7 100644
--- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
+++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
@@ -363,59 +363,69 @@ DeviceManager::DeviceManager(bool isInstance) : d(std::make_unique<DeviceManager
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
this, &DeviceManager::save);
- DeviceFileHooks hooks;
+ DeviceFileHooks deviceHooks;
- hooks.isExecutableFile = [](const FilePath &filePath) {
+ deviceHooks.isExecutableFile = [](const FilePath &filePath) {
auto device = DeviceManager::deviceForPath(filePath);
QTC_ASSERT(device, return false);
return device->isExecutableFile(filePath);
};
- hooks.isReadableFile = [](const FilePath &filePath) {
+ deviceHooks.isReadableFile = [](const FilePath &filePath) {
auto device = DeviceManager::deviceForPath(filePath);
QTC_ASSERT(device, return false);
return device->isReadableFile(filePath);
};
- hooks.isReadableDir = [](const FilePath &filePath) {
+ deviceHooks.isReadableDir = [](const FilePath &filePath) {
auto device = DeviceManager::deviceForPath(filePath);
QTC_ASSERT(device, return false);
return device->isReadableDirectory(filePath);
};
- hooks.isWritableDir = [](const FilePath &filePath) {
+ deviceHooks.isWritableDir = [](const FilePath &filePath) {
auto device = DeviceManager::deviceForPath(filePath);
QTC_ASSERT(device, return false);
return device->isWritableDirectory(filePath);
};
- hooks.createDir = [](const FilePath &filePath) {
+ deviceHooks.createDir = [](const FilePath &filePath) {
auto device = DeviceManager::deviceForPath(filePath);
QTC_ASSERT(device, return false);
return device->createDirectory(filePath);
};
- hooks.dirEntries = [](const FilePath &filePath,
+ deviceHooks.dirEntries = [](const FilePath &filePath,
const QStringList &nameFilters, QDir::Filters filters) {
auto device = DeviceManager::deviceForPath(filePath);
QTC_ASSERT(device, return FilePaths());
return device->directoryEntries(filePath, nameFilters, filters);
};
- hooks.fileContents = [](const FilePath &filePath, int maxSize) {
+ deviceHooks.fileContents = [](const FilePath &filePath, int maxSize) {
auto device = DeviceManager::deviceForPath(filePath);
QTC_ASSERT(device, return QByteArray());
return device->fileContents(filePath, maxSize);
};
- FilePath::setDeviceFileHooks(hooks);
+ FilePath::setDeviceFileHooks(deviceHooks);
- QtcProcess::setRemoteStartProcessHook([](QtcProcess &process) {
+ DeviceProcessHooks processHooks;
+
+ processHooks.startProcessHook = [](QtcProcess &process) {
FilePath filePath = process.commandLine().executable();
auto device = DeviceManager::deviceForPath(filePath);
QTC_ASSERT(device, return);
device->runProcess(process);
- });
+ };
+
+ processHooks.systemEnvironmentForBinary = [](const FilePath &filePath) {
+ auto device = DeviceManager::deviceForPath(filePath);
+ QTC_ASSERT(device, return Environment());
+ return device->systemEnvironment();
+ };
+
+ QtcProcess::setRemoteProcessHooks(processHooks);
}
DeviceManager::~DeviceManager()