forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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());
|
||||
|
Reference in New Issue
Block a user