Use Utils::FilePath in SynchronousProcess

Adapt callers and surrounding code.

Change-Id: Ie6c1883a44169cf9d790d06b660f46d24dc24c89
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-06-06 16:27:55 +02:00
parent 021d3a6c59
commit ca4ba34229
48 changed files with 202 additions and 221 deletions

View File

@@ -49,6 +49,7 @@
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/benchmarker.h> #include <utils/benchmarker.h>
#include <utils/executeondestruction.h> #include <utils/executeondestruction.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/mimetypes/mimedatabase.h> #include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -413,10 +414,10 @@ static QString filled(const QString &s, int min)
QString PluginManager::systemInformation() const QString PluginManager::systemInformation() const
{ {
QString result; QString result;
const QString qtdiagBinary = HostOsInfo::withExecutableSuffix( CommandLine qtDiag(FilePath::fromString(HostOsInfo::withExecutableSuffix(
QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qtdiag"); QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qtdiag")));
SynchronousProcess qtdiagProc; SynchronousProcess qtdiagProc;
const SynchronousProcessResponse response = qtdiagProc.runBlocking(qtdiagBinary, QStringList()); const SynchronousProcessResponse response = qtdiagProc.runBlocking(qtDiag);
if (response.result == SynchronousProcessResponse::Finished) if (response.result == SynchronousProcessResponse::Finished)
result += response.allOutput() + "\n"; result += response.allOutput() + "\n";
result += "Plugin information:\n\n"; result += "Plugin information:\n\n";

View File

@@ -46,7 +46,7 @@ QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
const QString toolDir = QLatin1String("QTTOOLDIR=\""); const QString toolDir = QLatin1String("QTTOOLDIR=\"");
SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(1); proc.setTimeoutS(1);
SynchronousProcessResponse response = proc.runBlocking(path, QStringList(QLatin1String("-print-env"))); SynchronousProcessResponse response = proc.runBlocking({FilePath::fromString(path), {"-print-env"}});
if (response.result != SynchronousProcessResponse::Finished) if (response.result != SynchronousProcessResponse::Finished)
return QString(); return QString();
const QString output = response.stdOut(); const QString output = response.stdOut();
@@ -130,7 +130,7 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath)
SynchronousProcess qmake; SynchronousProcess qmake;
qmake.setTimeoutS(5); qmake.setTimeoutS(5);
SynchronousProcessResponse response = qmake.runBlocking(qmakePath, QStringList(QLatin1String("--version"))); SynchronousProcessResponse response = qmake.runBlocking({FilePath::fromString(qmakePath), {"--version"}});
if (response.result != SynchronousProcessResponse::Finished) { if (response.result != SynchronousProcessResponse::Finished) {
qWarning() << response.exitMessage(qmakePath, 5); qWarning() << response.exitMessage(qmakePath, 5);
return QString(); return QString();

View File

@@ -84,7 +84,7 @@ public:
QStringList arguments() const { return m_arguments; } QStringList arguments() const { return m_arguments; }
void setArguments(const QStringList &arguments) { m_arguments = arguments; } void setArguments(const QStringList &arguments) { m_arguments = arguments; }
static QString toolVersion(const QString &binary, const QStringList &arguments); static QString toolVersion(const CommandLine &cmd);
private: private:
// Extension point for concatenating existing tooltips. // Extension point for concatenating existing tooltips.
@@ -108,7 +108,8 @@ bool BinaryVersionToolTipEventFilter::eventFilter(QObject *o, QEvent *e)
const QString binary = le->text(); const QString binary = le->text();
if (!binary.isEmpty()) { if (!binary.isEmpty()) {
const QString version = BinaryVersionToolTipEventFilter::toolVersion(QDir::cleanPath(binary), m_arguments); const QString version = BinaryVersionToolTipEventFilter::toolVersion(
CommandLine(FilePath::fromString(QDir::cleanPath(binary)), m_arguments));
if (!version.isEmpty()) { if (!version.isEmpty()) {
// Concatenate tooltips. // Concatenate tooltips.
QString tooltip = "<html><head/><body>"; QString tooltip = "<html><head/><body>";
@@ -127,13 +128,13 @@ bool BinaryVersionToolTipEventFilter::eventFilter(QObject *o, QEvent *e)
return false; return false;
} }
QString BinaryVersionToolTipEventFilter::toolVersion(const QString &binary, const QStringList &arguments) QString BinaryVersionToolTipEventFilter::toolVersion(const CommandLine &cmd)
{ {
if (binary.isEmpty()) if (cmd.executable().isEmpty())
return QString(); return QString();
SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(1); proc.setTimeoutS(1);
SynchronousProcessResponse response = proc.runBlocking(binary, arguments); SynchronousProcessResponse response = proc.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished) if (response.result != SynchronousProcessResponse::Finished)
return QString(); return QString();
return response.allOutput(); return response.allOutput();
@@ -677,7 +678,7 @@ FancyLineEdit *PathChooser::lineEdit() const
QString PathChooser::toolVersion(const QString &binary, const QStringList &arguments) QString PathChooser::toolVersion(const QString &binary, const QStringList &arguments)
{ {
return BinaryVersionToolTipEventFilter::toolVersion(binary, arguments); return BinaryVersionToolTipEventFilter::toolVersion({FilePath::fromString(binary), arguments});
} }
void PathChooser::installLineEditVersionToolTip(QLineEdit *le, const QStringList &arguments) void PathChooser::installLineEditVersionToolTip(QLineEdit *le, const QStringList &arguments)

View File

@@ -341,9 +341,9 @@ SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary,
if ((d->m_flags & FullySynchronously) if ((d->m_flags & FullySynchronously)
|| (!(d->m_flags & NoFullySync) || (!(d->m_flags & NoFullySync)
&& QThread::currentThread() == QCoreApplication::instance()->thread())) { && QThread::currentThread() == QCoreApplication::instance()->thread())) {
response = runFullySynchronous(binary, arguments, proxy, timeoutS, dir, interpreter); response = runFullySynchronous({binary, arguments}, proxy, timeoutS, dir, interpreter);
} else { } else {
response = runSynchronous(binary, arguments, proxy, timeoutS, dir, interpreter); response = runSynchronous({binary, arguments}, proxy, timeoutS, dir, interpreter);
} }
if (!d->m_aborted) { if (!d->m_aborted) {
@@ -359,8 +359,7 @@ SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary,
return response; return response;
} }
SynchronousProcessResponse ShellCommand::runFullySynchronous(const FilePath &binary, SynchronousProcessResponse ShellCommand::runFullySynchronous(const CommandLine &cmd,
const QStringList &arguments,
QSharedPointer<OutputProxy> proxy, QSharedPointer<OutputProxy> proxy,
int timeoutS, int timeoutS,
const QString &workingDirectory, const QString &workingDirectory,
@@ -380,7 +379,7 @@ SynchronousProcessResponse ShellCommand::runFullySynchronous(const FilePath &bin
process.setTimeoutS(timeoutS); process.setTimeoutS(timeoutS);
process.setExitCodeInterpreter(interpreter); process.setExitCodeInterpreter(interpreter);
SynchronousProcessResponse resp = process.runBlocking(binary.toString(), arguments); SynchronousProcessResponse resp = process.runBlocking(cmd);
if (!d->m_aborted) { if (!d->m_aborted) {
const QString stdErr = resp.stdErr(); const QString stdErr = resp.stdErr();
@@ -399,8 +398,7 @@ SynchronousProcessResponse ShellCommand::runFullySynchronous(const FilePath &bin
return resp; return resp;
} }
SynchronousProcessResponse ShellCommand::runSynchronous(const FilePath &binary, SynchronousProcessResponse ShellCommand::runSynchronous(const CommandLine &cmd,
const QStringList &arguments,
QSharedPointer<OutputProxy> proxy, QSharedPointer<OutputProxy> proxy,
int timeoutS, int timeoutS,
const QString &workingDirectory, const QString &workingDirectory,
@@ -460,7 +458,7 @@ SynchronousProcessResponse ShellCommand::runSynchronous(const FilePath &binary,
process.setTimeoutS(timeoutS); process.setTimeoutS(timeoutS);
process.setExitCodeInterpreter(interpreter); process.setExitCodeInterpreter(interpreter);
return process.run(binary.toString(), arguments); return process.run(cmd);
} }
const QVariant &ShellCommand::cookie() const const QVariant &ShellCommand::cookie() const

View File

@@ -171,12 +171,12 @@ private:
void run(QFutureInterface<void> &future); void run(QFutureInterface<void> &future);
// Run without a event loop in fully blocking mode. No signals will be delivered. // Run without a event loop in fully blocking mode. No signals will be delivered.
SynchronousProcessResponse runFullySynchronous(const FilePath &binary, const QStringList &arguments, SynchronousProcessResponse runFullySynchronous(const CommandLine &cmd,
QSharedPointer<OutputProxy> proxy, QSharedPointer<OutputProxy> proxy,
int timeoutS, const QString &workingDirectory, int timeoutS, const QString &workingDirectory,
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter); const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
// Run with an event loop. Signals will be delivered. // Run with an event loop. Signals will be delivered.
SynchronousProcessResponse runSynchronous(const FilePath &binary, const QStringList &arguments, SynchronousProcessResponse runSynchronous(const CommandLine &cmd,
QSharedPointer<OutputProxy> proxy, QSharedPointer<OutputProxy> proxy,
int timeoutS, const QString &workingDirectory, int timeoutS, const QString &workingDirectory,
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter); const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);

View File

@@ -442,15 +442,6 @@ static bool isGuiThread()
return QThread::currentThread() == QCoreApplication::instance()->thread(); return QThread::currentThread() == QCoreApplication::instance()->thread();
} }
SynchronousProcessResponse SynchronousProcess::run(const QString &binary,
const QStringList &args,
const QByteArray &writeData)
{
CommandLine cmd(FilePath::fromString(binary), {});
cmd.addArgs(args);
return run(cmd, writeData);
}
SynchronousProcessResponse SynchronousProcess::run(const CommandLine &cmd, SynchronousProcessResponse SynchronousProcess::run(const CommandLine &cmd,
const QByteArray &writeData) const QByteArray &writeData)
{ {
@@ -506,14 +497,6 @@ SynchronousProcessResponse SynchronousProcess::run(const CommandLine &cmd,
return d->m_result; return d->m_result;
} }
SynchronousProcessResponse
SynchronousProcess::runBlocking(const QString &binary, const QStringList &args)
{
CommandLine cmd(FilePath::fromString(binary), {});
cmd.addArgs(args);
return runBlocking(cmd);
}
SynchronousProcessResponse SynchronousProcess::runBlocking(const CommandLine &cmd) SynchronousProcessResponse SynchronousProcess::runBlocking(const CommandLine &cmd)
{ {
d->clearForRun(); d->clearForRun();

View File

@@ -127,14 +127,8 @@ public:
void setExitCodeInterpreter(const ExitCodeInterpreter &interpreter); void setExitCodeInterpreter(const ExitCodeInterpreter &interpreter);
ExitCodeInterpreter exitCodeInterpreter() const; ExitCodeInterpreter exitCodeInterpreter() const;
// Starts a nested event loop and runs the binary with the arguments
// FIXME: Use the CommandLine overload below.
SynchronousProcessResponse run(const QString &binary, const QStringList &args, const QByteArray &writeData = {});
// Starts a nested event loop and runs the command // Starts a nested event loop and runs the command
SynchronousProcessResponse run(const CommandLine &cmd, const QByteArray &writeData = {}); SynchronousProcessResponse run(const CommandLine &cmd, const QByteArray &writeData = {});
// Starts the binary with the arguments blocking the UI fully
// FIXME: Use the CommandLine overload below.
SynchronousProcessResponse runBlocking(const QString &binary, const QStringList &args);
// Starts the command blocking the UI fully // Starts the command blocking the UI fully
SynchronousProcessResponse runBlocking(const CommandLine &cmd); SynchronousProcessResponse runBlocking(const CommandLine &cmd);

View File

@@ -41,6 +41,8 @@
#include <chrono> #include <chrono>
#include <functional> #include <functional>
using namespace Utils;
namespace { namespace {
Q_LOGGING_CATEGORY(avdManagerLog, "qtc.android.avdManager", QtWarningMsg) Q_LOGGING_CATEGORY(avdManagerLog, "qtc.android.avdManager", QtWarningMsg)
} }
@@ -67,11 +69,11 @@ const int avdCreateTimeoutMs = 30000;
*/ */
static bool avdManagerCommand(const AndroidConfig config, const QStringList &args, QString *output) static bool avdManagerCommand(const AndroidConfig config, const QStringList &args, QString *output)
{ {
QString avdManagerToolPath = config.avdManagerToolPath().toString(); CommandLine cmd(config.avdManagerToolPath(), args);
Utils::SynchronousProcess proc; Utils::SynchronousProcess proc;
auto env = AndroidConfigurations::toolsEnvironment(config).toStringList(); auto env = AndroidConfigurations::toolsEnvironment(config).toStringList();
proc.setEnvironment(env); proc.setEnvironment(env);
Utils::SynchronousProcessResponse response = proc.runBlocking(avdManagerToolPath, args); SynchronousProcessResponse response = proc.runBlocking(cmd);
if (response.result == Utils::SynchronousProcessResponse::Finished) { if (response.result == Utils::SynchronousProcessResponse::Finished) {
if (output) if (output)
*output = response.allOutput(); *output = response.allOutput();
@@ -258,8 +260,7 @@ bool AndroidAvdManager::removeAvd(const QString &name) const
Utils::SynchronousProcess proc; Utils::SynchronousProcess proc;
proc.setTimeoutS(5); proc.setTimeoutS(5);
Utils::SynchronousProcessResponse response Utils::SynchronousProcessResponse response
= proc.runBlocking(m_config.avdManagerToolPath().toString(), = proc.runBlocking({m_config.avdManagerToolPath(), {"delete", "avd", "-n", name}});
QStringList({"delete", "avd", "-n", name}));
return response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0; return response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0;
} }
@@ -345,10 +346,9 @@ bool AndroidAvdManager::isAvdBooted(const QString &device) const
QStringList arguments = AndroidDeviceInfo::adbSelector(device); QStringList arguments = AndroidDeviceInfo::adbSelector(device);
arguments << "shell" << "getprop" << "init.svc.bootanim"; arguments << "shell" << "getprop" << "init.svc.bootanim";
Utils::SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(10); adbProc.setTimeoutS(10);
Utils::SynchronousProcessResponse response = SynchronousProcessResponse response = adbProc.runBlocking({m_config.adbToolPath(), arguments});
adbProc.runBlocking(m_config.adbToolPath().toString(), arguments);
if (response.result != Utils::SynchronousProcessResponse::Finished) if (response.result != Utils::SynchronousProcessResponse::Finished)
return false; return false;
QString value = response.allOutput().trimmed(); QString value = response.allOutput().trimmed();
@@ -376,7 +376,7 @@ bool AndroidAvdManager::waitForBooted(const QString &serialNumber,
AndroidDeviceInfoList AvdManagerOutputParser::listVirtualDevices(const AndroidConfig &config) AndroidDeviceInfoList AvdManagerOutputParser::listVirtualDevices(const AndroidConfig &config)
{ {
QString output; QString output;
if (!avdManagerCommand(config, QStringList({"list", "avd"}), &output)) { if (!avdManagerCommand(config, {"list", "avd"}, &output)) {
qCDebug(avdManagerLog) << "Avd list command failed" << output << config.sdkToolsVersion(); qCDebug(avdManagerLog) << "Avd list command failed" << output << config.sdkToolsVersion();
return {}; return {};
} }

View File

@@ -577,8 +577,8 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
Utils::SynchronousProcess keytoolProc; Utils::SynchronousProcess keytoolProc;
keytoolProc.setTimeoutS(30); keytoolProc.setTimeoutS(30);
const Utils::SynchronousProcessResponse response const SynchronousProcessResponse response
= keytoolProc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), params); = keytoolProc.run({AndroidConfigurations::currentConfig().keytoolPath(), params});
if (response.result > Utils::SynchronousProcessResponse::FinishedError) if (response.result > Utils::SynchronousProcessResponse::FinishedError)
QMessageBox::critical(nullptr, tr("Error"), tr("Failed to run keytool.")); QMessageBox::critical(nullptr, tr("Error"), tr("Failed to run keytool."));
else else

View File

@@ -140,7 +140,8 @@ namespace {
SynchronousProcess proc; SynchronousProcess proc;
proc.setProcessChannelMode(QProcess::MergedChannels); proc.setProcessChannelMode(QProcess::MergedChannels);
proc.setTimeoutS(30); proc.setTimeoutS(30);
SynchronousProcessResponse response = proc.runBlocking(executable, QStringList(shell)); SynchronousProcessResponse response
= proc.runBlocking({FilePath::fromString(executable), {shell}});
if (response.result != SynchronousProcessResponse::Finished) if (response.result != SynchronousProcessResponse::Finished)
return true; return true;
return !response.allOutput().contains("x86-64"); return !response.allOutput().contains("x86-64");
@@ -429,20 +430,20 @@ FilePath AndroidConfig::keytoolPath() const
QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const
{ {
return connectedDevices(adbToolPath().toString(), error); return connectedDevices(adbToolPath(), error);
} }
QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const QString &adbToolPath, QString *error) QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const FilePath &adbToolPath, QString *error)
{ {
QVector<AndroidDeviceInfo> devices; QVector<AndroidDeviceInfo> devices;
SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(30); adbProc.setTimeoutS(30);
SynchronousProcessResponse response = adbProc.runBlocking(adbToolPath, QStringList("devices")); CommandLine cmd{adbToolPath, {"devices"}};
SynchronousProcessResponse response = adbProc.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished) { if (response.result != SynchronousProcessResponse::Finished) {
if (error) if (error)
*error = QApplication::translate("AndroidConfiguration", *error = QApplication::translate("AndroidConfiguration", "Could not run: %1")
"Could not run: %1") .arg(cmd.toUserOutput());
.arg(adbToolPath + QLatin1String(" devices"));
return devices; return devices;
} }
QStringList adbDevs = response.allOutput().split('\n', QString::SkipEmptyParts); QStringList adbDevs = response.allOutput().split('\n', QString::SkipEmptyParts);
@@ -485,7 +486,7 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const QString &adbToo
if (devices.isEmpty() && error) if (devices.isEmpty() && error)
*error = QApplication::translate("AndroidConfiguration", *error = QApplication::translate("AndroidConfiguration",
"No devices found in output of: %1") "No devices found in output of: %1")
.arg(adbToolPath + QLatin1String(" devices")); .arg(cmd.toUserOutput());
return devices; return devices;
} }
@@ -501,33 +502,33 @@ bool AndroidConfig::isConnected(const QString &serialNumber) const
bool AndroidConfig::isBootToQt(const QString &device) const bool AndroidConfig::isBootToQt(const QString &device) const
{ {
return isBootToQt(adbToolPath().toString(), device); return isBootToQt(adbToolPath(), device);
} }
bool AndroidConfig::isBootToQt(const QString &adbToolPath, const QString &device) bool AndroidConfig::isBootToQt(const FilePath &adbToolPath, const QString &device)
{ {
// workaround for '????????????' serial numbers // workaround for '????????????' serial numbers
QStringList arguments = AndroidDeviceInfo::adbSelector(device); CommandLine cmd(adbToolPath, AndroidDeviceInfo::adbSelector(device));
arguments << QLatin1String("shell") cmd.addArg("shell");
<< QLatin1String("ls -l /system/bin/appcontroller || ls -l /usr/bin/appcontroller && echo Boot2Qt"); cmd.addArg("ls -l /system/bin/appcontroller || ls -l /usr/bin/appcontroller && echo Boot2Qt");
SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(10); adbProc.setTimeoutS(10);
SynchronousProcessResponse response = adbProc.runBlocking(adbToolPath, arguments); SynchronousProcessResponse response = adbProc.runBlocking(cmd);
return response.result == SynchronousProcessResponse::Finished return response.result == SynchronousProcessResponse::Finished
&& response.allOutput().contains(QLatin1String("Boot2Qt")); && response.allOutput().contains(QLatin1String("Boot2Qt"));
} }
QString AndroidConfig::getDeviceProperty(const QString &adbToolPath, const QString &device, const QString &property) QString AndroidConfig::getDeviceProperty(const FilePath &adbToolPath, const QString &device, const QString &property)
{ {
// workaround for '????????????' serial numbers // workaround for '????????????' serial numbers
QStringList arguments = AndroidDeviceInfo::adbSelector(device); CommandLine cmd(adbToolPath, AndroidDeviceInfo::adbSelector(device));
arguments << QLatin1String("shell") << QLatin1String("getprop") << property; cmd.addArgs({"shell", "getprop", property});
SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(10); adbProc.setTimeoutS(10);
SynchronousProcessResponse response = adbProc.runBlocking(adbToolPath, arguments); SynchronousProcessResponse response = adbProc.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished) if (response.result != SynchronousProcessResponse::Finished)
return QString(); return QString();
@@ -536,12 +537,12 @@ QString AndroidConfig::getDeviceProperty(const QString &adbToolPath, const QStri
int AndroidConfig::getSDKVersion(const QString &device) const int AndroidConfig::getSDKVersion(const QString &device) const
{ {
return getSDKVersion(adbToolPath().toString(), device); return getSDKVersion(adbToolPath(), device);
} }
int AndroidConfig::getSDKVersion(const QString &adbToolPath, const QString &device) int AndroidConfig::getSDKVersion(const FilePath &adbToolPath, const QString &device)
{ {
QString tmp = getDeviceProperty(adbToolPath, device, QLatin1String("ro.build.version.sdk")); QString tmp = getDeviceProperty(adbToolPath, device, "ro.build.version.sdk");
if (tmp.isEmpty()) if (tmp.isEmpty())
return -1; return -1;
return tmp.trimmed().toInt(); return tmp.trimmed().toInt();
@@ -612,7 +613,7 @@ QString AndroidConfig::getProductModel(const QString &device) const
if (m_serialNumberToDeviceName.contains(device)) if (m_serialNumberToDeviceName.contains(device))
return m_serialNumberToDeviceName.value(device); return m_serialNumberToDeviceName.value(device);
QString model = getDeviceProperty(adbToolPath().toString(), device, QLatin1String("ro.product.model")).trimmed(); QString model = getDeviceProperty(adbToolPath(), device, "ro.product.model").trimmed();
if (model.isEmpty()) if (model.isEmpty())
return device; return device;
@@ -623,18 +624,18 @@ QString AndroidConfig::getProductModel(const QString &device) const
QStringList AndroidConfig::getAbis(const QString &device) const QStringList AndroidConfig::getAbis(const QString &device) const
{ {
return getAbis(adbToolPath().toString(), device); return getAbis(adbToolPath(), device);
} }
QStringList AndroidConfig::getAbis(const QString &adbToolPath, const QString &device) QStringList AndroidConfig::getAbis(const FilePath &adbToolPath, const QString &device)
{ {
QStringList result; QStringList result;
// First try via ro.product.cpu.abilist // First try via ro.product.cpu.abilist
QStringList arguments = AndroidDeviceInfo::adbSelector(device); QStringList arguments = AndroidDeviceInfo::adbSelector(device);
arguments << QLatin1String("shell") << QLatin1String("getprop") << QLatin1String("ro.product.cpu.abilist"); arguments << "shell" << "getprop" << "ro.product.cpu.abilist";
SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(10); adbProc.setTimeoutS(10);
SynchronousProcessResponse response = adbProc.runBlocking(adbToolPath, arguments); SynchronousProcessResponse response = adbProc.runBlocking({adbToolPath, arguments});
if (response.result != SynchronousProcessResponse::Finished) if (response.result != SynchronousProcessResponse::Finished)
return result; return result;
@@ -656,7 +657,7 @@ QStringList AndroidConfig::getAbis(const QString &adbToolPath, const QString &de
SynchronousProcess abiProc; SynchronousProcess abiProc;
abiProc.setTimeoutS(10); abiProc.setTimeoutS(10);
SynchronousProcessResponse abiResponse = abiProc.runBlocking(adbToolPath, arguments); SynchronousProcessResponse abiResponse = abiProc.runBlocking({adbToolPath, arguments});
if (abiResponse.result != SynchronousProcessResponse::Finished) if (abiResponse.result != SynchronousProcessResponse::Finished)
return result; return result;
@@ -1187,7 +1188,8 @@ void AndroidConfigurations::load()
SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(2); proc.setTimeoutS(2);
proc.setProcessChannelMode(QProcess::MergedChannels); proc.setProcessChannelMode(QProcess::MergedChannels);
SynchronousProcessResponse response = proc.runBlocking(javaHomeExec.absoluteFilePath(), QStringList()); SynchronousProcessResponse response =
proc.runBlocking({FilePath::fromString(javaHomeExec.absoluteFilePath()), {}});
if (response.result == SynchronousProcessResponse::Finished) { if (response.result == SynchronousProcessResponse::Finished) {
const QString &javaHome = response.allOutput().trimmed(); const QString &javaHome = response.allOutput().trimmed();
if (!javaHome.isEmpty() && QFileInfo::exists(javaHome)) if (!javaHome.isEmpty() && QFileInfo::exists(javaHome))

View File

@@ -139,7 +139,7 @@ public:
Utils::FilePath keytoolPath() const; Utils::FilePath keytoolPath() const;
QVector<AndroidDeviceInfo> connectedDevices(QString *error = nullptr) const; QVector<AndroidDeviceInfo> connectedDevices(QString *error = nullptr) const;
static QVector<AndroidDeviceInfo> connectedDevices(const QString &adbToolPath, QString *error = nullptr); static QVector<AndroidDeviceInfo> connectedDevices(const Utils::FilePath &adbToolPath, QString *error = nullptr);
QString bestNdkPlatformMatch(int target) const; QString bestNdkPlatformMatch(int target) const;
@@ -156,14 +156,15 @@ public:
bool useNativeUiTools() const; bool useNativeUiTools() const;
private: private:
static QString getDeviceProperty(const QString &adbToolPath, const QString &device, const QString &property); static QString getDeviceProperty(const Utils::FilePath &adbToolPath,
const QString &device, const QString &property);
Utils::FilePath openJDKBinPath() const; Utils::FilePath openJDKBinPath() const;
int getSDKVersion(const QString &device) const; int getSDKVersion(const QString &device) const;
static int getSDKVersion(const QString &adbToolPath, const QString &device); static int getSDKVersion(const Utils::FileName &adbToolPath, const QString &device);
QStringList getAbis(const QString &device) const; QStringList getAbis(const QString &device) const;
static QStringList getAbis(const QString &adbToolPath, const QString &device); static QStringList getAbis(const Utils::FilePath &adbToolPath, const QString &device);
static bool isBootToQt(const QString &adbToolPath, const QString &device); static bool isBootToQt(const Utils::FilePath &adbToolPath, const QString &device);
bool isBootToQt(const QString &device) const; bool isBootToQt(const QString &device) const;
static QString getAvdName(const QString &serialnumber); static QString getAvdName(const QString &serialnumber);

View File

@@ -32,6 +32,8 @@
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
using namespace Utils;
using namespace Android::Internal; using namespace Android::Internal;
AndroidCreateKeystoreCertificate::AndroidCreateKeystoreCertificate(QWidget *parent) : AndroidCreateKeystoreCertificate::AndroidCreateKeystoreCertificate(QWidget *parent) :
@@ -169,24 +171,23 @@ void AndroidCreateKeystoreCertificate::on_buttonBox_accepted()
if (ui->stateNameLineEdit->text().length()) if (ui->stateNameLineEdit->text().length())
distinguishedNames += QLatin1String(", S=") + ui->stateNameLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,")); distinguishedNames += QLatin1String(", S=") + ui->stateNameLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,"));
const QString command = AndroidConfigurations::currentConfig().keytoolPath().toString(); const CommandLine command(AndroidConfigurations::currentConfig().keytoolPath(),
QStringList params; { "-genkey", "-keyalg", "RSA",
params << QLatin1String("-genkey") << QLatin1String("-keyalg") << QLatin1String("RSA") "-keystore", m_keystoreFilePath.toString(),
<< QLatin1String("-keystore") << m_keystoreFilePath.toString() "-storepass", keystorePassword(),
<< QLatin1String("-storepass") << keystorePassword() "-alias", certificateAlias(),
<< QLatin1String("-alias") << certificateAlias() "-keysize", ui->keySizeSpinBox->text(),
<< QLatin1String("-keysize") << ui->keySizeSpinBox->text() "-validity", ui->validitySpinBox->text(),
<< QLatin1String("-validity") << ui->validitySpinBox->text() "-keypass", certificatePassword(),
<< QLatin1String("-keypass") << certificatePassword() "-dname", distinguishedNames});
<< QLatin1String("-dname") << distinguishedNames;
Utils::SynchronousProcess genKeyCertProc; SynchronousProcess genKeyCertProc;
genKeyCertProc.setTimeoutS(15); genKeyCertProc.setTimeoutS(15);
Utils::SynchronousProcessResponse response = genKeyCertProc.run(command, params); SynchronousProcessResponse response = genKeyCertProc.run(command);
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) { if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) {
QMessageBox::critical(this, tr("Error"), QMessageBox::critical(this, tr("Error"),
response.exitMessage(command, 15) + QLatin1Char('\n') + response.allOutput()); response.exitMessage(command.executable().toString(), 15) + '\n' + response.allOutput());
return; return;
} }
accept(); accept();

View File

@@ -345,9 +345,9 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
} }
qCDebug(deployStepLog) << "Uninstalling previous package"; qCDebug(deployStepLog) << "Uninstalling previous package";
emit addOutput(tr("Uninstall previous package %1.").arg(packageName), OutputFormat::NormalMessage); emit addOutput(tr("Uninstall previous package %1.").arg(packageName), OutputFormat::NormalMessage);
runCommand(m_adbPath.toString(), runCommand({m_adbPath,
AndroidDeviceInfo::adbSelector(m_serialNumber) AndroidDeviceInfo::adbSelector(m_serialNumber)
<< QLatin1String("uninstall") << packageName); << "uninstall" << packageName});
} }
cmd.addArgs(AndroidDeviceInfo::adbSelector(m_serialNumber)); cmd.addArgs(AndroidDeviceInfo::adbSelector(m_serialNumber));
@@ -489,9 +489,9 @@ bool AndroidDeployQtStep::runImpl()
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr) { for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr) {
QFile::remove(itr.value()); QFile::remove(itr.value());
runCommand(m_adbPath.toString(), runCommand({m_adbPath,
AndroidDeviceInfo::adbSelector(m_serialNumber) AndroidDeviceInfo::adbSelector(m_serialNumber)
<< "pull" << itr.key() << itr.value()); << "pull" << itr.key() << itr.value()});
if (!QFileInfo::exists(itr.value())) { if (!QFileInfo::exists(itr.value())) {
emit addOutput(tr("Package deploy: Failed to pull \"%1\" to \"%2\".") emit addOutput(tr("Package deploy: Failed to pull \"%1\" to \"%2\".")
.arg(itr.key()) .arg(itr.key())
@@ -545,14 +545,16 @@ void AndroidDeployQtStep::doRun()
runInThread([this] { return runImpl(); }); runInThread([this] { return runImpl(); });
} }
void AndroidDeployQtStep::runCommand(const QString &program, const QStringList &arguments) void AndroidDeployQtStep::runCommand(const CommandLine &command)
{ {
Utils::SynchronousProcess buildProc; SynchronousProcess buildProc;
buildProc.setTimeoutS(2 * 60); buildProc.setTimeoutS(2 * 60);
emit addOutput(tr("Package deploy: Running command \"%1 %2\".").arg(program).arg(arguments.join(QLatin1Char(' '))), BuildStep::OutputFormat::NormalMessage); emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
Utils::SynchronousProcessResponse response = buildProc.run(program, arguments); OutputFormat::NormalMessage);
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) SynchronousProcessResponse response = buildProc.run(command);
emit addOutput(response.exitMessage(program, 2 * 60), BuildStep::OutputFormat::ErrorMessage); if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0)
emit addOutput(response.exitMessage(command.executable().toString(), 2 * 60),
OutputFormat::ErrorMessage);
} }
ProjectExplorer::BuildStepConfigWidget *AndroidDeployQtStep::createConfigWidget() ProjectExplorer::BuildStepConfigWidget *AndroidDeployQtStep::createConfigWidget()

View File

@@ -80,7 +80,7 @@ signals:
void setSerialNumber(const QString &serialNumber); void setSerialNumber(const QString &serialNumber);
private: private:
void runCommand(const QString &program, const QStringList &arguments); void runCommand(const Utils::CommandLine &command);
bool init() override; bool init() override;
void doRun() override; void doRun() override;

View File

@@ -473,7 +473,7 @@ AndroidDeviceDialog::AndroidDeviceDialog(int apiLevel, const QString &abi,
connect(m_ui->lookingForDeviceCancel, &QPushButton::clicked, connect(m_ui->lookingForDeviceCancel, &QPushButton::clicked,
this, &AndroidDeviceDialog::defaultDeviceClear); this, &AndroidDeviceDialog::defaultDeviceClear);
m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath().toString()); m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath());
} }
AndroidDeviceDialog::~AndroidDeviceDialog() AndroidDeviceDialog::~AndroidDeviceDialog()
@@ -512,7 +512,7 @@ void AndroidDeviceDialog::refreshDeviceList()
{ {
m_ui->refreshDevicesButton->setEnabled(false); m_ui->refreshDevicesButton->setEnabled(false);
m_progressIndicator->show(); m_progressIndicator->show();
m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath().toString()); m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath());
m_futureWatcherRefreshDevices.setFuture(m_avdManager->avdList()); m_futureWatcherRefreshDevices.setFuture(m_avdManager->avdList());
} }

View File

@@ -526,15 +526,11 @@ bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QS
{ {
if (keystorePasswd.isEmpty()) if (keystorePasswd.isEmpty())
return false; return false;
QStringList arguments; const CommandLine cmd(AndroidConfigurations::currentConfig().keytoolPath(),
arguments << QLatin1String("-list") {"-list", "-keystore", keystorePath, "--storepass", keystorePasswd});
<< QLatin1String("-keystore") SynchronousProcess proc;
<< keystorePath
<< QLatin1String("--storepass")
<< keystorePasswd;
Utils::SynchronousProcess proc;
proc.setTimeoutS(10); proc.setTimeoutS(10);
Utils::SynchronousProcessResponse response = proc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments); SynchronousProcessResponse response = proc.run(cmd);
return (response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0); return (response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0);
} }
@@ -548,11 +544,11 @@ bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const
else else
arguments << certificatePasswd; arguments << certificatePasswd;
Utils::SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(10); proc.setTimeoutS(10);
Utils::SynchronousProcessResponse response SynchronousProcessResponse response
= proc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments); = proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
return response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0; return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
} }
bool AndroidManager::checkCertificateExists(const QString &keystorePath, bool AndroidManager::checkCertificateExists(const QString &keystorePath,
@@ -562,11 +558,11 @@ bool AndroidManager::checkCertificateExists(const QString &keystorePath,
QStringList arguments = { "-list", "-keystore", keystorePath, QStringList arguments = { "-list", "-keystore", keystorePath,
"--storepass", keystorePasswd, "-alias", alias }; "--storepass", keystorePasswd, "-alias", alias };
Utils::SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(10); proc.setTimeoutS(10);
Utils::SynchronousProcessResponse response SynchronousProcessResponse response
= proc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments); = proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
return response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0; return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
} }
using GradleProperties = QMap<QByteArray, QByteArray>; using GradleProperties = QMap<QByteArray, QByteArray>;
@@ -716,35 +712,35 @@ QProcess *AndroidManager::runAdbCommandDetached(const QStringList &args, QString
return nullptr; return nullptr;
} }
SdkToolResult AndroidManager::runCommand(const QString &executable, const QStringList &args, SdkToolResult AndroidManager::runCommand(const CommandLine &command,
const QByteArray &writeData, int timeoutS) const QByteArray &writeData, int timeoutS)
{ {
Android::SdkToolResult cmdResult; Android::SdkToolResult cmdResult;
Utils::SynchronousProcess cmdProc; Utils::SynchronousProcess cmdProc;
cmdProc.setTimeoutS(timeoutS); cmdProc.setTimeoutS(timeoutS);
qCDebug(androidManagerLog) << "Running command: " << executable << args.join(' '); qCDebug(androidManagerLog) << "Running command: " << command.toUserOutput();
Utils::SynchronousProcessResponse response = cmdProc.run(executable, args, writeData); SynchronousProcessResponse response = cmdProc.run(command, writeData);
cmdResult.m_stdOut = response.stdOut().trimmed(); cmdResult.m_stdOut = response.stdOut().trimmed();
cmdResult.m_stdErr = response.stdErr().trimmed(); cmdResult.m_stdErr = response.stdErr().trimmed();
cmdResult.m_success = response.result == Utils::SynchronousProcessResponse::Finished; cmdResult.m_success = response.result == Utils::SynchronousProcessResponse::Finished;
qCDebug(androidManagerLog) << "Running command finshed:" << executable << args.join(' ') qCDebug(androidManagerLog) << "Running command finshed:" << command.toUserOutput()
<< "Success:" << cmdResult.m_success << "Success:" << cmdResult.m_success
<< "Output:" << response.allRawOutput(); << "Output:" << response.allRawOutput();
if (!cmdResult.success()) if (!cmdResult.success())
cmdResult.m_exitMessage = response.exitMessage(executable, timeoutS); cmdResult.m_exitMessage = response.exitMessage(command.executable().toString(), timeoutS);
return cmdResult; return cmdResult;
} }
SdkToolResult AndroidManager::runAdbCommand(const QStringList &args, SdkToolResult AndroidManager::runAdbCommand(const QStringList &args,
const QByteArray &writeData, int timeoutS) const QByteArray &writeData, int timeoutS)
{ {
return runCommand(AndroidConfigurations::currentConfig().adbToolPath().toString(), args, return runCommand({AndroidConfigurations::currentConfig().adbToolPath(), args},
writeData, timeoutS); writeData, timeoutS);
} }
SdkToolResult AndroidManager::runAaptCommand(const QStringList &args, int timeoutS) SdkToolResult AndroidManager::runAaptCommand(const QStringList &args, int timeoutS)
{ {
return runCommand(AndroidConfigurations::currentConfig().aaptToolPath().toString(), args, {}, return runCommand({AndroidConfigurations::currentConfig().aaptToolPath(), args}, {},
timeoutS); timeoutS);
} }
} // namespace Android } // namespace Android

View File

@@ -40,7 +40,10 @@ class Kit;
class Target; class Target;
} }
namespace Utils { class FilePath; } namespace Utils {
class CommandLine;
class FilePath;
}
namespace Android { namespace Android {
@@ -118,7 +121,7 @@ public:
static QJsonObject deploymentSettings(const ProjectExplorer::Target *target); static QJsonObject deploymentSettings(const ProjectExplorer::Target *target);
private: private:
static SdkToolResult runCommand(const QString &executable, const QStringList &args, static SdkToolResult runCommand(const Utils::CommandLine &command,
const QByteArray &writeData = {}, int timeoutS = 30); const QByteArray &writeData = {}, int timeoutS = 30);
}; };

View File

@@ -63,6 +63,7 @@ static const int GdbTempFileMaxCounter = 20;
using namespace std; using namespace std;
using namespace std::placeholders; using namespace std::placeholders;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace Android { namespace Android {
namespace Internal { namespace Internal {
@@ -126,10 +127,10 @@ static void findProcessPID(QFutureInterface<qint64> &fi, QStringList selector,
chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now(); chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now();
do { do {
QThread::msleep(200); QThread::msleep(200);
QString adbPath = AndroidConfigurations::currentConfig().adbToolPath().toString(); FilePath adbPath = AndroidConfigurations::currentConfig().adbToolPath();
selector.append("shell"); selector.append("shell");
selector.append(preNougat ? pidScriptPreNougat : pidScript.arg(packageName)); selector.append(preNougat ? pidScriptPreNougat : pidScript.arg(packageName));
const auto out = Utils::SynchronousProcess().runBlocking(adbPath, selector).allRawOutput(); const auto out = SynchronousProcess().runBlocking({adbPath, selector}).allRawOutput();
if (preNougat) { if (preNougat) {
processPID = extractPID(out, packageName); processPID = extractPID(out, packageName);
} else { } else {

View File

@@ -136,7 +136,7 @@ static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(config)); proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(config));
proc.setTimeoutS(timeout); proc.setTimeoutS(timeout);
proc.setTimeOutMessageBoxEnabled(true); proc.setTimeOutMessageBoxEnabled(true);
SynchronousProcessResponse response = proc.run(config.sdkManagerToolPath().toString(), args); SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), args});
if (output) if (output)
*output = response.allOutput(); *output = response.allOutput();
return response.result == SynchronousProcessResponse::Finished; return response.result == SynchronousProcessResponse::Finished;
@@ -175,7 +175,7 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations, QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations,
&proc, &SynchronousProcess::terminate); &proc, &SynchronousProcess::terminate);
} }
SynchronousProcessResponse response = proc.run(config.sdkManagerToolPath().toString(), args); SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), args});
if (assertionFound) { if (assertionFound) {
output.success = false; output.success = false;
output.stdOutput = response.stdOut(); output.stdOutput = response.stdOut();

View File

@@ -60,10 +60,9 @@ public:
static bool androidToolCommand(Utils::FilePath toolPath, const QStringList &args, static bool androidToolCommand(Utils::FilePath toolPath, const QStringList &args,
const QProcessEnvironment &environment, QString *output) const QProcessEnvironment &environment, QString *output)
{ {
QString androidToolPath = toolPath.toString();
SynchronousProcess proc; SynchronousProcess proc;
proc.setProcessEnvironment(environment); proc.setProcessEnvironment(environment);
SynchronousProcessResponse response = proc.runBlocking(androidToolPath, args); SynchronousProcessResponse response = proc.runBlocking({toolPath, args});
if (response.result == SynchronousProcessResponse::Finished) { if (response.result == SynchronousProcessResponse::Finished) {
if (output) if (output)
*output = response.allOutput(); *output = response.allOutput();
@@ -131,8 +130,7 @@ bool AndroidToolManager::removeAvd(const QString &name) const
proc.setTimeoutS(5); proc.setTimeoutS(5);
proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(m_config)); proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(m_config));
SynchronousProcessResponse response SynchronousProcessResponse response
= proc.runBlocking(m_config.androidToolPath().toString(), = proc.runBlocking({m_config.androidToolPath(), {"delete", "avd", "-n", name}});
QStringList({"delete", "avd", "-n", name}));
return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0; return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
} }

View File

@@ -85,8 +85,7 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const Core::Id lang
cpp.setEnvironment(env); cpp.setEnvironment(env);
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
CommandLine cmd(compiler, {}); CommandLine cmd(compiler, {fakeIn.fileName()});
cmd.addArg(fakeIn.fileName());
if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID) if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
cmd.addArg("--ec++"); cmd.addArg("--ec++");
cmd.addArg("--predef_macros"); cmd.addArg("--predef_macros");
@@ -131,8 +130,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Core::Id lang
cpp.setEnvironment(env); cpp.setEnvironment(env);
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
CommandLine cmd(compiler, {}); CommandLine cmd(compiler, {fakeIn.fileName()});
cmd.addArg(fakeIn.fileName());
if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID) if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
cmd.addArg("--ec++"); cmd.addArg("--ec++");
cmd.addArg("--preinclude"); cmd.addArg("--preinclude");

