aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-07-29 19:30:00 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-07-30 11:55:58 +0000
commit085240fb574d3fc4d7869700671bf92877b34b61 (patch)
treea684b22b3ea4f8333f87d9773ee484d1a84d4b93
parent2e896545a33df5ff8e8ddc62efed21abf71f132b (diff)
baremetal: Auto-detect GNU ARM toolchains on Windows
... which are installed from this site: https: //developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm Change-Id: Ic7e8886e53ede7b86289ef514eccd94870e17676 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/app/qbs-setup-toolchains/gccprobe.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/app/qbs-setup-toolchains/gccprobe.cpp b/src/app/qbs-setup-toolchains/gccprobe.cpp
index de6631cfd..4eee804c6 100644
--- a/src/app/qbs-setup-toolchains/gccprobe.cpp
+++ b/src/app/qbs-setup-toolchains/gccprobe.cpp
@@ -259,6 +259,41 @@ static QStringList buildCompilerNameFilters(const QString &compilerName)
return filters;
}
+static QStringList gnuRegistrySearchPaths()
+{
+ if (!HostOsInfo::isWindowsHost())
+ return {};
+
+ // Registry token for the "GNU Tools for ARM Embedded Processors".
+ static const char kRegistryToken[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" \
+ "Windows\\CurrentVersion\\Uninstall\\";
+
+ QStringList searchPaths;
+
+ QSettings registry(QLatin1String(kRegistryToken), QSettings::NativeFormat);
+ const auto productGroups = registry.childGroups();
+ for (const QString &productKey : productGroups) {
+ if (!productKey.startsWith(
+ QLatin1String("GNU Tools for ARM Embedded Processors"))) {
+ continue;
+ }
+ registry.beginGroup(productKey);
+ QString uninstallFilePath = registry.value(
+ QLatin1String("UninstallString")).toString();
+ if (uninstallFilePath.startsWith(QLatin1Char('"')))
+ uninstallFilePath.remove(0, 1);
+ if (uninstallFilePath.endsWith(QLatin1Char('"')))
+ uninstallFilePath.remove(uninstallFilePath.size() - 1, 1);
+ registry.endGroup();
+
+ const QString toolkitRootPath = QFileInfo(uninstallFilePath).path();
+ const QString toolchainPath = toolkitRootPath + QLatin1String("/bin");
+ searchPaths.push_back(toolchainPath);
+ }
+
+ return searchPaths;
+}
+
Profile createGccProfile(const QFileInfo &compiler, Settings *settings,
const QStringList &toolchainTypes,
const QString &profileName)
@@ -306,7 +341,8 @@ void gccProbe(Settings *settings, QList<Profile> &profiles, const QString &compi
{
qbsInfo() << Tr::tr("Trying to detect %1...").arg(compilerName);
- const QStringList searchPaths = systemSearchPaths();
+ QStringList searchPaths;
+ searchPaths << systemSearchPaths() << gnuRegistrySearchPaths();
std::vector<QFileInfo> candidates;
const auto filters = buildCompilerNameFilters(compilerName);