summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-09-18 13:37:20 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-09-27 14:40:47 +0000
commit38292de68a707eeaa2e5ece5a16084c00f8e4bef (patch)
treedf6a9b07767c61b63dc750c53b39525576552d6b
parent2d95c905926f49a660778e6ea45f779343da3fe5 (diff)
downloadqt-creator-38292de68a707eeaa2e5ece5a16084c00f8e4bef.tar.gz
BareMetal: Fix auto detection of SDCC toolchain on Windows
The SDCC toolchain package can be provided as 32-bit or as 64-bit installer. If the SDCC 64-bit package will be installed on the 32-bit Windows, then it will not be found in the system registry, because we use the QSettings::NativeFormat. So, we need to check the data for the 32-bit and 64-bit registry sequentially. Change-Id: I1e7711bdde173eff21a7ba84f221d505a21709ca Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/plugins/baremetal/sdcctoolchain.cpp48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/plugins/baremetal/sdcctoolchain.cpp b/src/plugins/baremetal/sdcctoolchain.cpp
index b839a68fe8..a292a575d9 100644
--- a/src/plugins/baremetal/sdcctoolchain.cpp
+++ b/src/plugins/baremetal/sdcctoolchain.cpp
@@ -395,27 +395,41 @@ QList<ToolChain *> SdccToolChainFactory::autoDetect(const QList<ToolChain *> &al
if (Utils::HostOsInfo::isWindowsHost()) {
-#ifdef Q_OS_WIN64
- static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\SDCC";
-#else
- static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\SDCC";
-#endif
-
- QSettings registry(kRegistryNode, QSettings::NativeFormat);
- QString compilerPath = registry.value("Default").toString();
- if (!compilerPath.isEmpty()) {
+ // Tries to detect the candidate from the 32-bit
+ // or 64-bit system registry format.
+ auto probeCandidate = [](QSettings::Format format) {
+ QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\SDCC",
+ format);
+ QString compilerPath = registry.value("Default").toString();
+ if (compilerPath.isEmpty())
+ return Candidate{};
// Build full compiler path.
compilerPath += "\\bin\\sdcc.exe";
const FilePath fn = FilePath::fromString(
QFileInfo(compilerPath).absoluteFilePath());
- if (compilerExists(fn)) {
- // Build compiler version.
- const QString version = QString("%1.%2.%3").arg(
- registry.value("VersionMajor").toString(),
- registry.value("VersionMinor").toString(),
- registry.value("VersionRevision").toString());
- candidates.push_back({fn, version});
- }
+ if (!compilerExists(fn))
+ return Candidate{};
+ // Build compiler version.
+ const QString version = QString("%1.%2.%3").arg(
+ registry.value("VersionMajor").toString(),
+ registry.value("VersionMinor").toString(),
+ registry.value("VersionRevision").toString());
+ return Candidate{fn, version};
+ };
+
+ const QSettings::Format allowedFormats[] = {
+ QSettings::NativeFormat,
+#ifdef Q_OS_WIN
+ QSettings::Registry32Format,
+ QSettings::Registry64Format
+#endif
+ };
+
+ for (const QSettings::Format format : allowedFormats) {
+ const auto candidate = probeCandidate(format);
+ if (candidate.compilerPath.isEmpty() || candidates.contains(candidate))
+ continue;
+ candidates.push_back(candidate);
}
}