View File

@@ -102,8 +102,7 @@ static Macros dumpC51PredefinedMacros(const FilePath &compiler, const QStringLis
cpp.setEnvironment(env); cpp.setEnvironment(env);
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
CommandLine cmd(compiler, {}); const CommandLine cmd(compiler, {fakeIn.fileName()});
cmd.addArg(fakeIn.fileName());
const SynchronousProcessResponse response = cpp.runBlocking(cmd); const SynchronousProcessResponse response = cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished if (response.result != SynchronousProcessResponse::Finished
@@ -131,8 +130,7 @@ static Macros dumpArmPredefinedMacros(const FilePath &compiler, const QStringLis
cpp.setEnvironment(env); cpp.setEnvironment(env);
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
CommandLine cmd(compiler, {}); const CommandLine cmd(compiler, {"-E", "--list-macros"});
cmd.addArgs({"-E", "--list-macros"});
const SynchronousProcessResponse response = cpp.runBlocking(cmd); const SynchronousProcessResponse response = cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished if (response.result != SynchronousProcessResponse::Finished

View File

@@ -92,8 +92,7 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const QStringList &
cpp.setEnvironment(env); cpp.setEnvironment(env);
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
CommandLine cmd(compiler, {}); const CommandLine cmd(compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()});
cmd.addArgs({compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()});
const SynchronousProcessResponse response = cpp.runBlocking(cmd); const SynchronousProcessResponse response = cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished if (response.result != SynchronousProcessResponse::Finished
@@ -116,8 +115,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const QStringList &
cpp.setEnvironment(env); cpp.setEnvironment(env);
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
CommandLine cmd(compiler, {}); const CommandLine cmd(compiler, {compilerTargetFlag(abi), "--print-search-dirs"});
cmd.addArgs({compilerTargetFlag(abi), "--print-search-dirs"});
const SynchronousProcessResponse response = cpp.runBlocking(cmd); const SynchronousProcessResponse response = cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished if (response.result != SynchronousProcessResponse::Finished

View File

@@ -121,9 +121,9 @@ QString AbstractSettings::styleFileName(const QString &key) const
return m_styleDir.absoluteFilePath(key + m_ending); return m_styleDir.absoluteFilePath(key + m_ending);
} }
QString AbstractSettings::command() const Utils::FilePath AbstractSettings::command() const
{ {
return m_command; return Utils::FilePath::fromString(m_command);
} }
void AbstractSettings::setCommand(const QString &command) void AbstractSettings::setCommand(const QString &command)

View File

@@ -36,6 +36,7 @@
#include <QVector> #include <QVector>
namespace Core { class IDocument; } namespace Core { class IDocument; }
namespace Utils { class FilePath; }
namespace Beautifier { namespace Beautifier {
namespace Internal { namespace Internal {
@@ -64,7 +65,7 @@ public:
void replaceStyle(const QString &oldKey, const QString &newKey, const QString &value); void replaceStyle(const QString &oldKey, const QString &newKey, const QString &value);
virtual QString styleFileName(const QString &key) const; virtual QString styleFileName(const QString &key) const;
QString command() const; Utils::FilePath command() const;
void setCommand(const QString &command); void setCommand(const QString &command);
int version() const; int version() const;
virtual void updateVersion(); virtual void updateVersion();

View File

@@ -147,7 +147,7 @@ bool ArtisticStyle::isApplicable(const Core::IDocument *document) const
Command ArtisticStyle::command(const QString &cfgFile) const Command ArtisticStyle::command(const QString &cfgFile) const
{ {
Command command; Command command;
command.setExecutable(m_settings.command()); command.setExecutable(m_settings.command().toString());
command.addOption("-q"); command.addOption("-q");
command.addOption("--options=" + cfgFile); command.addOption("--options=" + cfgFile);

View File

@@ -65,7 +65,7 @@ ArtisticStyleOptionsPageWidget::~ArtisticStyleOptionsPageWidget()
void ArtisticStyleOptionsPageWidget::restore() void ArtisticStyleOptionsPageWidget::restore()
{ {
ui->command->setPath(m_settings->command()); ui->command->setFileName(m_settings->command());
ui->mime->setText(m_settings->supportedMimeTypesAsString()); ui->mime->setText(m_settings->supportedMimeTypesAsString());
ui->useOtherFiles->setChecked(m_settings->useOtherFiles()); ui->useOtherFiles->setChecked(m_settings->useOtherFiles());
ui->useSpecificConfigFile->setChecked(m_settings->useSpecificConfigFile()); ui->useSpecificConfigFile->setChecked(m_settings->useSpecificConfigFile());

View File

@@ -82,11 +82,10 @@ static int parseVersion(const QString &text)
return 0; return 0;
} }
static int updateVersionHelper(const QString &command) static int updateVersionHelper(const Utils::FilePath &command)
{ {
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
Utils::SynchronousProcessResponse response Utils::SynchronousProcessResponse response = process.runBlocking({command, {"--version"}});
= process.runBlocking(command, QStringList("--version"));
if (response.result != Utils::SynchronousProcessResponse::Finished) if (response.result != Utils::SynchronousProcessResponse::Finished)
return 0; return 0;
@@ -182,8 +181,7 @@ void ArtisticStyleSettings::createDocumentationFile() const
{ {
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
process.setTimeoutS(2); process.setTimeoutS(2);
Utils::SynchronousProcessResponse response Utils::SynchronousProcessResponse response = process.runBlocking({command(), {"-h"}});
= process.runBlocking(command(), QStringList("-h"));
if (response.result != Utils::SynchronousProcessResponse::Finished) if (response.result != Utils::SynchronousProcessResponse::Finished)
return; return;

View File

@@ -167,7 +167,7 @@ void ClangFormat::disableFormattingSelectedText()
Command ClangFormat::command() const Command ClangFormat::command() const
{ {
Command command; Command command;
command.setExecutable(m_settings.command()); command.setExecutable(m_settings.command().toString());
command.setProcessing(Command::PipeProcessing); command.setProcessing(Command::PipeProcessing);
if (m_settings.usePredefinedStyle()) { if (m_settings.usePredefinedStyle()) {

View File

@@ -70,7 +70,7 @@ ClangFormatOptionsPageWidget::~ClangFormatOptionsPageWidget()
void ClangFormatOptionsPageWidget::restore() void ClangFormatOptionsPageWidget::restore()
{ {
ui->command->setPath(m_settings->command()); ui->command->setFileName(m_settings->command());
ui->mime->setText(m_settings->supportedMimeTypesAsString()); ui->mime->setText(m_settings->supportedMimeTypesAsString());
const int predefinedStyleIndex = ui->predefinedStyle->findText(m_settings->predefinedStyle()); const int predefinedStyleIndex = ui->predefinedStyle->findText(m_settings->predefinedStyle());
if (predefinedStyleIndex != -1) if (predefinedStyleIndex != -1)

View File

@@ -184,7 +184,7 @@ bool Uncrustify::isApplicable(const Core::IDocument *document) const
Command Uncrustify::command(const QString &cfgFile, bool fragment) const Command Uncrustify::command(const QString &cfgFile, bool fragment) const
{ {
Command command; Command command;
command.setExecutable(m_settings.command()); command.setExecutable(m_settings.command().toString());
command.setProcessing(Command::PipeProcessing); command.setProcessing(Command::PipeProcessing);
if (m_settings.version() >= 62) { if (m_settings.version() >= 62) {
command.addOption("--assume"); command.addOption("--assume");

View File

@@ -68,7 +68,7 @@ UncrustifyOptionsPageWidget::~UncrustifyOptionsPageWidget()
void UncrustifyOptionsPageWidget::restore() void UncrustifyOptionsPageWidget::restore()
{ {
ui->command->setPath(m_settings->command()); ui->command->setFileName(m_settings->command());
ui->mime->setText(m_settings->supportedMimeTypesAsString()); ui->mime->setText(m_settings->supportedMimeTypesAsString());
ui->useOtherFiles->setChecked(m_settings->useOtherFiles()); ui->useOtherFiles->setChecked(m_settings->useOtherFiles());
ui->useHomeFile->setChecked(m_settings->useHomeFile()); ui->useHomeFile->setChecked(m_settings->useHomeFile());

View File

@@ -152,7 +152,7 @@ void UncrustifySettings::createDocumentationFile() const
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
process.setTimeoutS(2); process.setTimeoutS(2);
Utils::SynchronousProcessResponse response Utils::SynchronousProcessResponse response
= process.runBlocking(command(), QStringList("--show-config")); = process.runBlocking(Utils::CommandLine(command(), {"--show-config"}));
if (response.result != Utils::SynchronousProcessResponse::Finished) if (response.result != Utils::SynchronousProcessResponse::Finished)
return; return;
@@ -230,7 +230,7 @@ void UncrustifySettings::updateVersion()
m_versionProcess.kill(); m_versionProcess.kill();
m_versionProcess.waitForFinished(); m_versionProcess.waitForFinished();
} }
m_versionProcess.start(command(), {"--version"}); m_versionProcess.start(command().toString(), {"--version"});
} }
void UncrustifySettings::parseVersionProcessResult(int exitCode, QProcess::ExitStatus exitStatus) void UncrustifySettings::parseVersionProcessResult(int exitCode, QProcess::ExitStatus exitStatus)

View File

@@ -2140,15 +2140,15 @@ void ClearCasePlugin::diffGraphical(const QString &file1, const QString &file2)
QString ClearCasePlugin::runExtDiff(const QString &workingDir, const QStringList &arguments, QString ClearCasePlugin::runExtDiff(const QString &workingDir, const QStringList &arguments,
int timeOutS, QTextCodec *outputCodec) int timeOutS, QTextCodec *outputCodec)
{ {
const QString executable(QLatin1String("diff")); CommandLine diff(FilePath::fromString("diff"));
QStringList args(m_settings.diffArgs.split(QLatin1Char(' '), QString::SkipEmptyParts)); diff.addArgs(m_settings.diffArgs.split(' ', QString::SkipEmptyParts));
args << arguments; diff.addArgs(arguments);
SynchronousProcess process; SynchronousProcess process;
process.setTimeoutS(timeOutS); process.setTimeoutS(timeOutS);
process.setWorkingDirectory(workingDir); process.setWorkingDirectory(workingDir);
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8")); process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));
SynchronousProcessResponse response = process.run(executable, args); SynchronousProcessResponse response = process.run(diff);
if (response.result != SynchronousProcessResponse::Finished) if (response.result != SynchronousProcessResponse::Finished)
return QString(); return QString();
return response.allOutput(); return response.allOutput();

View File

@@ -169,7 +169,7 @@ Utils::SynchronousProcessResponse CMakeTool::run(const QStringList &args, bool m
cmake.setProcessEnvironment(env.toProcessEnvironment()); cmake.setProcessEnvironment(env.toProcessEnvironment());
cmake.setTimeOutMessageBoxEnabled(false); cmake.setTimeOutMessageBoxEnabled(false);
Utils::SynchronousProcessResponse response = cmake.runBlocking(m_executable.toString(), args); Utils::SynchronousProcessResponse response = cmake.runBlocking({m_executable, args});
m_introspection->m_didAttemptToRun = true; m_introspection->m_didAttemptToRun = true;
m_introspection->m_didRun = mayFail ? true : (response.result == Utils::SynchronousProcessResponse::Finished); m_introspection->m_didRun = mayFail ? true : (response.result == Utils::SynchronousProcessResponse::Finished);
return response; return response;

View File

@@ -64,12 +64,12 @@ const char DEBUGGER_INFORMATION_WORKINGDIRECTORY[] = "WorkingDirectory";
//! Return the configuration of gdb as a list of --key=value //! Return the configuration of gdb as a list of --key=value
//! \note That the list will also contain some output not in this format. //! \note That the list will also contain some output not in this format.
static QString getConfigurationOfGdbCommand(const QString &command) static QString getConfigurationOfGdbCommand(const FilePath &command)
{ {
// run gdb with the --configuration opion // run gdb with the --configuration opion
Utils::SynchronousProcess gdbConfigurationCall; Utils::SynchronousProcess gdbConfigurationCall;
Utils::SynchronousProcessResponse output = Utils::SynchronousProcessResponse output =
gdbConfigurationCall.runBlocking(command, {QString("--configuration")}); gdbConfigurationCall.runBlocking({command, {"--configuration"}});
return output.allOutput(); return output.allOutput();
} }
@@ -142,15 +142,14 @@ void DebuggerItem::reinitializeFromFile()
// CDB only understands the single-dash -version, whereas GDB and LLDB are // CDB only understands the single-dash -version, whereas GDB and LLDB are
// happy with both -version and --version. So use the "working" -version // happy with both -version and --version. So use the "working" -version
// except for the experimental LLDB-MI which insists on --version. // except for the experimental LLDB-MI which insists on --version.
const char *version = "-version"; QString version = "-version";
const QFileInfo fileInfo = m_command.toFileInfo(); const QFileInfo fileInfo = m_command.toFileInfo();
m_lastModified = fileInfo.lastModified(); m_lastModified = fileInfo.lastModified();
if (fileInfo.baseName().toLower().contains("lldb-mi")) if (fileInfo.baseName().toLower().contains("lldb-mi"))
version = "--version"; version = "--version";
SynchronousProcess proc; SynchronousProcess proc;
SynchronousProcessResponse response SynchronousProcessResponse response = proc.runBlocking({m_command, {version}});
= proc.runBlocking(m_command.toString(), {QLatin1String(version)});
if (response.result != SynchronousProcessResponse::Finished) { if (response.result != SynchronousProcessResponse::Finished) {
m_engineType = NoEngineType; m_engineType = NoEngineType;
return; return;
@@ -173,7 +172,7 @@ void DebuggerItem::reinitializeFromFile()
const bool unableToFindAVersion = (0 == version); const bool unableToFindAVersion = (0 == version);
const bool gdbSupportsConfigurationFlag = (version >= 70700); const bool gdbSupportsConfigurationFlag = (version >= 70700);
if (gdbSupportsConfigurationFlag || unableToFindAVersion) { if (gdbSupportsConfigurationFlag || unableToFindAVersion) {
const auto gdbConfiguration = getConfigurationOfGdbCommand(m_command.toString()); const auto gdbConfiguration = getConfigurationOfGdbCommand(m_command);
const auto gdbTargetAbiString = const auto gdbTargetAbiString =
extractGdbTargetAbiStringFromGdbOutput(gdbConfiguration); extractGdbTargetAbiStringFromGdbOutput(gdbConfiguration);
if (!gdbTargetAbiString.isEmpty()) { if (!gdbTargetAbiString.isEmpty()) {

View File

@@ -727,7 +727,7 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
SynchronousProcess lldbInfo; SynchronousProcess lldbInfo;
lldbInfo.setTimeoutS(2); lldbInfo.setTimeoutS(2);
SynchronousProcessResponse response SynchronousProcessResponse response
= lldbInfo.runBlocking("xcrun", {"--find", "lldb"}); = lldbInfo.runBlocking(CommandLine(FilePath::fromString("xcrun"), {"--find", "lldb"}));
if (response.result == Utils::SynchronousProcessResponse::Finished) { if (response.result == Utils::SynchronousProcessResponse::Finished) {
QString lPath = response.allOutput().trimmed(); QString lPath = response.allOutput().trimmed();
if (!lPath.isEmpty()) { if (!lPath.isEmpty()) {

View File

@@ -4679,7 +4679,8 @@ CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const QS
QStringList envLang = QProcess::systemEnvironment(); QStringList envLang = QProcess::systemEnvironment();
Utils::Environment::setupEnglishOutput(&envLang); Utils::Environment::setupEnglishOutput(&envLang);
proc.setEnvironment(envLang); proc.setEnvironment(envLang);
SynchronousProcessResponse response = proc.runBlocking(debugger.executable, args); SynchronousProcessResponse response
= proc.runBlocking({FilePath::fromString(debugger.executable), args});
if (response.result == SynchronousProcessResponse::Finished) { if (response.result == SynchronousProcessResponse::Finished) {
QString output = response.stdOut(); QString output = response.stdOut();

View File

@@ -233,7 +233,7 @@ static QByteArray decodeProvisioningProfile(const QString &path)
p.setTimeoutS(3); p.setTimeoutS(3);
// path is assumed to be valid file path to .mobileprovision // path is assumed to be valid file path to .mobileprovision
const QStringList args = {"smime", "-inform", "der", "-verify", "-in", path}; const QStringList args = {"smime", "-inform", "der", "-verify", "-in", path};
Utils::SynchronousProcessResponse res = p.runBlocking("openssl", args); Utils::SynchronousProcessResponse res = p.runBlocking({FilePath::fromString("openssl"), args});
if (res.result != Utils::SynchronousProcessResponse::Finished) if (res.result != Utils::SynchronousProcessResponse::Finished)
qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path; qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path;
return res.stdOut().toLatin1(); return res.stdOut().toLatin1();

View File

@@ -35,6 +35,8 @@
static Q_LOGGING_CATEGORY(probeLog, "qtc.ios.probe", QtWarningMsg) static Q_LOGGING_CATEGORY(probeLog, "qtc.ios.probe", QtWarningMsg)
using namespace Utils;
namespace Ios { namespace Ios {
static QString defaultDeveloperPath = QLatin1String("/Applications/Xcode.app/Contents/Developer"); static QString defaultDeveloperPath = QLatin1String("/Applications/Xcode.app/Contents/Developer");
@@ -64,8 +66,8 @@ void XcodeProbe::detectDeveloperPaths()
{ {
Utils::SynchronousProcess selectedXcode; Utils::SynchronousProcess selectedXcode;
selectedXcode.setTimeoutS(5); selectedXcode.setTimeoutS(5);
Utils::SynchronousProcessResponse response = selectedXcode.run( const CommandLine xcodeSelect{FilePath::fromString("/usr/bin/xcode-select"), {"--print-path"}};
QLatin1String("/usr/bin/xcode-select"), QStringList("--print-path")); Utils::SynchronousProcessResponse response = selectedXcode.run(xcodeSelect);
if (response.result != Utils::SynchronousProcessResponse::Finished) if (response.result != Utils::SynchronousProcessResponse::Finished)
qCWarning(probeLog) qCWarning(probeLog)
<< QString::fromLatin1("Could not detect selected Xcode using xcode-select"); << QString::fromLatin1("Could not detect selected Xcode using xcode-select");

View File

@@ -44,6 +44,7 @@
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QProcess> #include <QProcess>
using namespace Utils;
using namespace std; using namespace std;
namespace { namespace {
@@ -77,20 +78,20 @@ static bool checkForTimeout(const chrono::high_resolution_clock::time_point &sta
return timedOut; return timedOut;
} }
static bool runCommand(QString command, const QStringList &args, QString *output) static bool runCommand(const CommandLine &command, QString *output)
{ {
Utils::SynchronousProcess p; SynchronousProcess p;
p.setTimeoutS(-1); p.setTimeoutS(-1);
Utils::SynchronousProcessResponse resp = p.runBlocking(command, args); SynchronousProcessResponse resp = p.runBlocking(command);
if (output) if (output)
*output = resp.stdOut(); *output = resp.stdOut();
return resp.result == Utils::SynchronousProcessResponse::Finished; return resp.result == SynchronousProcessResponse::Finished;
} }
static bool runSimCtlCommand(QStringList args, QString *output) static bool runSimCtlCommand(QStringList args, QString *output)
{ {
args.prepend("simctl"); args.prepend("simctl");
return runCommand("xcrun", args, output); return runCommand({FilePath::fromString("xcrun"), args}, output);
} }
static bool launchSimulator(const QString &simUdid) { static bool launchSimulator(const QString &simUdid) {
@@ -101,10 +102,10 @@ static bool launchSimulator(const QString &simUdid) {
if (IosConfigurations::xcodeVersion() >= QVersionNumber(9)) { if (IosConfigurations::xcodeVersion() >= QVersionNumber(9)) {
// For XCode 9 boot the second device instead of launching simulator app twice. // For XCode 9 boot the second device instead of launching simulator app twice.
QString psOutput; QString psOutput;
if (runCommand("ps", {"-A", "-o", "comm"}, &psOutput)) { if (runCommand({FilePath::fromString("ps"), {"-A", "-o", "comm"}}, &psOutput)) {
for (const QString &comm : psOutput.split('\n')) { for (const QString &comm : psOutput.split('\n')) {
if (comm == simulatorAppPath) if (comm == simulatorAppPath)
return runSimCtlCommand(QStringList({"boot", simUdid}), nullptr); return runSimCtlCommand({"boot", simUdid}, nullptr);
} }
} else { } else {
qCDebug(simulatorLog) << "Cannot start Simulator device." qCDebug(simulatorLog) << "Cannot start Simulator device."

View File

@@ -996,7 +996,8 @@ PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir,
} }
} }
process.setTimeOutMessageBoxEnabled(true); process.setTimeOutMessageBoxEnabled(true);
const SynchronousProcessResponse sp_resp = process.run(settings().p4BinaryPath(), args); const SynchronousProcessResponse sp_resp = process.run(
CommandLine{FilePath::fromString(settings().p4BinaryPath()), args});
PerforceResponse response; PerforceResponse response;
response.error = true; response.error = true;

View File

@@ -27,6 +27,7 @@
#include "customwizard.h" #include "customwizard.h"
#include "customwizardparameters.h" #include "customwizardparameters.h"
#include <utils/fileutils.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#include <utils/temporarydirectory.h> #include <utils/temporarydirectory.h>
@@ -107,11 +108,11 @@ static bool
} }
process.setWorkingDirectory(workingDirectory); process.setWorkingDirectory(workingDirectory);
process.setTimeoutS(30); process.setTimeoutS(30);
const Utils::CommandLine cmd(Utils::FilePath::fromString(binary), arguments);
if (CustomWizard::verbose()) if (CustomWizard::verbose())
qDebug("In %s, running:\n%s\n%s\n", qPrintable(workingDirectory), qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory),
qPrintable(binary), qPrintable(cmd.toUserOutput()));
qPrintable(arguments.join(QLatin1Char(' ')))); Utils::SynchronousProcessResponse response = process.run(cmd);
Utils::SynchronousProcessResponse response = process.run(binary, arguments);
if (response.result != Utils::SynchronousProcessResponse::Finished) { if (response.result != Utils::SynchronousProcessResponse::Finished) {
*errorMessage = QString::fromLatin1("Generator script failed: %1") *errorMessage = QString::fromLatin1("Generator script failed: %1")
.arg(response.exitMessage(binary, 30)); .arg(response.exitMessage(binary, 30));

View File

@@ -88,7 +88,7 @@ static QByteArray runGcc(const FilePath &gcc, const QStringList &arguments, cons
cpp.setEnvironment(environment); cpp.setEnvironment(environment);
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
SynchronousProcessResponse response = cpp.runBlocking(gcc.toString(), arguments); SynchronousProcessResponse response = cpp.runBlocking(CommandLine(gcc, arguments));
if (response.result != SynchronousProcessResponse::Finished || if (response.result != SynchronousProcessResponse::Finished ||
response.exitCode != 0) { response.exitCode != 0) {
qWarning() << response.exitMessage(gcc.toString(), 10); qWarning() << response.exitMessage(gcc.toString(), 10);

View File

@@ -239,9 +239,9 @@ static QVector<VisualStudioInstallation> detectVisualStudioFromVsWhere(const QSt
Utils::SynchronousProcess vsWhereProcess; Utils::SynchronousProcess vsWhereProcess;
const int timeoutS = 5; const int timeoutS = 5;
vsWhereProcess.setTimeoutS(timeoutS); vsWhereProcess.setTimeoutS(timeoutS);
const QStringList const CommandLine cmd(FilePath::fromString(vswhere),
arguments{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"}; {"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"});
Utils::SynchronousProcessResponse response = vsWhereProcess.runBlocking(vswhere, arguments); Utils::SynchronousProcessResponse response = vsWhereProcess.runBlocking(cmd);
switch (response.result) { switch (response.result) {
case Utils::SynchronousProcessResponse::Finished: case Utils::SynchronousProcessResponse::Finished:
break; break;
@@ -622,7 +622,7 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID) if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
arguments << QLatin1String("/TC"); arguments << QLatin1String("/TC");
arguments << toProcess << QLatin1String("/EP") << QDir::toNativeSeparators(saver.fileName()); arguments << toProcess << QLatin1String("/EP") << QDir::toNativeSeparators(saver.fileName());
Utils::SynchronousProcessResponse response = cpp.runBlocking(binary.toString(), arguments); SynchronousProcessResponse response = cpp.runBlocking({binary, arguments});
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0)
return predefinedMacros; return predefinedMacros;
@@ -1540,10 +1540,10 @@ static const MsvcToolChain *findMsvcToolChain(const QString &displayedVarsBat)
static QVersionNumber clangClVersion(const QString &clangClPath) static QVersionNumber clangClVersion(const QString &clangClPath)
{ {
Utils::SynchronousProcess clangClProcess; SynchronousProcess clangClProcess;
const Utils::SynchronousProcessResponse response const SynchronousProcessResponse response
= clangClProcess.runBlocking(clangClPath, {QStringLiteral("--version")}); = clangClProcess.runBlocking({FilePath::fromString(clangClPath), {"--version"}});
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0)
return {}; return {};
const QRegularExpressionMatch match = QRegularExpression( const QRegularExpressionMatch match = QRegularExpression(
QStringLiteral("clang version (\\d+(\\.\\d+)+)")) QStringLiteral("clang version (\\d+(\\.\\d+)+)"))
@@ -1779,8 +1779,7 @@ Macros ClangClToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
QStringList arguments = cxxflags; QStringList arguments = cxxflags;
arguments.append(gccPredefinedMacrosOptions(language())); arguments.append(gccPredefinedMacrosOptions(language()));
arguments.append("-"); arguments.append("-");
Utils::SynchronousProcessResponse response = cpp.runBlocking(compilerCommand().toString(), Utils::SynchronousProcessResponse response = cpp.runBlocking({compilerCommand(), arguments});
arguments);
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) { if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) {
// Show the warning but still parse the output. // Show the warning but still parse the output.
QTC_CHECK(false && "clang-cl exited with non-zero code."); QTC_CHECK(false && "clang-cl exited with non-zero code.");
@@ -2109,13 +2108,12 @@ Utils::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils:
if (cmdPath.isEmpty()) if (cmdPath.isEmpty())
cmdPath = env.searchInPath(QLatin1String("cmd.exe")); cmdPath = env.searchInPath(QLatin1String("cmd.exe"));
// Windows SDK setup scripts require command line switches for environment expansion. // Windows SDK setup scripts require command line switches for environment expansion.
QStringList cmdArguments({QLatin1String("/E:ON"), QLatin1String("/V:ON"), QLatin1String("/c")}); CommandLine cmd(cmdPath, {"/E:ON", "/V:ON", "/c", QDir::toNativeSeparators(saver.fileName())});
cmdArguments << QDir::toNativeSeparators(saver.fileName());
if (debug) if (debug)
qDebug() << "readEnvironmentSetting: " << call << cmdPath << cmdArguments.join(' ') qDebug() << "readEnvironmentSetting: " << call << cmd.toUserOutput()
<< " Env: " << runEnv.size(); << " Env: " << runEnv.size();
run.setCodec(QTextCodec::codecForName("UTF-8")); run.setCodec(QTextCodec::codecForName("UTF-8"));
Utils::SynchronousProcessResponse response = run.runBlocking(cmdPath.toString(), cmdArguments); Utils::SynchronousProcessResponse response = run.runBlocking(cmd);
if (response.result != Utils::SynchronousProcessResponse::Finished) { if (response.result != Utils::SynchronousProcessResponse::Finished) {
const QString message = !response.stdErr().isEmpty() const QString message = !response.stdErr().isEmpty()

View File

@@ -90,7 +90,8 @@ static FormatTask format(FormatTask task)
options.replaceInStrings(QLatin1String("%file"), sourceFile.fileName()); options.replaceInStrings(QLatin1String("%file"), sourceFile.fileName());
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
process.setTimeoutS(5); process.setTimeoutS(5);
Utils::SynchronousProcessResponse response = process.runBlocking(executable, options); const CommandLine cmd(FilePath::fromString(executable), {options});
Utils::SynchronousProcessResponse response = process.runBlocking(cmd);
if (response.result != Utils::SynchronousProcessResponse::Finished) { if (response.result != Utils::SynchronousProcessResponse::Finished) {
task.error = QString(QT_TRANSLATE_NOOP("TextEditor", "Failed to format: %1.")) task.error = QString(QT_TRANSLATE_NOOP("TextEditor", "Failed to format: %1."))
.arg(response.exitMessage(executable, 5)); .arg(response.exitMessage(executable, 5));

View File

@@ -28,6 +28,8 @@
#include "texteditorconstants.h" #include "texteditorconstants.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
@@ -67,12 +69,12 @@ QString findFallbackDefinitionsLocation()
} }
// Try kde-config. // Try kde-config.
const QStringList programs = {QLatin1String("kde-config"), QLatin1String("kde4-config")}; const QStringList programs = {"kde-config", "kde4-config"};
for (auto &program : programs) { for (auto &program : programs) {
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
process.setTimeoutS(5); process.setTimeoutS(5);
Utils::SynchronousProcessResponse response Utils::SynchronousProcessResponse response
= process.runBlocking(program, QStringList(QLatin1String("--prefix"))); = process.runBlocking({Utils::FilePath::fromString(program), {"--prefix"}});
if (response.result == Utils::SynchronousProcessResponse::Finished) { if (response.result == Utils::SynchronousProcessResponse::Finished) {
QString output = response.stdOut(); QString output = response.stdOut();
output.remove(QLatin1Char('\n')); output.remove(QLatin1Char('\n'));

View File

@@ -25,6 +25,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <utils/fileutils.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#include <QPlainTextEdit> #include <QPlainTextEdit>
@@ -56,6 +57,6 @@ void MainWindow::test()
qDebug() << "Async: " << cmd << args; qDebug() << "Async: " << cmd << args;
connect(&process, &Utils::SynchronousProcess::stdOutBuffered, this, &MainWindow::append); connect(&process, &Utils::SynchronousProcess::stdOutBuffered, this, &MainWindow::append);
connect(&process, &Utils::SynchronousProcess::stdErrBuffered, this, &MainWindow::append); connect(&process, &Utils::SynchronousProcess::stdErrBuffered, this, &MainWindow::append);
const Utils::SynchronousProcessResponse resp = process.run(cmd, args); const Utils::SynchronousProcessResponse resp = process.run({Utils::FilePath::fromString(cmd), args});
qDebug() << resp; qDebug() << resp;
} }