From 085240fb574d3fc4d7869700671bf92877b34b61 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 29 Jul 2019 19:30:00 +0300 Subject: 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 --- src/app/qbs-setup-toolchains/gccprobe.cpp | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) 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 &profiles, const QString &compi { qbsInfo() << Tr::tr("Trying to detect %1...").arg(compilerName); - const QStringList searchPaths = systemSearchPaths(); + QStringList searchPaths; + searchPaths << systemSearchPaths() << gnuRegistrySearchPaths(); std::vector candidates; const auto filters = buildCompilerNameFilters(compilerName); -- cgit v1.2.3