summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-10-30 18:58:31 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-10-31 09:58:28 +0000
commit3ecbe3a17a5822e0f5650e93c712651757082047 (patch)
treeffa2c903539706915ec1551358b24bf5dabff83b
parentd0567a74115483b0d36df2e56e298dd488f14b2b (diff)
baremetal: Auto-detect MPLAB X32 GCC toolchain on Windows
Microchip Technology Inc. provides set of own GCC toolchains to use it with the PIC32 microcontrollers: * https://www.microchip.com/mplab/compilers On Windows these toolchains distributed in a form of the installer packages. So, it will be good to auto-detect such toolchains there. But, this patch do it partially, it can not detect each installed toolchain as separate instance. For example, if we have a two toolchains v2.20 and v2.30 installed, then it will looks like this: Profile 'xc32-gcc' created for 'C:/microchip/xc32/v2.20/bin/xc32-gcc.exe'. Profile 'xc32-gcc' created for 'C:/microchip/xc32/v2.30/bin/xc32-gcc.exe'. In resulting, the toolchain v2.20 will be overwritten by toolchain v2.30, because its names are identical, and then the one last profile will be created. Seems, to solve this issue we need to dump the compiler version. But a problem is in that both compilers has same 4.8.3 version. So, it is not possible to separate there two compilers in a simple way. Maybe, in future, we can look on the __XC_VERSION__ macro, and to interpret it as 'build' version (which is 2200 vs 2300). But, for this purpose we need to refactor the logic in gccprobe.cpp. Change-Id: Id804a411ed6046b31e57b0468d75830eef92693c 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 2be65ca79..7394acc38 100644
--- a/src/app/qbs-setup-toolchains/gccprobe.cpp
+++ b/src/app/qbs-setup-toolchains/gccprobe.cpp
@@ -423,6 +423,41 @@ static QStringList renesasRl78RegistrySearchPaths()
return searchPaths;
}
+static QStringList mplabX32RegistrySearchPaths()
+{
+ if (!HostOsInfo::isWindowsHost())
+ return {};
+
+ // Registry token for the "MPLAB X32" toolchain.
+ 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("MPLAB XC32 Compiler"))) {
+ continue;
+ }
+ registry.beginGroup(productKey);
+ const QString installLocation = registry.value(
+ QLatin1String("InstallLocation")).toString();
+ registry.endGroup();
+ if (installLocation.isEmpty())
+ continue;
+
+ const QFileInfo toolchainPath = QDir(installLocation).absolutePath()
+ + QLatin1String("/bin");
+ if (!toolchainPath.exists())
+ continue;
+ searchPaths.push_back(toolchainPath.absoluteFilePath());
+ }
+
+ return searchPaths;
+}
+
Profile createGccProfile(const QFileInfo &compiler, Settings *settings,
const QStringList &toolchainTypes,
const QString &profileName)
@@ -499,7 +534,8 @@ void gccProbe(Settings *settings, QList<Profile> &profiles, const QString &compi
searchPaths << systemSearchPaths()
<< gnuRegistrySearchPaths()
<< atmelRegistrySearchPaths()
- << renesasRl78RegistrySearchPaths();
+ << renesasRl78RegistrySearchPaths()
+ << mplabX32RegistrySearchPaths();
std::vector<QFileInfo> candidates;
const auto filters = buildCompilerNameFilters(compilerName);