forked from qt-creator/qt-creator
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:
@@ -49,6 +49,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/benchmarker.h>
|
||||
#include <utils/executeondestruction.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -413,10 +414,10 @@ static QString filled(const QString &s, int min)
|
||||
QString PluginManager::systemInformation() const
|
||||
{
|
||||
QString result;
|
||||
const QString qtdiagBinary = HostOsInfo::withExecutableSuffix(
|
||||
QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qtdiag");
|
||||
CommandLine qtDiag(FilePath::fromString(HostOsInfo::withExecutableSuffix(
|
||||
QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qtdiag")));
|
||||
SynchronousProcess qtdiagProc;
|
||||
const SynchronousProcessResponse response = qtdiagProc.runBlocking(qtdiagBinary, QStringList());
|
||||
const SynchronousProcessResponse response = qtdiagProc.runBlocking(qtDiag);
|
||||
if (response.result == SynchronousProcessResponse::Finished)
|
||||
result += response.allOutput() + "\n";
|
||||
result += "Plugin information:\n\n";
|
||||
|
@@ -46,7 +46,7 @@ QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
|
||||
const QString toolDir = QLatin1String("QTTOOLDIR=\"");
|
||||
SynchronousProcess proc;
|
||||
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)
|
||||
return QString();
|
||||
const QString output = response.stdOut();
|
||||
@@ -130,7 +130,7 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath)
|
||||
|
||||
SynchronousProcess qmake;
|
||||
qmake.setTimeoutS(5);
|
||||
SynchronousProcessResponse response = qmake.runBlocking(qmakePath, QStringList(QLatin1String("--version")));
|
||||
SynchronousProcessResponse response = qmake.runBlocking({FilePath::fromString(qmakePath), {"--version"}});
|
||||
if (response.result != SynchronousProcessResponse::Finished) {
|
||||
qWarning() << response.exitMessage(qmakePath, 5);
|
||||
return QString();
|
||||
|
@@ -84,7 +84,7 @@ public:
|
||||
QStringList arguments() const { return m_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:
|
||||
// Extension point for concatenating existing tooltips.
|
||||
@@ -108,7 +108,8 @@ bool BinaryVersionToolTipEventFilter::eventFilter(QObject *o, QEvent *e)
|
||||
|
||||
const QString binary = le->text();
|
||||
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()) {
|
||||
// Concatenate tooltips.
|
||||
QString tooltip = "<html><head/><body>";
|
||||
@@ -127,13 +128,13 @@ bool BinaryVersionToolTipEventFilter::eventFilter(QObject *o, QEvent *e)
|
||||
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();
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(1);
|
||||
SynchronousProcessResponse response = proc.runBlocking(binary, arguments);
|
||||
SynchronousProcessResponse response = proc.runBlocking(cmd);
|
||||
if (response.result != SynchronousProcessResponse::Finished)
|
||||
return QString();
|
||||
return response.allOutput();
|
||||
@@ -677,7 +678,7 @@ FancyLineEdit *PathChooser::lineEdit() const
|
||||
|
||||
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)
|
||||
|
@@ -341,9 +341,9 @@ SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary,
|
||||
if ((d->m_flags & FullySynchronously)
|
||||
|| (!(d->m_flags & NoFullySync)
|
||||
&& QThread::currentThread() == QCoreApplication::instance()->thread())) {
|
||||
response = runFullySynchronous(binary, arguments, proxy, timeoutS, dir, interpreter);
|
||||
response = runFullySynchronous({binary, arguments}, proxy, timeoutS, dir, interpreter);
|
||||
} else {
|
||||
response = runSynchronous(binary, arguments, proxy, timeoutS, dir, interpreter);
|
||||
response = runSynchronous({binary, arguments}, proxy, timeoutS, dir, interpreter);
|
||||
}
|
||||
|
||||
if (!d->m_aborted) {
|
||||
@@ -359,8 +359,7 @@ SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary,
|
||||
return response;
|
||||
}
|
||||
|
||||
SynchronousProcessResponse ShellCommand::runFullySynchronous(const FilePath &binary,
|
||||
const QStringList &arguments,
|
||||
SynchronousProcessResponse ShellCommand::runFullySynchronous(const CommandLine &cmd,
|
||||
QSharedPointer<OutputProxy> proxy,
|
||||
int timeoutS,
|
||||
const QString &workingDirectory,
|
||||
@@ -380,7 +379,7 @@ SynchronousProcessResponse ShellCommand::runFullySynchronous(const FilePath &bin
|
||||
process.setTimeoutS(timeoutS);
|
||||
process.setExitCodeInterpreter(interpreter);
|
||||
|
||||
SynchronousProcessResponse resp = process.runBlocking(binary.toString(), arguments);
|
||||
SynchronousProcessResponse resp = process.runBlocking(cmd);
|
||||
|
||||
if (!d->m_aborted) {
|
||||
const QString stdErr = resp.stdErr();
|
||||
@@ -399,8 +398,7 @@ SynchronousProcessResponse ShellCommand::runFullySynchronous(const FilePath &bin
|
||||
return resp;
|
||||
}
|
||||
|
||||
SynchronousProcessResponse ShellCommand::runSynchronous(const FilePath &binary,
|
||||
const QStringList &arguments,
|
||||
SynchronousProcessResponse ShellCommand::runSynchronous(const CommandLine &cmd,
|
||||
QSharedPointer<OutputProxy> proxy,
|
||||
int timeoutS,
|
||||
const QString &workingDirectory,
|
||||
@@ -460,7 +458,7 @@ SynchronousProcessResponse ShellCommand::runSynchronous(const FilePath &binary,
|
||||
process.setTimeoutS(timeoutS);
|
||||
process.setExitCodeInterpreter(interpreter);
|
||||
|
||||
return process.run(binary.toString(), arguments);
|
||||
return process.run(cmd);
|
||||
}
|
||||
|
||||
const QVariant &ShellCommand::cookie() const
|
||||
|
@@ -171,12 +171,12 @@ private:
|
||||
void run(QFutureInterface<void> &future);
|
||||
|
||||
// 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,
|
||||
int timeoutS, const QString &workingDirectory,
|
||||
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
||||
// 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,
|
||||
int timeoutS, const QString &workingDirectory,
|
||||
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
||||
|
@@ -442,15 +442,6 @@ static bool isGuiThread()
|
||||
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,
|
||||
const QByteArray &writeData)
|
||||
{
|
||||
@@ -506,14 +497,6 @@ SynchronousProcessResponse SynchronousProcess::run(const CommandLine &cmd,
|
||||
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)
|
||||
{
|
||||
d->clearForRun();
|
||||
|
@@ -127,14 +127,8 @@ public:
|
||||
void setExitCodeInterpreter(const ExitCodeInterpreter &interpreter);
|
||||
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
|
||||
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
|
||||
SynchronousProcessResponse runBlocking(const CommandLine &cmd);
|
||||
|
||||
|
@@ -41,6 +41,8 @@
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace {
|
||||
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)
|
||||
{
|
||||
QString avdManagerToolPath = config.avdManagerToolPath().toString();
|
||||
CommandLine cmd(config.avdManagerToolPath(), args);
|
||||
Utils::SynchronousProcess proc;
|
||||
auto env = AndroidConfigurations::toolsEnvironment(config).toStringList();
|
||||
proc.setEnvironment(env);
|
||||
Utils::SynchronousProcessResponse response = proc.runBlocking(avdManagerToolPath, args);
|
||||
SynchronousProcessResponse response = proc.runBlocking(cmd);
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished) {
|
||||
if (output)
|
||||
*output = response.allOutput();
|
||||
@@ -258,8 +260,7 @@ bool AndroidAvdManager::removeAvd(const QString &name) const
|
||||
Utils::SynchronousProcess proc;
|
||||
proc.setTimeoutS(5);
|
||||
Utils::SynchronousProcessResponse response
|
||||
= proc.runBlocking(m_config.avdManagerToolPath().toString(),
|
||||
QStringList({"delete", "avd", "-n", name}));
|
||||
= proc.runBlocking({m_config.avdManagerToolPath(), {"delete", "avd", "-n", name}});
|
||||
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);
|
||||
arguments << "shell" << "getprop" << "init.svc.bootanim";
|
||||
|
||||
Utils::SynchronousProcess adbProc;
|
||||
SynchronousProcess adbProc;
|
||||
adbProc.setTimeoutS(10);
|
||||
Utils::SynchronousProcessResponse response =
|
||||
adbProc.runBlocking(m_config.adbToolPath().toString(), arguments);
|
||||
SynchronousProcessResponse response = adbProc.runBlocking({m_config.adbToolPath(), arguments});
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished)
|
||||
return false;
|
||||
QString value = response.allOutput().trimmed();
|
||||
@@ -376,7 +376,7 @@ bool AndroidAvdManager::waitForBooted(const QString &serialNumber,
|
||||
AndroidDeviceInfoList AvdManagerOutputParser::listVirtualDevices(const AndroidConfig &config)
|
||||
{
|
||||
QString output;
|
||||
if (!avdManagerCommand(config, QStringList({"list", "avd"}), &output)) {
|
||||
if (!avdManagerCommand(config, {"list", "avd"}, &output)) {
|
||||
qCDebug(avdManagerLog) << "Avd list command failed" << output << config.sdkToolsVersion();
|
||||
return {};
|
||||
}
|
||||
|
@@ -577,8 +577,8 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
|
||||
|
||||
Utils::SynchronousProcess keytoolProc;
|
||||
keytoolProc.setTimeoutS(30);
|
||||
const Utils::SynchronousProcessResponse response
|
||||
= keytoolProc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), params);
|
||||
const SynchronousProcessResponse response
|
||||
= keytoolProc.run({AndroidConfigurations::currentConfig().keytoolPath(), params});
|
||||
if (response.result > Utils::SynchronousProcessResponse::FinishedError)
|
||||
QMessageBox::critical(nullptr, tr("Error"), tr("Failed to run keytool."));
|
||||
else
|
||||
|
@@ -140,7 +140,8 @@ namespace {
|
||||
SynchronousProcess proc;
|
||||
proc.setProcessChannelMode(QProcess::MergedChannels);
|
||||
proc.setTimeoutS(30);
|
||||
SynchronousProcessResponse response = proc.runBlocking(executable, QStringList(shell));
|
||||
SynchronousProcessResponse response
|
||||
= proc.runBlocking({FilePath::fromString(executable), {shell}});
|
||||
if (response.result != SynchronousProcessResponse::Finished)
|
||||
return true;
|
||||
return !response.allOutput().contains("x86-64");
|
||||
@@ -429,20 +430,20 @@ FilePath AndroidConfig::keytoolPath() 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;
|
||||
SynchronousProcess adbProc;
|
||||
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 (error)
|
||||
*error = QApplication::translate("AndroidConfiguration",
|
||||
"Could not run: %1")
|
||||
.arg(adbToolPath + QLatin1String(" devices"));
|
||||
*error = QApplication::translate("AndroidConfiguration", "Could not run: %1")
|
||||
.arg(cmd.toUserOutput());
|
||||
return devices;
|
||||
}
|
||||
QStringList adbDevs = response.allOutput().split('\n', QString::SkipEmptyParts);
|
||||
@@ -485,7 +486,7 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const QString &adbToo
|
||||
if (devices.isEmpty() && error)
|
||||
*error = QApplication::translate("AndroidConfiguration",
|
||||
"No devices found in output of: %1")
|
||||
.arg(adbToolPath + QLatin1String(" devices"));
|
||||
.arg(cmd.toUserOutput());
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -501,33 +502,33 @@ bool AndroidConfig::isConnected(const QString &serialNumber) 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
|
||||
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
|
||||
arguments << QLatin1String("shell")
|
||||
<< QLatin1String("ls -l /system/bin/appcontroller || ls -l /usr/bin/appcontroller && echo Boot2Qt");
|
||||
CommandLine cmd(adbToolPath, AndroidDeviceInfo::adbSelector(device));
|
||||
cmd.addArg("shell");
|
||||
cmd.addArg("ls -l /system/bin/appcontroller || ls -l /usr/bin/appcontroller && echo Boot2Qt");
|
||||
|
||||
SynchronousProcess adbProc;
|
||||
adbProc.setTimeoutS(10);
|
||||
SynchronousProcessResponse response = adbProc.runBlocking(adbToolPath, arguments);
|
||||
SynchronousProcessResponse response = adbProc.runBlocking(cmd);
|
||||
return response.result == SynchronousProcessResponse::Finished
|
||||
&& 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
|
||||
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
|
||||
arguments << QLatin1String("shell") << QLatin1String("getprop") << property;
|
||||
CommandLine cmd(adbToolPath, AndroidDeviceInfo::adbSelector(device));
|
||||
cmd.addArgs({"shell", "getprop", property});
|
||||
|
||||
SynchronousProcess adbProc;
|
||||
adbProc.setTimeoutS(10);
|
||||
SynchronousProcessResponse response = adbProc.runBlocking(adbToolPath, arguments);
|
||||
SynchronousProcessResponse response = adbProc.runBlocking(cmd);
|
||||
if (response.result != SynchronousProcessResponse::Finished)
|
||||
return QString();
|
||||
|
||||
@@ -536,12 +537,12 @@ QString AndroidConfig::getDeviceProperty(const QString &adbToolPath, const QStri
|
||||
|
||||
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())
|
||||
return -1;
|
||||
return tmp.trimmed().toInt();
|
||||
@@ -612,7 +613,7 @@ QString AndroidConfig::getProductModel(const QString &device) const
|
||||
if (m_serialNumberToDeviceName.contains(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())
|
||||
return device;
|
||||
|
||||
@@ -623,18 +624,18 @@ QString AndroidConfig::getProductModel(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;
|
||||
// First try via ro.product.cpu.abilist
|
||||
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
|
||||
arguments << QLatin1String("shell") << QLatin1String("getprop") << QLatin1String("ro.product.cpu.abilist");
|
||||
arguments << "shell" << "getprop" << "ro.product.cpu.abilist";
|
||||
SynchronousProcess adbProc;
|
||||
adbProc.setTimeoutS(10);
|
||||
SynchronousProcessResponse response = adbProc.runBlocking(adbToolPath, arguments);
|
||||
SynchronousProcessResponse response = adbProc.runBlocking({adbToolPath, arguments});
|
||||
if (response.result != SynchronousProcessResponse::Finished)
|
||||
return result;
|
||||
|
||||
@@ -656,7 +657,7 @@ QStringList AndroidConfig::getAbis(const QString &adbToolPath, const QString &de
|
||||
|
||||
SynchronousProcess abiProc;
|
||||
abiProc.setTimeoutS(10);
|
||||
SynchronousProcessResponse abiResponse = abiProc.runBlocking(adbToolPath, arguments);
|
||||
SynchronousProcessResponse abiResponse = abiProc.runBlocking({adbToolPath, arguments});
|
||||
if (abiResponse.result != SynchronousProcessResponse::Finished)
|
||||
return result;
|
||||
|
||||
@@ -1187,7 +1188,8 @@ void AndroidConfigurations::load()
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(2);
|
||||
proc.setProcessChannelMode(QProcess::MergedChannels);
|
||||
SynchronousProcessResponse response = proc.runBlocking(javaHomeExec.absoluteFilePath(), QStringList());
|
||||
SynchronousProcessResponse response =
|
||||
proc.runBlocking({FilePath::fromString(javaHomeExec.absoluteFilePath()), {}});
|
||||
if (response.result == SynchronousProcessResponse::Finished) {
|
||||
const QString &javaHome = response.allOutput().trimmed();
|
||||
if (!javaHome.isEmpty() && QFileInfo::exists(javaHome))
|
||||
|
@@ -139,7 +139,7 @@ public:
|
||||
Utils::FilePath keytoolPath() 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;
|
||||
|
||||
@@ -156,14 +156,15 @@ public:
|
||||
bool useNativeUiTools() const;
|
||||
|
||||
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;
|
||||
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;
|
||||
static QStringList getAbis(const QString &adbToolPath, const QString &device);
|
||||
static bool isBootToQt(const QString &adbToolPath, const QString &device);
|
||||
static QStringList getAbis(const Utils::FilePath &adbToolPath, const QString &device);
|
||||
static bool isBootToQt(const Utils::FilePath &adbToolPath, const QString &device);
|
||||
bool isBootToQt(const QString &device) const;
|
||||
static QString getAvdName(const QString &serialnumber);
|
||||
|
||||
|
@@ -32,6 +32,8 @@
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
using namespace Android::Internal;
|
||||
|
||||
AndroidCreateKeystoreCertificate::AndroidCreateKeystoreCertificate(QWidget *parent) :
|
||||
@@ -169,24 +171,23 @@ void AndroidCreateKeystoreCertificate::on_buttonBox_accepted()
|
||||
if (ui->stateNameLineEdit->text().length())
|
||||
distinguishedNames += QLatin1String(", S=") + ui->stateNameLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,"));
|
||||
|
||||
const QString command = AndroidConfigurations::currentConfig().keytoolPath().toString();
|
||||
QStringList params;
|
||||
params << QLatin1String("-genkey") << QLatin1String("-keyalg") << QLatin1String("RSA")
|
||||
<< QLatin1String("-keystore") << m_keystoreFilePath.toString()
|
||||
<< QLatin1String("-storepass") << keystorePassword()
|
||||
<< QLatin1String("-alias") << certificateAlias()
|
||||
<< QLatin1String("-keysize") << ui->keySizeSpinBox->text()
|
||||
<< QLatin1String("-validity") << ui->validitySpinBox->text()
|
||||
<< QLatin1String("-keypass") << certificatePassword()
|
||||
<< QLatin1String("-dname") << distinguishedNames;
|
||||
const CommandLine command(AndroidConfigurations::currentConfig().keytoolPath(),
|
||||
{ "-genkey", "-keyalg", "RSA",
|
||||
"-keystore", m_keystoreFilePath.toString(),
|
||||
"-storepass", keystorePassword(),
|
||||
"-alias", certificateAlias(),
|
||||
"-keysize", ui->keySizeSpinBox->text(),
|
||||
"-validity", ui->validitySpinBox->text(),
|
||||
"-keypass", certificatePassword(),
|
||||
"-dname", distinguishedNames});
|
||||
|
||||
Utils::SynchronousProcess genKeyCertProc;
|
||||
SynchronousProcess genKeyCertProc;
|
||||
genKeyCertProc.setTimeoutS(15);
|
||||
Utils::SynchronousProcessResponse response = genKeyCertProc.run(command, params);
|
||||
SynchronousProcessResponse response = genKeyCertProc.run(command);
|
||||
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) {
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
response.exitMessage(command, 15) + QLatin1Char('\n') + response.allOutput());
|
||||
response.exitMessage(command.executable().toString(), 15) + '\n' + response.allOutput());
|
||||
return;
|
||||
}
|
||||
accept();
|
||||
|
@@ -345,9 +345,9 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
||||
}
|
||||
qCDebug(deployStepLog) << "Uninstalling previous package";
|
||||
emit addOutput(tr("Uninstall previous package %1.").arg(packageName), OutputFormat::NormalMessage);
|
||||
runCommand(m_adbPath.toString(),
|
||||
runCommand({m_adbPath,
|
||||
AndroidDeviceInfo::adbSelector(m_serialNumber)
|
||||
<< QLatin1String("uninstall") << packageName);
|
||||
<< "uninstall" << packageName});
|
||||
}
|
||||
|
||||
cmd.addArgs(AndroidDeviceInfo::adbSelector(m_serialNumber));
|
||||
@@ -489,9 +489,9 @@ bool AndroidDeployQtStep::runImpl()
|
||||
|
||||
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr) {
|
||||
QFile::remove(itr.value());
|
||||
runCommand(m_adbPath.toString(),
|
||||
runCommand({m_adbPath,
|
||||
AndroidDeviceInfo::adbSelector(m_serialNumber)
|
||||
<< "pull" << itr.key() << itr.value());
|
||||
<< "pull" << itr.key() << itr.value()});
|
||||
if (!QFileInfo::exists(itr.value())) {
|
||||
emit addOutput(tr("Package deploy: Failed to pull \"%1\" to \"%2\".")
|
||||
.arg(itr.key())
|
||||
@@ -545,14 +545,16 @@ void AndroidDeployQtStep::doRun()
|
||||
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);
|
||||
emit addOutput(tr("Package deploy: Running command \"%1 %2\".").arg(program).arg(arguments.join(QLatin1Char(' '))), BuildStep::OutputFormat::NormalMessage);
|
||||
Utils::SynchronousProcessResponse response = buildProc.run(program, arguments);
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0)
|
||||
emit addOutput(response.exitMessage(program, 2 * 60), BuildStep::OutputFormat::ErrorMessage);
|
||||
emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
|
||||
OutputFormat::NormalMessage);
|
||||
SynchronousProcessResponse response = buildProc.run(command);
|
||||
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0)
|
||||
emit addOutput(response.exitMessage(command.executable().toString(), 2 * 60),
|
||||
OutputFormat::ErrorMessage);
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *AndroidDeployQtStep::createConfigWidget()
|
||||
|
@@ -80,7 +80,7 @@ signals:
|
||||
void setSerialNumber(const QString &serialNumber);
|
||||
|
||||
private:
|
||||
void runCommand(const QString &program, const QStringList &arguments);
|
||||
void runCommand(const Utils::CommandLine &command);
|
||||
|
||||
bool init() override;
|
||||
void doRun() override;
|
||||
|
@@ -473,7 +473,7 @@ AndroidDeviceDialog::AndroidDeviceDialog(int apiLevel, const QString &abi,
|
||||
connect(m_ui->lookingForDeviceCancel, &QPushButton::clicked,
|
||||
this, &AndroidDeviceDialog::defaultDeviceClear);
|
||||
|
||||
m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath().toString());
|
||||
m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath());
|
||||
}
|
||||
|
||||
AndroidDeviceDialog::~AndroidDeviceDialog()
|
||||
@@ -512,7 +512,7 @@ void AndroidDeviceDialog::refreshDeviceList()
|
||||
{
|
||||
m_ui->refreshDevicesButton->setEnabled(false);
|
||||
m_progressIndicator->show();
|
||||
m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath().toString());
|
||||
m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath());
|
||||
m_futureWatcherRefreshDevices.setFuture(m_avdManager->avdList());
|
||||
}
|
||||
|
||||
|
@@ -526,15 +526,11 @@ bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QS
|
||||
{
|
||||
if (keystorePasswd.isEmpty())
|
||||
return false;
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("-list")
|
||||
<< QLatin1String("-keystore")
|
||||
<< keystorePath
|
||||
<< QLatin1String("--storepass")
|
||||
<< keystorePasswd;
|
||||
Utils::SynchronousProcess proc;
|
||||
const CommandLine cmd(AndroidConfigurations::currentConfig().keytoolPath(),
|
||||
{"-list", "-keystore", keystorePath, "--storepass", keystorePasswd});
|
||||
SynchronousProcess proc;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -548,11 +544,11 @@ bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const
|
||||
else
|
||||
arguments << certificatePasswd;
|
||||
|
||||
Utils::SynchronousProcess proc;
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(10);
|
||||
Utils::SynchronousProcessResponse response
|
||||
= proc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments);
|
||||
return response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0;
|
||||
SynchronousProcessResponse response
|
||||
= proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||
return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
|
||||
}
|
||||
|
||||
bool AndroidManager::checkCertificateExists(const QString &keystorePath,
|
||||
@@ -562,11 +558,11 @@ bool AndroidManager::checkCertificateExists(const QString &keystorePath,
|
||||
QStringList arguments = { "-list", "-keystore", keystorePath,
|
||||
"--storepass", keystorePasswd, "-alias", alias };
|
||||
|
||||
Utils::SynchronousProcess proc;
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(10);
|
||||
Utils::SynchronousProcessResponse response
|
||||
= proc.run(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments);
|
||||
return response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0;
|
||||
SynchronousProcessResponse response
|
||||
= proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||
return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
|
||||
}
|
||||
|
||||
using GradleProperties = QMap<QByteArray, QByteArray>;
|
||||
@@ -716,35 +712,35 @@ QProcess *AndroidManager::runAdbCommandDetached(const QStringList &args, QString
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SdkToolResult AndroidManager::runCommand(const QString &executable, const QStringList &args,
|
||||
SdkToolResult AndroidManager::runCommand(const CommandLine &command,
|
||||
const QByteArray &writeData, int timeoutS)
|
||||
{
|
||||
Android::SdkToolResult cmdResult;
|
||||
Utils::SynchronousProcess cmdProc;
|
||||
cmdProc.setTimeoutS(timeoutS);
|
||||
qCDebug(androidManagerLog) << "Running command: " << executable << args.join(' ');
|
||||
Utils::SynchronousProcessResponse response = cmdProc.run(executable, args, writeData);
|
||||
qCDebug(androidManagerLog) << "Running command: " << command.toUserOutput();
|
||||
SynchronousProcessResponse response = cmdProc.run(command, writeData);
|
||||
cmdResult.m_stdOut = response.stdOut().trimmed();
|
||||
cmdResult.m_stdErr = response.stdErr().trimmed();
|
||||
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
|
||||
<< "Output:" << response.allRawOutput();
|
||||
if (!cmdResult.success())
|
||||
cmdResult.m_exitMessage = response.exitMessage(executable, timeoutS);
|
||||
cmdResult.m_exitMessage = response.exitMessage(command.executable().toString(), timeoutS);
|
||||
return cmdResult;
|
||||
}
|
||||
|
||||
SdkToolResult AndroidManager::runAdbCommand(const QStringList &args,
|
||||
const QByteArray &writeData, int timeoutS)
|
||||
{
|
||||
return runCommand(AndroidConfigurations::currentConfig().adbToolPath().toString(), args,
|
||||
return runCommand({AndroidConfigurations::currentConfig().adbToolPath(), args},
|
||||
writeData, timeoutS);
|
||||
}
|
||||
|
||||
SdkToolResult AndroidManager::runAaptCommand(const QStringList &args, int timeoutS)
|
||||
{
|
||||
return runCommand(AndroidConfigurations::currentConfig().aaptToolPath().toString(), args, {},
|
||||
return runCommand({AndroidConfigurations::currentConfig().aaptToolPath(), args}, {},
|
||||
timeoutS);
|
||||
}
|
||||
} // namespace Android
|
||||
|
@@ -40,7 +40,10 @@ class Kit;
|
||||
class Target;
|
||||
}
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
namespace Utils {
|
||||
class CommandLine;
|
||||
class FilePath;
|
||||
}
|
||||
|
||||
namespace Android {
|
||||
|
||||
@@ -118,7 +121,7 @@ public:
|
||||
static QJsonObject deploymentSettings(const ProjectExplorer::Target *target);
|
||||
|
||||
private:
|
||||
static SdkToolResult runCommand(const QString &executable, const QStringList &args,
|
||||
static SdkToolResult runCommand(const Utils::CommandLine &command,
|
||||
const QByteArray &writeData = {}, int timeoutS = 30);
|
||||
};
|
||||
|
||||
|
@@ -63,6 +63,7 @@ static const int GdbTempFileMaxCounter = 20;
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Android {
|
||||
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();
|
||||
do {
|
||||
QThread::msleep(200);
|
||||
QString adbPath = AndroidConfigurations::currentConfig().adbToolPath().toString();
|
||||
FilePath adbPath = AndroidConfigurations::currentConfig().adbToolPath();
|
||||
selector.append("shell");
|
||||
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) {
|
||||
processPID = extractPID(out, packageName);
|
||||
} else {
|
||||
|
@@ -136,7 +136,7 @@ static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
||||
proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(config));
|
||||
proc.setTimeoutS(timeout);
|
||||
proc.setTimeOutMessageBoxEnabled(true);
|
||||
SynchronousProcessResponse response = proc.run(config.sdkManagerToolPath().toString(), args);
|
||||
SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), args});
|
||||
if (output)
|
||||
*output = response.allOutput();
|
||||
return response.result == SynchronousProcessResponse::Finished;
|
||||
@@ -175,7 +175,7 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
||||
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations,
|
||||
&proc, &SynchronousProcess::terminate);
|
||||
}
|
||||
SynchronousProcessResponse response = proc.run(config.sdkManagerToolPath().toString(), args);
|
||||
SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), args});
|
||||
if (assertionFound) {
|
||||
output.success = false;
|
||||
output.stdOutput = response.stdOut();
|
||||
|
@@ -60,10 +60,9 @@ public:
|
||||
static bool androidToolCommand(Utils::FilePath toolPath, const QStringList &args,
|
||||
const QProcessEnvironment &environment, QString *output)
|
||||
{
|
||||
QString androidToolPath = toolPath.toString();
|
||||
SynchronousProcess proc;
|
||||
proc.setProcessEnvironment(environment);
|
||||
SynchronousProcessResponse response = proc.runBlocking(androidToolPath, args);
|
||||
SynchronousProcessResponse response = proc.runBlocking({toolPath, args});
|
||||
if (response.result == SynchronousProcessResponse::Finished) {
|
||||
if (output)
|
||||
*output = response.allOutput();
|
||||
@@ -131,8 +130,7 @@ bool AndroidToolManager::removeAvd(const QString &name) const
|
||||
proc.setTimeoutS(5);
|
||||
proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(m_config));
|
||||
SynchronousProcessResponse response
|
||||
= proc.runBlocking(m_config.androidToolPath().toString(),
|
||||
QStringList({"delete", "avd", "-n", name}));
|
||||
= proc.runBlocking({m_config.androidToolPath(), {"delete", "avd", "-n", name}});
|
||||
return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
|
||||
}
|
||||
|
||||
|
@@ -85,8 +85,7 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const Core::Id lang
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
|
||||
CommandLine cmd(compiler, {});
|
||||
cmd.addArg(fakeIn.fileName());
|
||||
CommandLine cmd(compiler, {fakeIn.fileName()});
|
||||
if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
|
||||
cmd.addArg("--ec++");
|
||||
cmd.addArg("--predef_macros");
|
||||
@@ -131,8 +130,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Core::Id lang
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
|
||||
CommandLine cmd(compiler, {});
|
||||
cmd.addArg(fakeIn.fileName());
|
||||
CommandLine cmd(compiler, {fakeIn.fileName()});
|
||||
if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
|
||||
cmd.addArg("--ec++");
|
||||
cmd.addArg("--preinclude");
|
||||
|
@@ -102,8 +102,7 @@ static Macros dumpC51PredefinedMacros(const FilePath &compiler, const QStringLis
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
|
||||
CommandLine cmd(compiler, {});
|
||||
cmd.addArg(fakeIn.fileName());
|
||||
const CommandLine cmd(compiler, {fakeIn.fileName()});
|
||||
|
||||
const SynchronousProcessResponse response = cpp.runBlocking(cmd);
|
||||
if (response.result != SynchronousProcessResponse::Finished
|
||||
@@ -131,8 +130,7 @@ static Macros dumpArmPredefinedMacros(const FilePath &compiler, const QStringLis
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
|
||||
CommandLine cmd(compiler, {});
|
||||
cmd.addArgs({"-E", "--list-macros"});
|
||||
const CommandLine cmd(compiler, {"-E", "--list-macros"});
|
||||
|
||||
const SynchronousProcessResponse response = cpp.runBlocking(cmd);
|
||||
if (response.result != SynchronousProcessResponse::Finished
|
||||
|
@@ -92,8 +92,7 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const QStringList &
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
|
||||
CommandLine cmd(compiler, {});
|
||||
cmd.addArgs({compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()});
|
||||
const CommandLine cmd(compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()});
|
||||
|
||||
const SynchronousProcessResponse response = cpp.runBlocking(cmd);
|
||||
if (response.result != SynchronousProcessResponse::Finished
|
||||
@@ -116,8 +115,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const QStringList &
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
|
||||
CommandLine cmd(compiler, {});
|
||||
cmd.addArgs({compilerTargetFlag(abi), "--print-search-dirs"});
|
||||
const CommandLine cmd(compiler, {compilerTargetFlag(abi), "--print-search-dirs"});
|
||||
|
||||
const SynchronousProcessResponse response = cpp.runBlocking(cmd);
|
||||
if (response.result != SynchronousProcessResponse::Finished
|
||||
|
@@ -121,9 +121,9 @@ QString AbstractSettings::styleFileName(const QString &key) const
|
||||
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)
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <QVector>
|
||||
|
||||
namespace Core { class IDocument; }
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace Beautifier {
|
||||
namespace Internal {
|
||||
@@ -64,7 +65,7 @@ public:
|
||||
void replaceStyle(const QString &oldKey, const QString &newKey, const QString &value);
|
||||
virtual QString styleFileName(const QString &key) const;
|
||||
|
||||
QString command() const;
|
||||
Utils::FilePath command() const;
|
||||
void setCommand(const QString &command);
|
||||
int version() const;
|
||||
virtual void updateVersion();
|
||||
|
@@ -147,7 +147,7 @@ bool ArtisticStyle::isApplicable(const Core::IDocument *document) const
|
||||
Command ArtisticStyle::command(const QString &cfgFile) const
|
||||
{
|
||||
Command command;
|
||||
command.setExecutable(m_settings.command());
|
||||
command.setExecutable(m_settings.command().toString());
|
||||
command.addOption("-q");
|
||||
command.addOption("--options=" + cfgFile);
|
||||
|
||||
|
@@ -65,7 +65,7 @@ ArtisticStyleOptionsPageWidget::~ArtisticStyleOptionsPageWidget()
|
||||
|
||||
void ArtisticStyleOptionsPageWidget::restore()
|
||||
{
|
||||
ui->command->setPath(m_settings->command());
|
||||
ui->command->setFileName(m_settings->command());
|
||||
ui->mime->setText(m_settings->supportedMimeTypesAsString());
|
||||
ui->useOtherFiles->setChecked(m_settings->useOtherFiles());
|
||||
ui->useSpecificConfigFile->setChecked(m_settings->useSpecificConfigFile());
|
||||
|
@@ -82,11 +82,10 @@ static int parseVersion(const QString &text)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int updateVersionHelper(const QString &command)
|
||||
static int updateVersionHelper(const Utils::FilePath &command)
|
||||
{
|
||||
Utils::SynchronousProcess process;
|
||||
Utils::SynchronousProcessResponse response
|
||||
= process.runBlocking(command, QStringList("--version"));
|
||||
Utils::SynchronousProcessResponse response = process.runBlocking({command, {"--version"}});
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished)
|
||||
return 0;
|
||||
|
||||
@@ -182,8 +181,7 @@ void ArtisticStyleSettings::createDocumentationFile() const
|
||||
{
|
||||
Utils::SynchronousProcess process;
|
||||
process.setTimeoutS(2);
|
||||
Utils::SynchronousProcessResponse response
|
||||
= process.runBlocking(command(), QStringList("-h"));
|
||||
Utils::SynchronousProcessResponse response = process.runBlocking({command(), {"-h"}});
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished)
|
||||
return;
|
||||
|
||||
|
@@ -167,7 +167,7 @@ void ClangFormat::disableFormattingSelectedText()
|
||||
Command ClangFormat::command() const
|
||||
{
|
||||
Command command;
|
||||
command.setExecutable(m_settings.command());
|
||||
command.setExecutable(m_settings.command().toString());
|
||||
command.setProcessing(Command::PipeProcessing);
|
||||
|
||||
if (m_settings.usePredefinedStyle()) {
|
||||
|
@@ -70,7 +70,7 @@ ClangFormatOptionsPageWidget::~ClangFormatOptionsPageWidget()
|
||||
|
||||
void ClangFormatOptionsPageWidget::restore()
|
||||
{
|
||||
ui->command->setPath(m_settings->command());
|
||||
ui->command->setFileName(m_settings->command());
|
||||
ui->mime->setText(m_settings->supportedMimeTypesAsString());
|
||||
const int predefinedStyleIndex = ui->predefinedStyle->findText(m_settings->predefinedStyle());
|
||||
if (predefinedStyleIndex != -1)
|
||||
|
@@ -184,7 +184,7 @@ bool Uncrustify::isApplicable(const Core::IDocument *document) const
|
||||
Command Uncrustify::command(const QString &cfgFile, bool fragment) const
|
||||
{
|
||||
Command command;
|
||||
command.setExecutable(m_settings.command());
|
||||
command.setExecutable(m_settings.command().toString());
|
||||
command.setProcessing(Command::PipeProcessing);
|
||||
if (m_settings.version() >= 62) {
|
||||
command.addOption("--assume");
|
||||
|
@@ -68,7 +68,7 @@ UncrustifyOptionsPageWidget::~UncrustifyOptionsPageWidget()
|
||||
|
||||
void UncrustifyOptionsPageWidget::restore()
|
||||
{
|
||||
ui->command->setPath(m_settings->command());
|
||||
ui->command->setFileName(m_settings->command());
|
||||
ui->mime->setText(m_settings->supportedMimeTypesAsString());
|
||||
ui->useOtherFiles->setChecked(m_settings->useOtherFiles());
|
||||
ui->useHomeFile->setChecked(m_settings->useHomeFile());
|
||||
|
@@ -152,7 +152,7 @@ void UncrustifySettings::createDocumentationFile() const
|
||||
Utils::SynchronousProcess process;
|
||||
process.setTimeoutS(2);
|
||||
Utils::SynchronousProcessResponse response
|
||||
= process.runBlocking(command(), QStringList("--show-config"));
|
||||
= process.runBlocking(Utils::CommandLine(command(), {"--show-config"}));
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished)
|
||||
return;
|
||||
|
||||
@@ -230,7 +230,7 @@ void UncrustifySettings::updateVersion()
|
||||
m_versionProcess.kill();
|
||||
m_versionProcess.waitForFinished();
|
||||
}
|
||||
m_versionProcess.start(command(), {"--version"});
|
||||
m_versionProcess.start(command().toString(), {"--version"});
|
||||
}
|
||||
|
||||
void UncrustifySettings::parseVersionProcessResult(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
|
@@ -2140,15 +2140,15 @@ void ClearCasePlugin::diffGraphical(const QString &file1, const QString &file2)
|
||||
QString ClearCasePlugin::runExtDiff(const QString &workingDir, const QStringList &arguments,
|
||||
int timeOutS, QTextCodec *outputCodec)
|
||||
{
|
||||
const QString executable(QLatin1String("diff"));
|
||||
QStringList args(m_settings.diffArgs.split(QLatin1Char(' '), QString::SkipEmptyParts));
|
||||
args << arguments;
|
||||
CommandLine diff(FilePath::fromString("diff"));
|
||||
diff.addArgs(m_settings.diffArgs.split(' ', QString::SkipEmptyParts));
|
||||
diff.addArgs(arguments);
|
||||
|
||||
SynchronousProcess process;
|
||||
process.setTimeoutS(timeOutS);
|
||||
process.setWorkingDirectory(workingDir);
|
||||
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));
|
||||
SynchronousProcessResponse response = process.run(executable, args);
|
||||
SynchronousProcessResponse response = process.run(diff);
|
||||
if (response.result != SynchronousProcessResponse::Finished)
|
||||
return QString();
|
||||
return response.allOutput();
|
||||
|
@@ -169,7 +169,7 @@ Utils::SynchronousProcessResponse CMakeTool::run(const QStringList &args, bool m
|
||||
cmake.setProcessEnvironment(env.toProcessEnvironment());
|
||||
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_didRun = mayFail ? true : (response.result == Utils::SynchronousProcessResponse::Finished);
|
||||
return response;
|
||||
|
@@ -64,12 +64,12 @@ const char DEBUGGER_INFORMATION_WORKINGDIRECTORY[] = "WorkingDirectory";
|
||||
|
||||
//! Return the configuration of gdb as a list of --key=value
|
||||
//! \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
|
||||
Utils::SynchronousProcess gdbConfigurationCall;
|
||||
Utils::SynchronousProcessResponse output =
|
||||
gdbConfigurationCall.runBlocking(command, {QString("--configuration")});
|
||||
gdbConfigurationCall.runBlocking({command, {"--configuration"}});
|
||||
return output.allOutput();
|
||||
}
|
||||
|
||||
@@ -142,15 +142,14 @@ void DebuggerItem::reinitializeFromFile()
|
||||
// CDB only understands the single-dash -version, whereas GDB and LLDB are
|
||||
// happy with both -version and --version. So use the "working" -version
|
||||
// except for the experimental LLDB-MI which insists on --version.
|
||||
const char *version = "-version";
|
||||
QString version = "-version";
|
||||
const QFileInfo fileInfo = m_command.toFileInfo();
|
||||
m_lastModified = fileInfo.lastModified();
|
||||
if (fileInfo.baseName().toLower().contains("lldb-mi"))
|
||||
version = "--version";
|
||||
|
||||
SynchronousProcess proc;
|
||||
SynchronousProcessResponse response
|
||||
= proc.runBlocking(m_command.toString(), {QLatin1String(version)});
|
||||
SynchronousProcessResponse response = proc.runBlocking({m_command, {version}});
|
||||
if (response.result != SynchronousProcessResponse::Finished) {
|
||||
m_engineType = NoEngineType;
|
||||
return;
|
||||
@@ -173,7 +172,7 @@ void DebuggerItem::reinitializeFromFile()
|
||||
const bool unableToFindAVersion = (0 == version);
|
||||
const bool gdbSupportsConfigurationFlag = (version >= 70700);
|
||||
if (gdbSupportsConfigurationFlag || unableToFindAVersion) {
|
||||
const auto gdbConfiguration = getConfigurationOfGdbCommand(m_command.toString());
|
||||
const auto gdbConfiguration = getConfigurationOfGdbCommand(m_command);
|
||||
const auto gdbTargetAbiString =
|
||||
extractGdbTargetAbiStringFromGdbOutput(gdbConfiguration);
|
||||
if (!gdbTargetAbiString.isEmpty()) {
|
||||
|
@@ -727,7 +727,7 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
|
||||
SynchronousProcess lldbInfo;
|
||||
lldbInfo.setTimeoutS(2);
|
||||
SynchronousProcessResponse response
|
||||
= lldbInfo.runBlocking("xcrun", {"--find", "lldb"});
|
||||
= lldbInfo.runBlocking(CommandLine(FilePath::fromString("xcrun"), {"--find", "lldb"}));
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished) {
|
||||
QString lPath = response.allOutput().trimmed();
|
||||
if (!lPath.isEmpty()) {
|
||||
|
@@ -4679,7 +4679,8 @@ CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const QS
|
||||
QStringList envLang = QProcess::systemEnvironment();
|
||||
Utils::Environment::setupEnglishOutput(&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) {
|
||||
QString output = response.stdOut();
|
||||
|
@@ -233,7 +233,7 @@ static QByteArray decodeProvisioningProfile(const QString &path)
|
||||
p.setTimeoutS(3);
|
||||
// path is assumed to be valid file path to .mobileprovision
|
||||
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)
|
||||
qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path;
|
||||
return res.stdOut().toLatin1();
|
||||
|
@@ -35,6 +35,8 @@
|
||||
|
||||
static Q_LOGGING_CATEGORY(probeLog, "qtc.ios.probe", QtWarningMsg)
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Ios {
|
||||
|
||||
static QString defaultDeveloperPath = QLatin1String("/Applications/Xcode.app/Contents/Developer");
|
||||
@@ -64,8 +66,8 @@ void XcodeProbe::detectDeveloperPaths()
|
||||
{
|
||||
Utils::SynchronousProcess selectedXcode;
|
||||
selectedXcode.setTimeoutS(5);
|
||||
Utils::SynchronousProcessResponse response = selectedXcode.run(
|
||||
QLatin1String("/usr/bin/xcode-select"), QStringList("--print-path"));
|
||||
const CommandLine xcodeSelect{FilePath::fromString("/usr/bin/xcode-select"), {"--print-path"}};
|
||||
Utils::SynchronousProcessResponse response = selectedXcode.run(xcodeSelect);
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished)
|
||||
qCWarning(probeLog)
|
||||
<< QString::fromLatin1("Could not detect selected Xcode using xcode-select");
|
||||
|
@@ -44,6 +44,7 @@
|
||||
#include <QLoggingCategory>
|
||||
#include <QProcess>
|
||||
|
||||
using namespace Utils;
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
@@ -77,20 +78,20 @@ static bool checkForTimeout(const chrono::high_resolution_clock::time_point &sta
|
||||
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);
|
||||
Utils::SynchronousProcessResponse resp = p.runBlocking(command, args);
|
||||
SynchronousProcessResponse resp = p.runBlocking(command);
|
||||
if (output)
|
||||
*output = resp.stdOut();
|
||||
return resp.result == Utils::SynchronousProcessResponse::Finished;
|
||||
return resp.result == SynchronousProcessResponse::Finished;
|
||||
}
|
||||
|
||||
static bool runSimCtlCommand(QStringList args, QString *output)
|
||||
{
|
||||
args.prepend("simctl");
|
||||
return runCommand("xcrun", args, output);
|
||||
return runCommand({FilePath::fromString("xcrun"), args}, output);
|
||||
}
|
||||
|
||||
static bool launchSimulator(const QString &simUdid) {
|
||||
@@ -101,10 +102,10 @@ static bool launchSimulator(const QString &simUdid) {
|
||||
if (IosConfigurations::xcodeVersion() >= QVersionNumber(9)) {
|
||||
// For XCode 9 boot the second device instead of launching simulator app twice.
|
||||
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')) {
|
||||
if (comm == simulatorAppPath)
|
||||
return runSimCtlCommand(QStringList({"boot", simUdid}), nullptr);
|
||||
return runSimCtlCommand({"boot", simUdid}, nullptr);
|
||||
}
|
||||
} else {
|
||||
qCDebug(simulatorLog) << "Cannot start Simulator device."
|
||||
|
@@ -996,7 +996,8 @@ PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir,
|
||||
}
|
||||
}
|
||||
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;
|
||||
response.error = true;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "customwizard.h"
|
||||
#include "customwizardparameters.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
@@ -107,11 +108,11 @@ static bool
|
||||
}
|
||||
process.setWorkingDirectory(workingDirectory);
|
||||
process.setTimeoutS(30);
|
||||
const Utils::CommandLine cmd(Utils::FilePath::fromString(binary), arguments);
|
||||
if (CustomWizard::verbose())
|
||||
qDebug("In %s, running:\n%s\n%s\n", qPrintable(workingDirectory),
|
||||
qPrintable(binary),
|
||||
qPrintable(arguments.join(QLatin1Char(' '))));
|
||||
Utils::SynchronousProcessResponse response = process.run(binary, arguments);
|
||||
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory),
|
||||
qPrintable(cmd.toUserOutput()));
|
||||
Utils::SynchronousProcessResponse response = process.run(cmd);
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished) {
|
||||
*errorMessage = QString::fromLatin1("Generator script failed: %1")
|
||||
.arg(response.exitMessage(binary, 30));
|
||||
|
@@ -88,7 +88,7 @@ static QByteArray runGcc(const FilePath &gcc, const QStringList &arguments, cons
|
||||
|
||||
cpp.setEnvironment(environment);
|
||||
cpp.setTimeoutS(10);
|
||||
SynchronousProcessResponse response = cpp.runBlocking(gcc.toString(), arguments);
|
||||
SynchronousProcessResponse response = cpp.runBlocking(CommandLine(gcc, arguments));
|
||||
if (response.result != SynchronousProcessResponse::Finished ||
|
||||
response.exitCode != 0) {
|
||||
qWarning() << response.exitMessage(gcc.toString(), 10);
|
||||
|
@@ -239,9 +239,9 @@ static QVector<VisualStudioInstallation> detectVisualStudioFromVsWhere(const QSt
|
||||
Utils::SynchronousProcess vsWhereProcess;
|
||||
const int timeoutS = 5;
|
||||
vsWhereProcess.setTimeoutS(timeoutS);
|
||||
const QStringList
|
||||
arguments{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"};
|
||||
Utils::SynchronousProcessResponse response = vsWhereProcess.runBlocking(vswhere, arguments);
|
||||
const CommandLine cmd(FilePath::fromString(vswhere),
|
||||
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"});
|
||||
Utils::SynchronousProcessResponse response = vsWhereProcess.runBlocking(cmd);
|
||||
switch (response.result) {
|
||||
case Utils::SynchronousProcessResponse::Finished:
|
||||
break;
|
||||
@@ -622,7 +622,7 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
||||
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
|
||||
arguments << QLatin1String("/TC");
|
||||
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)
|
||||
return predefinedMacros;
|
||||
|
||||
@@ -1540,10 +1540,10 @@ static const MsvcToolChain *findMsvcToolChain(const QString &displayedVarsBat)
|
||||
|
||||
static QVersionNumber clangClVersion(const QString &clangClPath)
|
||||
{
|
||||
Utils::SynchronousProcess clangClProcess;
|
||||
const Utils::SynchronousProcessResponse response
|
||||
= clangClProcess.runBlocking(clangClPath, {QStringLiteral("--version")});
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0)
|
||||
SynchronousProcess clangClProcess;
|
||||
const SynchronousProcessResponse response
|
||||
= clangClProcess.runBlocking({FilePath::fromString(clangClPath), {"--version"}});
|
||||
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0)
|
||||
return {};
|
||||
const QRegularExpressionMatch match = QRegularExpression(
|
||||
QStringLiteral("clang version (\\d+(\\.\\d+)+)"))
|
||||
@@ -1779,8 +1779,7 @@ Macros ClangClToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
||||
QStringList arguments = cxxflags;
|
||||
arguments.append(gccPredefinedMacrosOptions(language()));
|
||||
arguments.append("-");
|
||||
Utils::SynchronousProcessResponse response = cpp.runBlocking(compilerCommand().toString(),
|
||||
arguments);
|
||||
Utils::SynchronousProcessResponse response = cpp.runBlocking({compilerCommand(), arguments});
|
||||
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) {
|
||||
// Show the warning but still parse the output.
|
||||
QTC_CHECK(false && "clang-cl exited with non-zero code.");
|
||||
@@ -2109,13 +2108,12 @@ Utils::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils:
|
||||
if (cmdPath.isEmpty())
|
||||
cmdPath = env.searchInPath(QLatin1String("cmd.exe"));
|
||||
// Windows SDK setup scripts require command line switches for environment expansion.
|
||||
QStringList cmdArguments({QLatin1String("/E:ON"), QLatin1String("/V:ON"), QLatin1String("/c")});
|
||||
cmdArguments << QDir::toNativeSeparators(saver.fileName());
|
||||
CommandLine cmd(cmdPath, {"/E:ON", "/V:ON", "/c", QDir::toNativeSeparators(saver.fileName())});
|
||||
if (debug)
|
||||
qDebug() << "readEnvironmentSetting: " << call << cmdPath << cmdArguments.join(' ')
|
||||
qDebug() << "readEnvironmentSetting: " << call << cmd.toUserOutput()
|
||||
<< " Env: " << runEnv.size();
|
||||
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) {
|
||||
const QString message = !response.stdErr().isEmpty()
|
||||
|
@@ -90,7 +90,8 @@ static FormatTask format(FormatTask task)
|
||||
options.replaceInStrings(QLatin1String("%file"), sourceFile.fileName());
|
||||
Utils::SynchronousProcess process;
|
||||
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) {
|
||||
task.error = QString(QT_TRANSLATE_NOOP("TextEditor", "Failed to format: %1."))
|
||||
.arg(response.exitMessage(executable, 5));
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "texteditorconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
|
||||
@@ -67,12 +69,12 @@ QString findFallbackDefinitionsLocation()
|
||||
}
|
||||
|
||||
// Try kde-config.
|
||||
const QStringList programs = {QLatin1String("kde-config"), QLatin1String("kde4-config")};
|
||||
const QStringList programs = {"kde-config", "kde4-config"};
|
||||
for (auto &program : programs) {
|
||||
Utils::SynchronousProcess process;
|
||||
process.setTimeoutS(5);
|
||||
Utils::SynchronousProcessResponse response
|
||||
= process.runBlocking(program, QStringList(QLatin1String("--prefix")));
|
||||
= process.runBlocking({Utils::FilePath::fromString(program), {"--prefix"}});
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished) {
|
||||
QString output = response.stdOut();
|
||||
output.remove(QLatin1Char('\n'));
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
@@ -56,6 +57,6 @@ void MainWindow::test()
|
||||
qDebug() << "Async: " << cmd << args;
|
||||
connect(&process, &Utils::SynchronousProcess::stdOutBuffered, 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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user