From 1ffaf0139af4946b1965de6ea341db4f4577c224 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 10 May 2022 15:33:33 +0200 Subject: [PATCH] ProjectExplorer: Introduce a IDevice::filePath Same function as mapToGlobalPath, but operating on a QString specifying the local path part. It's the majority use case and arguably the 'right thing' to use instead of a full FilePath that can refer to arbitrary devices. Change-Id: Ifc8bd340e2e8859fe549f5724eb94269f587c418 Reviewed-by: Jarek Kobus --- src/plugins/boot2qt/qdbdevicedebugsupport.cpp | 2 +- src/plugins/boot2qt/qdbmakedefaultappstep.cpp | 2 +- src/plugins/boot2qt/qdbstopapplicationstep.cpp | 2 +- src/plugins/perfprofiler/perfconfigwidget.cpp | 2 +- src/plugins/perfprofiler/perfprofilerruncontrol.cpp | 2 +- src/plugins/perfprofiler/perftracepointdialog.cpp | 4 ++-- .../devicesupport/sshdeviceprocesslist.cpp | 3 +-- src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp | 4 ++-- src/plugins/qnx/qnxdevice.cpp | 2 +- src/plugins/qnx/qnxdevicetester.cpp | 5 ++--- src/plugins/qnx/slog2inforunner.cpp | 6 +++--- src/plugins/remotelinux/genericdirectuploadservice.cpp | 10 ++++------ src/plugins/remotelinux/linuxdevicetester.cpp | 2 +- src/plugins/remotelinux/publickeydeploymentdialog.cpp | 2 +- .../remotelinuxcustomcommanddeploymentstep.cpp | 2 +- .../remotelinux/remotelinuxenvironmentreader.cpp | 2 +- .../remotelinux/remotelinuxpackageinstaller.cpp | 4 ++-- src/plugins/remotelinux/remotelinuxsignaloperation.cpp | 2 +- src/plugins/remotelinux/rsyncdeploystep.cpp | 5 ++--- src/plugins/valgrind/callgrind/callgrindcontroller.cpp | 5 ++--- src/plugins/valgrind/memchecktool.cpp | 2 +- src/plugins/valgrind/valgrindrunner.cpp | 2 +- 22 files changed, 33 insertions(+), 39 deletions(-) diff --git a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp index 0543df4d6d8..a5b2fb7b574 100644 --- a/src/plugins/boot2qt/qdbdevicedebugsupport.cpp +++ b/src/plugins/boot2qt/qdbdevicedebugsupport.cpp @@ -88,7 +88,7 @@ public: Runnable r = runnable(); CommandLine cmd; - cmd.setExecutable(device()->mapToGlobalPath(FilePath::fromString(Constants::AppcontrollerFilepath))); + cmd.setExecutable(device()->filePath(Constants::AppcontrollerFilepath)); if (m_useGdbServer) { cmd.addArg("--debug-gdb"); diff --git a/src/plugins/boot2qt/qdbmakedefaultappstep.cpp b/src/plugins/boot2qt/qdbmakedefaultappstep.cpp index 412db8f4f57..59392cb4aa8 100644 --- a/src/plugins/boot2qt/qdbmakedefaultappstep.cpp +++ b/src/plugins/boot2qt/qdbmakedefaultappstep.cpp @@ -87,7 +87,7 @@ private: ? QStringLiteral("--make-default ") + remoteExe : QStringLiteral("--remove-default"); m_process.setCommand( - {deviceConfiguration()->mapToGlobalPath(Constants::AppcontrollerFilepath), {args}}); + {deviceConfiguration()->filePath(Constants::AppcontrollerFilepath), {args}}); m_process.start(); } diff --git a/src/plugins/boot2qt/qdbstopapplicationstep.cpp b/src/plugins/boot2qt/qdbstopapplicationstep.cpp index 61a7da53e8f..58071f4f8d5 100644 --- a/src/plugins/boot2qt/qdbstopapplicationstep.cpp +++ b/src/plugins/boot2qt/qdbstopapplicationstep.cpp @@ -109,7 +109,7 @@ void QdbStopApplicationService::doDeploy() emit stdOutData(QString::fromUtf8(m_process.readAllStandardOutput())); }); - m_process.setCommand({device->mapToGlobalPath(Constants::AppcontrollerFilepath), {"--stop"}}); + m_process.setCommand({device->filePath(Constants::AppcontrollerFilepath), {"--stop"}}); m_process.setWorkingDirectory("/usr/bin"); m_process.start(); } diff --git a/src/plugins/perfprofiler/perfconfigwidget.cpp b/src/plugins/perfprofiler/perfconfigwidget.cpp index 5eefee9c22d..f52bebc4852 100644 --- a/src/plugins/perfprofiler/perfconfigwidget.cpp +++ b/src/plugins/perfprofiler/perfconfigwidget.cpp @@ -145,7 +145,7 @@ void PerfConfigWidget::setTarget(ProjectExplorer::Target *target) QTC_CHECK(!m_process || m_process->state() == QProcess::NotRunning); m_process.reset(new QtcProcess); - m_process->setCommand({device->mapToGlobalPath("perf"), {"probe", "-l"}}); + m_process->setCommand({device->filePath("perf"), {"probe", "-l"}}); connect(m_process.get(), &QtcProcess::done, this, &PerfConfigWidget::handleProcessDone); diff --git a/src/plugins/perfprofiler/perfprofilerruncontrol.cpp b/src/plugins/perfprofiler/perfprofilerruncontrol.cpp index 3d78d1f1723..0bcb54601c2 100644 --- a/src/plugins/perfprofiler/perfprofilerruncontrol.cpp +++ b/src/plugins/perfprofiler/perfprofilerruncontrol.cpp @@ -147,7 +147,7 @@ public: Runnable perfRunnable = runnable(); - CommandLine cmd({device()->mapToGlobalPath("perf"), {"record"}}); + CommandLine cmd({device()->filePath("perf"), {"record"}}); cmd.addArgs(m_perfRecordArguments); cmd.addArgs({"-o", "-", "--"}); cmd.addCommandLineAsArgs(perfRunnable.command, CommandLine::Raw); diff --git a/src/plugins/perfprofiler/perftracepointdialog.cpp b/src/plugins/perfprofiler/perftracepointdialog.cpp index 9ee65b601ef..e0db48cc4cf 100644 --- a/src/plugins/perfprofiler/perftracepointdialog.cpp +++ b/src/plugins/perfprofiler/perftracepointdialog.cpp @@ -95,9 +95,9 @@ void PerfTracePointDialog::runScript() const QString elevate = m_ui->privilegesChooser->currentText(); if (elevate != QLatin1String("n.a.")) - m_process->setCommand({m_device->mapToGlobalPath(FilePath::fromString(elevate)), {"sh"}}); + m_process->setCommand({m_device->filePath(elevate), {"sh"}}); else - m_process->setCommand({m_device->mapToGlobalPath("sh"), {}}); + m_process->setCommand({m_device->filePath("sh"), {}}); connect(m_process.get(), &QtcProcess::done, this, &PerfTracePointDialog::handleProcessDone); m_process->start(); diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp index 089dda2713a..770d76a3e63 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp @@ -53,8 +53,7 @@ SshDeviceProcessList::~SshDeviceProcessList() = default; void SshDeviceProcessList::doUpdate() { d->m_process.close(); - d->m_process.setCommand({device()->mapToGlobalPath("/bin/sh"), - {"-c", listProcessesCommandLine()}}); + d->m_process.setCommand({device()->filePath("/bin/sh"), {"-c", listProcessesCommandLine()}}); d->m_process.start(); } diff --git a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp index 698acbf73b9..3fa29a35a66 100644 --- a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp +++ b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp @@ -262,7 +262,7 @@ void QnxDeployQtLibrariesDialog::startCheckDirProcess() m_state = CheckingRemoteDirectory; m_ui->deployLogWindow->appendPlainText(tr("Checking existence of \"%1\"") .arg(fullRemoteDirectory())); - m_checkDirProcess.setCommand({m_device->mapToGlobalPath("test"), + m_checkDirProcess.setCommand({m_device->filePath("test"), {"-d", fullRemoteDirectory()}}); m_checkDirProcess.start(); } @@ -272,7 +272,7 @@ void QnxDeployQtLibrariesDialog::startRemoveDirProcess() QTC_CHECK(m_state == CheckingRemoteDirectory); m_state = RemovingRemoteDirectory; m_ui->deployLogWindow->appendPlainText(tr("Removing \"%1\"").arg(fullRemoteDirectory())); - m_removeDirProcess.setCommand({m_device->mapToGlobalPath("rm"), + m_removeDirProcess.setCommand({m_device->filePath("rm"), {"-rf", fullRemoteDirectory()}}); m_removeDirProcess.start(); } diff --git a/src/plugins/qnx/qnxdevice.cpp b/src/plugins/qnx/qnxdevice.cpp index da448869897..6af7a3f4a19 100644 --- a/src/plugins/qnx/qnxdevice.cpp +++ b/src/plugins/qnx/qnxdevice.cpp @@ -153,7 +153,7 @@ void QnxDevice::updateVersionNumber() const { QtcProcess versionNumberProcess; - versionNumberProcess.setCommand({mapToGlobalPath("uname"), {"-r"}}); + versionNumberProcess.setCommand({filePath("uname"), {"-r"}}); versionNumberProcess.runBlocking(EventLoopMode::On); QByteArray output = versionNumberProcess.readAllStandardOutput(); diff --git a/src/plugins/qnx/qnxdevicetester.cpp b/src/plugins/qnx/qnxdevicetester.cpp index a816a4d47f9..8dd664ad8b7 100644 --- a/src/plugins/qnx/qnxdevicetester.cpp +++ b/src/plugins/qnx/qnxdevicetester.cpp @@ -94,7 +94,7 @@ void QnxDeviceTester::handleGenericTestFinished(TestResult result) m_state = VarRunTest; emit progressMessage(tr("Checking that files can be created in /var/run...")); - const CommandLine cmd {m_deviceConfiguration->mapToGlobalPath("/bin/sh"), + const CommandLine cmd {m_deviceConfiguration->filePath("/bin/sh"), {"-c", QLatin1String("rm %1 > /dev/null 2>&1; echo ABC > %1 && rm %1") .arg("/var/run/qtc_xxxx.pid")}}; m_process.setCommand(cmd); @@ -159,8 +159,7 @@ void QnxDeviceTester::testNextCommand() const QString command = m_commandsToTest[m_currentCommandIndex]; emit progressMessage(tr("Checking for %1...").arg(command)); - const CommandLine cmd {m_deviceConfiguration->mapToGlobalPath("command"), {"-v", command}}; - m_process.setCommand(cmd); + m_process.setCommand({m_deviceConfiguration->filePath("command"), {"-v", command}}); m_process.start(); } diff --git a/src/plugins/qnx/slog2inforunner.cpp b/src/plugins/qnx/slog2inforunner.cpp index d8b8906ffc8..7c632a30ca5 100644 --- a/src/plugins/qnx/slog2inforunner.cpp +++ b/src/plugins/qnx/slog2inforunner.cpp @@ -70,7 +70,7 @@ void Slog2InfoRunner::printMissingWarning() void Slog2InfoRunner::start() { - m_testProcess->setCommand({device()->mapToGlobalPath("slog2info"), {}}); + m_testProcess->setCommand({device()->filePath("slog2info"), {}}); m_testProcess->start(); reportStarted(); } @@ -107,7 +107,7 @@ void Slog2InfoRunner::handleTestProcessCompleted() void Slog2InfoRunner::readLaunchTime() { - m_launchDateTimeProcess->setCommand({device()->mapToGlobalPath("date"), + m_launchDateTimeProcess->setCommand({device()->filePath("date"), "+\"%d %H:%M:%S\"", CommandLine::Raw}); m_launchDateTimeProcess->start(); } @@ -126,7 +126,7 @@ void Slog2InfoRunner::launchSlog2Info() m_launchDateTime = QDateTime::fromString(QString::fromLatin1(m_launchDateTimeProcess->readAllStandardOutput()).trimmed(), QString::fromLatin1("dd HH:mm:ss")); - m_logProcess->setCommand({device()->mapToGlobalPath("slog2info"), {"-w"}}); + m_logProcess->setCommand({device()->filePath("slog2info"), {"-w"}}); m_logProcess->start(); } diff --git a/src/plugins/remotelinux/genericdirectuploadservice.cpp b/src/plugins/remotelinux/genericdirectuploadservice.cpp index dff6185f983..88868129cec 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.cpp +++ b/src/plugins/remotelinux/genericdirectuploadservice.cpp @@ -198,9 +198,8 @@ void GenericDirectUploadService::runStat(const DeployableFile &file) { // We'd like to use --format=%Y, but it's not supported by busybox. QtcProcess * const statProc = new QtcProcess(this); - const CommandLine statCmd {deviceConfiguration()->mapToGlobalPath("stat"), - {"-t", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}}; - statProc->setCommand(statCmd); + statProc->setCommand({deviceConfiguration()->filePath("stat"), + {"-t", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}}); connect(statProc, &QtcProcess::done, this, [this, statProc, state = d->state] { QTC_ASSERT(d->state == state, return); const DeployableFile file = d->getFileForProcess(statProc); @@ -338,9 +337,8 @@ void GenericDirectUploadService::chmod() if (!f.isExecutable()) continue; QtcProcess * const chmodProc = new QtcProcess(this); - const CommandLine chmodCmd {deviceConfiguration()->mapToGlobalPath("chmod"), - {"a+x", Utils::ProcessArgs::quoteArgUnix(f.remoteFilePath())}}; - chmodProc->setCommand(chmodCmd); + chmodProc->setCommand({deviceConfiguration()->filePath("chmod"), + {"a+x", Utils::ProcessArgs::quoteArgUnix(f.remoteFilePath())}}); connect(chmodProc, &QtcProcess::done, this, [this, chmodProc, state = d->state] { QTC_ASSERT(state == d->state, return); const DeployableFile file = d->getFileForProcess(chmodProc); diff --git a/src/plugins/remotelinux/linuxdevicetester.cpp b/src/plugins/remotelinux/linuxdevicetester.cpp index ffa745890e4..6ac18c87360 100644 --- a/src/plugins/remotelinux/linuxdevicetester.cpp +++ b/src/plugins/remotelinux/linuxdevicetester.cpp @@ -129,7 +129,7 @@ void GenericLinuxDeviceTester::handleConnected() { QTC_ASSERT(d->state == Connecting, return); - d->unameProcess.setCommand({d->deviceConfiguration->mapToGlobalPath("uname"), {"-rsm"}}); + d->unameProcess.setCommand({d->deviceConfiguration->filePath("uname"), {"-rsm"}}); emit progressMessage(tr("Checking kernel version...")); d->state = RunningUname; diff --git a/src/plugins/remotelinux/publickeydeploymentdialog.cpp b/src/plugins/remotelinux/publickeydeploymentdialog.cpp index 30cf82f7b1d..5da41546d03 100644 --- a/src/plugins/remotelinux/publickeydeploymentdialog.cpp +++ b/src/plugins/remotelinux/publickeydeploymentdialog.cpp @@ -97,7 +97,7 @@ PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const IDevice::ConstPtr &de const QString command = "test -d .ssh || mkdir -p ~/.ssh && chmod 0700 .ssh && echo '" + QString::fromLocal8Bit(reader.data()) + "' >> .ssh/authorized_keys && chmod 0600 .ssh/authorized_keys"; - d->m_process.setCommand({deviceConfig->mapToGlobalPath("/bin/sh"), {"-c", command}}); + d->m_process.setCommand({deviceConfig->filePath("/bin/sh"), {"-c", command}}); d->m_process.start(); } diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp index ef68e5bfe89..b9054f3d724 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp @@ -98,7 +98,7 @@ CheckResult RemoteLinuxCustomCommandDeployService::isDeploymentPossible() const void RemoteLinuxCustomCommandDeployService::doDeploy() { emit progressMessage(tr("Starting remote command \"%1\"...").arg(m_commandLine)); - m_process.setCommand({deviceConfiguration()->mapToGlobalPath("/bin/sh"), + m_process.setCommand({deviceConfiguration()->filePath("/bin/sh"), {"-c", m_commandLine}}); m_process.start(); } diff --git a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp index 5ccd5fcb403..3f88ac4b5e1 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp @@ -55,7 +55,7 @@ void RemoteLinuxEnvironmentReader::start() m_deviceProcess = new QtcProcess(this); connect(m_deviceProcess, &QtcProcess::done, this, &RemoteLinuxEnvironmentReader::handleDone); - m_deviceProcess->setCommand({m_device->mapToGlobalPath("env"), {}}); + m_deviceProcess->setCommand({m_device->filePath("env"), {}}); m_deviceProcess->start(); } diff --git a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp index adf82fbc07c..e4757663ec1 100644 --- a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp +++ b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp @@ -76,7 +76,7 @@ void AbstractRemoteLinuxPackageInstaller::installPackage(const IDevice::ConstPtr QString cmdLine = installCommandLine(packageFilePath); if (removePackageFile) cmdLine += QLatin1String(" && (rm ") + packageFilePath + QLatin1String(" || :)"); - d->m_installer.setCommand({d->m_device->mapToGlobalPath("/bin/sh"), {"-c", cmdLine}}); + d->m_installer.setCommand({d->m_device->filePath("/bin/sh"), {"-c", cmdLine}}); d->m_installer.start(); } @@ -84,7 +84,7 @@ void AbstractRemoteLinuxPackageInstaller::cancelInstallation() { QTC_ASSERT(d->m_installer.state() != QProcess::NotRunning, return); - d->m_killer.setCommand({d->m_device->mapToGlobalPath("/bin/sh"), + d->m_killer.setCommand({d->m_device->filePath("/bin/sh"), {"-c", cancelInstallationCommandLine()}}); d->m_killer.start(); d->m_installer.close(); diff --git a/src/plugins/remotelinux/remotelinuxsignaloperation.cpp b/src/plugins/remotelinux/remotelinuxsignaloperation.cpp index 946fbba2726..a0dec6b269c 100644 --- a/src/plugins/remotelinux/remotelinuxsignaloperation.cpp +++ b/src/plugins/remotelinux/remotelinuxsignaloperation.cpp @@ -52,7 +52,7 @@ void RemoteLinuxSignalOperation::run(const QString &command) m_process.reset(new QtcProcess); connect(m_process.get(), &QtcProcess::done, this, &RemoteLinuxSignalOperation::runnerDone); - m_process->setCommand({m_device->mapToGlobalPath("/bin/sh"), {"-c", command}}); + m_process->setCommand({m_device->filePath("/bin/sh"), {"-c", command}}); m_process->start(); } diff --git a/src/plugins/remotelinux/rsyncdeploystep.cpp b/src/plugins/remotelinux/rsyncdeploystep.cpp index 2f6b3c145dc..92b97962097 100644 --- a/src/plugins/remotelinux/rsyncdeploystep.cpp +++ b/src/plugins/remotelinux/rsyncdeploystep.cpp @@ -102,9 +102,8 @@ void RsyncDeployService::createRemoteDirectories() remoteDirs.sort(); remoteDirs.removeDuplicates(); m_mkdir.reset(new QtcProcess); - const CommandLine command {deviceConfiguration()->mapToGlobalPath("mkdir"), - {"-p", ProcessArgs::createUnixArgs(remoteDirs).toString()}}; - m_mkdir->setCommand(command); + m_mkdir->setCommand({deviceConfiguration()->filePath("mkdir"), + {"-p", ProcessArgs::createUnixArgs(remoteDirs).toString()}}); connect(m_mkdir.get(), &QtcProcess::done, this, [this] { if (m_mkdir->result() != ProcessResult::FinishedWithSuccess) { emit errorMessage(tr("Failed to create remote directories: %1") diff --git a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp index 53eb144dab8..fab2d76595a 100644 --- a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp +++ b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp @@ -114,12 +114,11 @@ void CallgrindController::run(Option option) connect(m_controllerProcess.get(), &QtcProcess::finished, this, &CallgrindController::controllerProcessDone); - const FilePath cgcontrol = FilePath::fromString(CALLGRIND_CONTROL_BINARY); CommandLine cmd; if (m_valgrindRunnable.device) - cmd.setExecutable(m_valgrindRunnable.device->mapToGlobalPath(cgcontrol)); + cmd.setExecutable(m_valgrindRunnable.device->filePath(CALLGRIND_CONTROL_BINARY)); else - cmd.setExecutable(cgcontrol); + cmd.setExecutable(CALLGRIND_CONTROL_BINARY); cmd.setArguments(QString("%1 %2").arg(toOptionString(option)).arg(m_pid)); m_controllerProcess->setCommand(cmd); m_controllerProcess->setWorkingDirectory(m_valgrindRunnable.workingDirectory); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 998268c9a0b..1e093b354a4 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -156,7 +156,7 @@ public: { QTC_ASSERT(!m_process, return); m_process.reset(new QtcProcess); - m_process->setCommand({device()->mapToGlobalPath("echo"), "-n $SSH_CLIENT", CommandLine::Raw}); + m_process->setCommand({device()->filePath("echo"), "-n $SSH_CLIENT", CommandLine::Raw}); connect(m_process.get(), &QtcProcess::done, this, [this] { if (m_process->error() != QProcess::UnknownError) { reportFailure(); diff --git a/src/plugins/valgrind/valgrindrunner.cpp b/src/plugins/valgrind/valgrindrunner.cpp index eda901324af..d97eb20a901 100644 --- a/src/plugins/valgrind/valgrindrunner.cpp +++ b/src/plugins/valgrind/valgrindrunner.cpp @@ -178,7 +178,7 @@ void ValgrindRunner::Private::remoteProcessStarted() QString procEscaped = proc; procEscaped.replace("/", "\\\\/"); - CommandLine cmd(m_device->mapToGlobalPath(FilePath::fromString("/bin/sh")), {}); + CommandLine cmd(m_device->filePath("/bin/sh"), {}); // sleep required since otherwise we might only match "bash -c..." and not the actual // valgrind run cmd.setArguments(QString("-c \""