diff options
author | hjk <hjk@qt.io> | 2019-05-28 18:59:45 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-05-29 14:36:46 +0000 |
commit | 4098be05b23dd20aaf752fb9aec79fe8d90a4220 (patch) | |
tree | b593688a2f5808fb42221dcf4127faeba0d8c6c6 /src/plugins | |
parent | f50859e856b911ba0667fc9aaa5df4c8882f8679 (diff) |
Utils: Extract a CommandLine structure from a QtcProcess
We regularly pass around strings or filenames or pairs of strings
or filenames and stringlist etc the in the end will be used
as a kind of "command line", with quite a bit of ad-hoc user
code and QtcProcess::addArg etc to set them up and manipulate them.
Let's have a class for that concept.
Change-Id: I288ab939d853b32c717135a65242c584c2beab50
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/android/androiddeployqtstep.cpp | 2 | ||||
-rw-r--r-- | src/plugins/android/androidsdkmanager.cpp | 2 | ||||
-rw-r--r-- | src/plugins/baremetal/gdbserverproviderprocess.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/servermode.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/tealeafreader.cpp | 2 | ||||
-rw-r--r-- | src/plugins/coreplugin/externaltool.cpp | 2 | ||||
-rw-r--r-- | src/plugins/coreplugin/locator/executefilter.cpp | 2 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppcheckrunner.cpp | 4 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerruncontrol.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.cpp | 3 | ||||
-rw-r--r-- | src/plugins/debugger/lldb/lldbengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/abstractprocessstep.cpp | 8 | ||||
-rw-r--r-- | src/plugins/projectexplorer/applicationlauncher.cpp | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.cpp | 5 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.h | 3 | ||||
-rw-r--r-- | src/plugins/winrt/winrtdevice.cpp | 2 | ||||
-rw-r--r-- | src/plugins/winrt/winrtrunnerhelper.cpp | 2 |
17 files changed, 30 insertions, 17 deletions
diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp index 77ea540e6f5..94a016478c2 100644 --- a/src/plugins/android/androiddeployqtstep.cpp +++ b/src/plugins/android/androiddeployqtstep.cpp @@ -366,7 +366,7 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy() } m_process = new Utils::QtcProcess; - m_process->setCommand(m_command, args); + m_process->setCommand(Utils::CommandLine(Utils::FilePath::fromString(m_command), args)); m_process->setWorkingDirectory(m_workingDirectory); m_process->setEnvironment(m_environment); diff --git a/src/plugins/android/androidsdkmanager.cpp b/src/plugins/android/androidsdkmanager.cpp index 5d0333f5f87..8b58cdd1add 100644 --- a/src/plugins/android/androidsdkmanager.cpp +++ b/src/plugins/android/androidsdkmanager.cpp @@ -930,7 +930,7 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdFutureInterface &fi) QtcProcess licenseCommand; licenseCommand.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(m_config)); bool reviewingLicenses = false; - licenseCommand.setCommand(m_config.sdkManagerToolPath().toString(), {"--licenses"}); + licenseCommand.setCommand(CommandLine(m_config.sdkManagerToolPath(), "--licenses")); if (Utils::HostOsInfo::isWindowsHost()) licenseCommand.setUseCtrlCStub(true); licenseCommand.start(); diff --git a/src/plugins/baremetal/gdbserverproviderprocess.cpp b/src/plugins/baremetal/gdbserverproviderprocess.cpp index 2d77d53d753..d893e5fae46 100644 --- a/src/plugins/baremetal/gdbserverproviderprocess.cpp +++ b/src/plugins/baremetal/gdbserverproviderprocess.cpp @@ -63,7 +63,7 @@ GdbServerProviderProcess::GdbServerProviderProcess( void GdbServerProviderProcess::start(const ProjectExplorer::Runnable &runnable) { QTC_ASSERT(m_process->state() == QProcess::NotRunning, return); - m_process->setCommand(runnable.executable, runnable.commandLineArguments); + m_process->setCommand(runnable.commandLine()); m_process->start(); } diff --git a/src/plugins/cmakeprojectmanager/servermode.cpp b/src/plugins/cmakeprojectmanager/servermode.cpp index 58f2afbc224..56b177fdf9d 100644 --- a/src/plugins/cmakeprojectmanager/servermode.cpp +++ b/src/plugins/cmakeprojectmanager/servermode.cpp @@ -129,7 +129,7 @@ ServerMode::ServerMode(const Environment &env, qCInfo(cmakeServerMode) << "Preparing cmake:" << cmakeExecutable.toString() << argumentString << "in" << m_buildDirectory.toString(); - m_cmakeProcess->setCommand(cmakeExecutable.toString(), argumentString); + m_cmakeProcess->setCommand(CommandLine(cmakeExecutable, argumentString)); // Delay start: QTimer::singleShot(0, this, [argumentString, this] { diff --git a/src/plugins/cmakeprojectmanager/tealeafreader.cpp b/src/plugins/cmakeprojectmanager/tealeafreader.cpp index 8192c63b91f..d336d9e8cfa 100644 --- a/src/plugins/cmakeprojectmanager/tealeafreader.cpp +++ b/src/plugins/cmakeprojectmanager/tealeafreader.cpp @@ -519,7 +519,7 @@ void TeaLeafReader::startCMake(const QStringList &configurationArguments) tr("Configuring \"%1\"").arg(m_parameters.projectName), "CMake.Configure"); - m_cmakeProcess->setCommand(cmake->cmakeExecutable().toString(), args); + m_cmakeProcess->setCommand(CommandLine(cmake->cmakeExecutable(), args)); emit configurationStarted(); m_cmakeProcess->start(); } diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 24a40db3eb7..b339dddd3de 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -663,7 +663,7 @@ void ExternalToolRunner::run() this, &ExternalToolRunner::readStandardError); if (!m_resolvedWorkingDirectory.isEmpty()) m_process->setWorkingDirectory(m_resolvedWorkingDirectory); - m_process->setCommand(m_resolvedExecutable.toString(), m_resolvedArguments); + m_process->setCommand(CommandLine(m_resolvedExecutable, m_resolvedArguments)); m_process->setEnvironment(m_resolvedEnvironment); MessageManager::write(tr("Starting external tool \"%1\" %2") .arg(m_resolvedExecutable.toUserOutput(), m_resolvedArguments), diff --git a/src/plugins/coreplugin/locator/executefilter.cpp b/src/plugins/coreplugin/locator/executefilter.cpp index 2d451a5b6e4..bc4a4b65a71 100644 --- a/src/plugins/coreplugin/locator/executefilter.cpp +++ b/src/plugins/coreplugin/locator/executefilter.cpp @@ -169,7 +169,7 @@ void ExecuteFilter::runHeadCommand() } MessageManager::write(tr("Starting command \"%1\".").arg(headCommand())); m_process->setWorkingDirectory(d.workingDirectory); - m_process->setCommand(fullPath.toString(), d.arguments); + m_process->setCommand(Utils::CommandLine(fullPath, d.arguments)); m_process->start(); m_process->closeWriteChannel(); if (!m_process->waitForStarted(1000)) { diff --git a/src/plugins/cppcheck/cppcheckrunner.cpp b/src/plugins/cppcheck/cppcheckrunner.cpp index 9c3e72bddb7..9b9872097ae 100644 --- a/src/plugins/cppcheck/cppcheckrunner.cpp +++ b/src/plugins/cppcheck/cppcheckrunner.cpp @@ -32,6 +32,8 @@ #include <coreplugin/messagemanager.h> +using namespace Utils; + namespace Cppcheck { namespace Internal { @@ -153,7 +155,7 @@ void CppcheckRunner::checkQueued() else m_queue.begin().value() = files; - m_process->setCommand(m_binary, arguments); + m_process->setCommand(CommandLine(FilePath::fromString(m_binary), arguments)); m_process->start(); } diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 8a70795f236..e2b79cf9b35 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -113,7 +113,7 @@ public: void start() override { - m_proc.setCommand(m_runnable.executable, m_runnable.commandLineArguments); + m_proc.setCommand(m_runnable.commandLine()); m_proc.start(); } diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index b763d951fdd..7fa961cea8f 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3556,7 +3556,8 @@ void GdbEngine::setupEngine() gdbArgs << "-n"; showMessage("STARTING " + rp.debugger.executable + " " + gdbArgs.join(' ')); - m_gdbProc.setCommand(rp.debugger.executable, QtcProcess::joinArgs(gdbArgs)); + m_gdbProc.setCommand(CommandLine(FilePath::fromString(rp.debugger.executable), + QtcProcess::joinArgs(gdbArgs))); if (QFileInfo(rp.debugger.workingDirectory).isDir()) m_gdbProc.setWorkingDirectory(rp.debugger.workingDirectory); m_gdbProc.setEnvironment(rp.debugger.environment); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 7e62db91fdb..3047fb8ad4b 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -207,7 +207,7 @@ void LldbEngine::setupEngine() if (QFileInfo(runParameters().debugger.workingDirectory).isDir()) m_lldbProc.setWorkingDirectory(runParameters().debugger.workingDirectory); - m_lldbProc.setCommand(lldbCmd, QString()); + m_lldbProc.setCommand(CommandLine(FilePath::fromString(lldbCmd), QString())); m_lldbProc.start(); if (!m_lldbProc.waitForStarted()) { diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index 106f58b006b..1d92fa92809 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -48,6 +48,8 @@ #include <algorithm> #include <memory> +using namespace Utils; + namespace ProjectExplorer { /*! @@ -211,8 +213,8 @@ void AbstractProcessStep::doRun() } } - QString effectiveCommand = d->m_param.effectiveCommand().toString(); - if (!QFileInfo::exists(effectiveCommand)) { + const CommandLine effectiveCommand{d->m_param.effectiveCommand(), d->m_param.effectiveArguments()}; + if (!effectiveCommand.executable().exists()) { processStartupFailed(); finish(false); return; @@ -222,7 +224,7 @@ void AbstractProcessStep::doRun() d->m_process->setUseCtrlCStub(Utils::HostOsInfo::isWindowsHost()); d->m_process->setWorkingDirectory(wd.absolutePath()); d->m_process->setEnvironment(d->m_param.environment()); - d->m_process->setCommand(effectiveCommand, d->m_param.effectiveArguments()); + d->m_process->setCommand(effectiveCommand); connect(d->m_process.get(), &QProcess::readyReadStandardOutput, this, &AbstractProcessStep::processReadyReadStdOutput); diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 57a9fe8bcff..3a9cde2baf9 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -378,7 +378,7 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: #endif if (!m_useTerminal) { - m_guiProcess.setCommand(runnable.executable, runnable.commandLineArguments); + m_guiProcess.setCommand(runnable.commandLine()); m_guiProcess.closeWriteChannel(); m_guiProcess.start(); } else { diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 5ce17b53fc6..a358df38f3b 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -1549,4 +1549,9 @@ void RunWorker::stop() reportStopped(); } +CommandLine Runnable::commandLine() const +{ + return CommandLine(FilePath::fromString(executable), commandLineArguments); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 8d24fabcf07..040520991d0 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -35,6 +35,7 @@ #include <utils/port.h> #include <utils/processhandle.h> #include <utils/qtcassert.h> +#include <utils/qtcprocess.h> #include <utils/icon.h> #include <QHash> @@ -72,6 +73,8 @@ class PROJECTEXPLORER_EXPORT Runnable public: Runnable() = default; + Utils::CommandLine commandLine() const; + QString executable; QString commandLineArguments; QString workingDirectory; diff --git a/src/plugins/winrt/winrtdevice.cpp b/src/plugins/winrt/winrtdevice.cpp index 672947f9cd1..9ceba3b3233 100644 --- a/src/plugins/winrt/winrtdevice.cpp +++ b/src/plugins/winrt/winrtdevice.cpp @@ -160,7 +160,7 @@ void WinRtDeviceFactory::autoDetect() } const QString args = QStringLiteral("--list-devices"); - m_process->setCommand(runnerFilePath, args); + m_process->setCommand(CommandLine(FilePath::fromString(runnerFilePath), args)); qCDebug(winrtDeviceLog) << __FUNCTION__ << "Starting process" << runnerFilePath << "with arguments" << args; MessageManager::write(runnerFilePath + QLatin1Char(' ') + args); diff --git a/src/plugins/winrt/winrtrunnerhelper.cpp b/src/plugins/winrt/winrtrunnerhelper.cpp index 4ef9b5972bd..8a9793fa56b 100644 --- a/src/plugins/winrt/winrtrunnerhelper.cpp +++ b/src/plugins/winrt/winrtrunnerhelper.cpp @@ -224,7 +224,7 @@ void WinRtRunnerHelper::startWinRtRunner(const RunConf &conf) } process->setUseCtrlCStub(true); - process->setCommand(m_runnerFilePath, runnerArgs); + process->setCommand(CommandLine(FilePath::fromString(m_runnerFilePath), runnerArgs)); process->setEnvironment(m_environment); process->setWorkingDirectory(QFileInfo(m_executableFilePath).absolutePath()); process->start(); |