forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -395,27 +395,41 @@ QList<ToolChain *> SdccToolChainFactory::autoDetect(const QList<ToolChain *> &al
|
|||||||
|
|
||||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||||
|
|
||||||
#ifdef Q_OS_WIN64
|
// Tries to detect the candidate from the 32-bit
|
||||||
static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\SDCC";
|
// or 64-bit system registry format.
|
||||||
#else
|
auto probeCandidate = [](QSettings::Format format) {
|
||||||
static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\SDCC";
|
QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\SDCC",
|
||||||
#endif
|
format);
|
||||||
|
QString compilerPath = registry.value("Default").toString();
|
||||||
QSettings registry(kRegistryNode, QSettings::NativeFormat);
|
if (compilerPath.isEmpty())
|
||||||
QString compilerPath = registry.value("Default").toString();
|
return Candidate{};
|
||||||
if (!compilerPath.isEmpty()) {
|
|
||||||
// Build full compiler path.
|
// Build full compiler path.
|
||||||
compilerPath += "\\bin\\sdcc.exe";
|
compilerPath += "\\bin\\sdcc.exe";
|
||||||
const FilePath fn = FilePath::fromString(
|
const FilePath fn = FilePath::fromString(
|
||||||
QFileInfo(compilerPath).absoluteFilePath());
|
QFileInfo(compilerPath).absoluteFilePath());
|
||||||
if (compilerExists(fn)) {
|
if (!compilerExists(fn))
|
||||||
// Build compiler version.
|
return Candidate{};
|
||||||
const QString version = QString("%1.%2.%3").arg(
|
// Build compiler version.
|
||||||
registry.value("VersionMajor").toString(),
|
const QString version = QString("%1.%2.%3").arg(
|
||||||
registry.value("VersionMinor").toString(),
|
registry.value("VersionMajor").toString(),
|
||||||
registry.value("VersionRevision").toString());
|
registry.value("VersionMinor").toString(),
|
||||||
candidates.push_back({fn, version});
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user