diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2019-07-11 16:16:20 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2019-07-15 13:34:14 +0000 |
commit | 4077bc869c415e061dac28e1fdbd5403c40c798f (patch) | |
tree | 082d38cec539b5ce891c581f6366d67813a5c968 /src | |
parent | 68ac9d51a69f5b440924297331400e6ff9454b0e (diff) |
ProjectExplorer: Auto-detect installed GNU tools for AVR on Windows
This patch implements the auto-detection for the installed
GCC embedded toolchains for AVR architecture provided
by "Microchip" (e.g. located in Atmel Studio):
https://www.microchip.com/mplab/avr-support/atmel-studio-7
The detection algorithm does search a toolchain path in a
Windows registry; this will work only if the Atmel Studio
was installed.
Tested on Windows 10 with Atmel Studio v6.2 installed.
Change-Id: Ibd2dd95daf7e9da272611fc32d679852a7f20952
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/projectexplorer/gcctoolchain.cpp | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index f6c5cbe1aa..a0a9583e6f 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -857,7 +857,7 @@ QString GccToolChain::detectVersion() const // GccToolChainFactory // -------------------------------------------------------------------------- -static Utils::FilePathList searchPathsFromRegistry() +static Utils::FilePathList gnuSearchPathsFromRegistry() { if (!HostOsInfo::isWindowsHost()) return {}; @@ -889,6 +889,56 @@ static Utils::FilePathList searchPathsFromRegistry() return searchPaths; } +static Utils::FilePathList atmelSearchPathsFromRegistry() +{ + if (!HostOsInfo::isWindowsHost()) + return {}; + + // Registry token for the "Atmel" toolchains, e.g. provided by installed + // "Atmel Studio" IDE. + static const char kRegistryToken[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Atmel\\"; + + Utils::FilePathList searchPaths; + QSettings registry(kRegistryToken, QSettings::NativeFormat); + const auto toolchainGroups = registry.childGroups(); + for (const QString &toolchainKey : toolchainGroups) { + if (!toolchainKey.endsWith("GCC")) + continue; + registry.beginGroup(toolchainKey); + const auto entries = registry.childGroups(); + for (const auto &entryKey : entries) { + registry.beginGroup(entryKey); + const QString installDir = registry.value("Native/InstallDir").toString(); + const QString version = registry.value("Native/Version").toString(); + registry.endGroup(); + + QString toolchainPath = installDir + + QLatin1String("/Atmel Toolchain/") + + toolchainKey + QLatin1String("/Native/") + + version; + if (toolchainKey.startsWith("ARM")) + toolchainPath += QLatin1String("/arm-gnu-toolchain"); + else if (toolchainKey.startsWith("AVR32")) + toolchainPath += QLatin1String("/avr32-gnu-toolchain"); + else if (toolchainKey.startsWith("AVR8")) + toolchainPath += QLatin1String("/avr8-gnu-toolchain"); + else + break; + + toolchainPath += QLatin1String("/bin"); + + const FilePath path = FilePath::fromString(toolchainPath); + if (path.exists()) { + searchPaths.push_back(FilePath::fromString(toolchainPath)); + break; + } + } + registry.endGroup(); + } + + return searchPaths; +} + GccToolChainFactory::GccToolChainFactory() { setDisplayName(tr("GCC")); @@ -939,7 +989,8 @@ QList<ToolChain *> GccToolChainFactory::autoDetectToolchains( compilerPaths << FilePath::fromString(compilerName); } else { FilePathList searchPaths = Environment::systemEnvironment().path(); - searchPaths << searchPathsFromRegistry(); + searchPaths << gnuSearchPathsFromRegistry(); + searchPaths << atmelSearchPathsFromRegistry(); for (const FilePath &dir : searchPaths) { static const QRegularExpression regexp(binaryRegexp); QDir binDir(dir.toString()); |