From 9c43466485bcc546f0daeea5277286b29efc781e Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 14 Nov 2019 16:07:55 +0100 Subject: [PATCH] Use HostOsInfo::withExecutableSuffix instead of if/else Let's use our Utils. Change-Id: I8cfbce55d2b41e42e86d050433df2cfd20cebe1b Reviewed-by: hjk --- src/plugins/android/androidbuildapkstep.cpp | 4 +--- src/plugins/android/androidrunnerworker.cpp | 5 +---- src/plugins/qmldesigner/generateresource.cpp | 7 ++----- src/tools/cplusplus-shared/utils.cpp | 13 ++----------- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index ccd9bec14d7..2b0ab580206 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -215,9 +215,7 @@ bool AndroidBuildApkStep::init() QString command = version->hostBinPath().toString(); if (!command.endsWith('/')) command += '/'; - command += "androiddeployqt"; - if (Utils::HostOsInfo::isWindowsHost()) - command += ".exe"; + command += Utils::HostOsInfo::withExecutableSuffix("androiddeployqt"); QString outputDir = bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString(); diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index 96508910e60..e4e1adf924a 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -589,10 +589,7 @@ void AndroidRunnerWorker::handleJdbWaiting() m_afterFinishAdbCommands.push_back(removeForward.join(' ')); auto jdbPath = AndroidConfigurations::currentConfig().openJDKLocation().pathAppended("bin"); - if (Utils::HostOsInfo::isWindowsHost()) - jdbPath = jdbPath.pathAppended("jdb.exe"); - else - jdbPath = jdbPath.pathAppended("jdb"); + jdbPath = jdbPath.pathAppended(Utils::HostOsInfo::withExecutableSuffix("jdb")); QStringList jdbArgs("-connect"); jdbArgs << QString("com.sun.jdi.SocketAttach:hostname=localhost,port=%1") diff --git a/src/plugins/qmldesigner/generateresource.cpp b/src/plugins/qmldesigner/generateresource.cpp index 2a07ae816ec..d1e73f0d59b 100644 --- a/src/plugins/qmldesigner/generateresource.cpp +++ b/src/plugins/qmldesigner/generateresource.cpp @@ -99,11 +99,8 @@ void GenerateResource::generateMenuEntry() temp.close(); auto rccBinary = QtSupport::QtKitAspect::qtVersion(currentProject->activeTarget()->kit())->hostBinPath(); -#ifdef Q_OS_WIN - rccBinary = rccBinary.pathAppended("rcc.exe"); -#else - rccBinary = rccBinary.pathAppended("rcc"); -#endif + rccBinary = rccBinary.pathAppended(Utils::HostOsInfo::withExecutableSuffix("rcc")); + QProcess rccProcess; rccProcess.setProgram(rccBinary.toString()); rccProcess.setWorkingDirectory(projectPath); diff --git a/src/tools/cplusplus-shared/utils.cpp b/src/tools/cplusplus-shared/utils.cpp index 1373d5f6f9f..a4111b6dd95 100644 --- a/src/tools/cplusplus-shared/utils.cpp +++ b/src/tools/cplusplus-shared/utils.cpp @@ -34,15 +34,6 @@ namespace CplusplusToolsUtils { -QString portableExecutableName(const QString &executable) -{ -#if defined(Q_OS_WIN) - return executable + QLatin1String(".exe"); -#else - return executable; -#endif -} - void executeCommand(const QString &command, const QStringList &arguments, const QString &outputFile, bool verbose) { @@ -86,9 +77,9 @@ void executeCommand(const QString &command, const QStringList &arguments, const SystemPreprocessor::SystemPreprocessor(bool verbose) : m_verbose(verbose) { - m_knownCompilers[portableExecutableName(QLatin1String("gcc"))] + m_knownCompilers[Utils::HostOsInfo::withExecutableSuffix("gcc")] = QLatin1String("-DCPLUSPLUS_WITHOUT_QT -U__BLOCKS__ -xc++ -E -include"); - m_knownCompilers[portableExecutableName(QLatin1String("cl"))] + m_knownCompilers[Utils::HostOsInfo::withExecutableSuffix("cl")] = QLatin1String("/DCPLUSPLUS_WITHOUT_QT /U__BLOCKS__ /TP /E /I . /FI"); QMapIterator i(m_knownCompilers);