McuSupport: fix toolchain naming difference between windows and linux

Toolchain naming convention is different in windows "mingw" than in
linux "gcc". That caused the logic to fail on windows and prompt the
user to remove a kit of an existing target.

Task-number: QTCREATORBUG-29003
Change-Id: Ib99a9b38fec30b9a6826874f1acd0bb2f8615e1e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Sivert Krøvel <sivert.krovel@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Karim Abdelrahman
2023-04-05 10:50:33 +03:00
committed by Sivert Krøvel
parent de6ed91c9c
commit b083a4d55e

View File

@@ -289,8 +289,7 @@ public:
cMakeToolchainFile.toString().toUtf8());
if (!cMakeToolchainFile.exists()) {
printMessage(
Tr::tr(
"Warning for target %1: missing CMake toolchain file expected at %2.")
Tr::tr("Warning for target %1: missing CMake toolchain file expected at %2.")
.arg(generateKitNameFromTarget(mcuTarget),
cMakeToolchainFile.toUserOutput()),
false);
@@ -301,8 +300,7 @@ public:
"/lib/cmake/Qul/QulGenerators.cmake");
configMap.insert("QUL_GENERATORS", generatorsPath.toString().toUtf8());
if (!generatorsPath.exists()) {
printMessage(Tr::tr(
"Warning for target %1: missing QulGenerators expected at %2.")
printMessage(Tr::tr("Warning for target %1: missing QulGenerators expected at %2.")
.arg(generateKitNameFromTarget(mcuTarget),
generatorsPath.toUserOutput()),
false);
@@ -510,8 +508,7 @@ void createAutomaticKits(const SettingsHandler::Ptr &settingsHandler)
}
case McuAbstractPackage::Status::EmptyPath: {
printMessage(
Tr::tr(
"Missing %1. Add the path in Edit > Preferences > Devices > MCU.")
Tr::tr("Missing %1. Add the path in Edit > Preferences > Devices > MCU.")
.arg(qtForMCUsPackage->detectionPath().toUserOutput()),
true);
return;
@@ -524,8 +521,7 @@ void createAutomaticKits(const SettingsHandler::Ptr &settingsHandler)
if (CMakeProjectManager::CMakeToolManager::cmakeTools().isEmpty()) {
printMessage(
Tr::tr(
"No CMake tool was detected. Add a CMake tool in Edit > Preferences > "
Tr::tr("No CMake tool was detected. Add a CMake tool in Edit > Preferences > "
"Kits > CMake."),
true);
return;
@@ -744,11 +740,17 @@ static bool anyKitDescriptionFileExists(const FilePaths &jsonFiles,
const QRegularExpressionMatch match = re.match(jsonFile.fileName());
QStringList kitsPropertiesFromFileName;
if (match.hasMatch()) {
const QString toolchain = match.captured(1).replace(
"gnu", "gcc"); // kitFileName contains gnu while profiles.xml contains gcc
QString toolchain = match.captured(1);
const QString vendor = match.captured(2);
const QString device = match.captured(3);
/*
* file name of kit starts with "gnu" while in profiles.xml name of
* toolchain is "gcc" on Linux and "mingw" on Windows
*/
toolchain = HostOsInfo::isLinuxHost() ? toolchain.replace("gnu", "gcc")
: toolchain.replace("gnu", "mingw");
kitsPropertiesFromFileName << toolchain << vendor << device;
}