forked from qt-creator/qt-creator
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 <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -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");
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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")
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
@@ -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 \""
|
||||
|
Reference in New Issue
Block a user