ProjectExplorer: Auto-detect installed GNU tools for ARM on Windows

This patch implements the auto-detection for the installed
GCC embedded toolchains provided by "ARM Holdings":

https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

The detection algorithm does search a toolchain path in a
Windows registry; this will work only if a toolchain was
installed using the installer.

Change-Id: Ide71fa57e5fa060372439923c8422c33ab81a8a0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Denis Shienkov
2019-07-09 19:09:45 +03:00
parent 77c419ee5f
commit e358c169a2

View File

@@ -855,6 +855,38 @@ QString GccToolChain::detectVersion() const
// GccToolChainFactory
// --------------------------------------------------------------------------
static Utils::FilePathList searchPathsFromRegistry()
{
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\\";
Utils::FilePathList searchPaths;
QSettings registry(kRegistryToken, QSettings::NativeFormat);
const auto productGroups = registry.childGroups();
for (const QString &productKey : productGroups) {
if (!productKey.startsWith("GNU Tools for ARM Embedded Processors"))
continue;
registry.beginGroup(productKey);
QString uninstallFilePath = registry.value("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(FilePath::fromString(toolchainPath));
}
return searchPaths;
}
GccToolChainFactory::GccToolChainFactory()
{
setDisplayName(tr("GCC"));
@@ -904,7 +936,8 @@ QList<ToolChain *> GccToolChainFactory::autoDetectToolchains(
if (fi.isFile())
compilerPaths << FilePath::fromString(compilerName);
} else {
const FilePathList searchPaths = Environment::systemEnvironment().path();
FilePathList searchPaths = Environment::systemEnvironment().path();
searchPaths << searchPathsFromRegistry();
for (const FilePath &dir : searchPaths) {
static const QRegularExpression regexp(binaryRegexp);
QDir binDir(dir.toString());