From 185f03cb339dc7b88f5808e95b4297f4bd4882f2 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 23 Apr 2020 23:30:40 +0200 Subject: [PATCH] McuSupport: Identify existing Kits for MCU Targets via meta data ... instead of just by kit name. Although the Kit name is quite verbose, it is missing some of the information needed to realiably identify Kits for MCU Targets. Use the Kit meta data for that, instead. This adds the color depth to the kit meta data. Change-Id: I39bc9a681a423a4309290b0f47298dbcb83b2e54 Reviewed-by: Eike Ziller --- src/plugins/mcusupport/mcusupportconstants.h | 2 ++ src/plugins/mcusupport/mcusupportoptions.cpp | 29 +++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/plugins/mcusupport/mcusupportconstants.h b/src/plugins/mcusupport/mcusupportconstants.h index 17fd68f181f..30d28f44df4 100644 --- a/src/plugins/mcusupport/mcusupportconstants.h +++ b/src/plugins/mcusupport/mcusupportconstants.h @@ -32,10 +32,12 @@ const char DEVICE_TYPE[] = "McuSupport.DeviceType"; const char DEVICE_ID[] = "McuSupport.Device"; const char RUNCONFIGURATION[] = "McuSupport.RunConfiguration"; const char SETTINGS_ID[] = "CC.McuSupport.Configuration"; + const char KIT_MCUTARGET_VENDOR_KEY[] = "McuSupport.McuTargetVendor"; const char KIT_MCUTARGET_MODEL_KEY[] = "McuSupport.McuTargetModel"; const char KIT_MCUTARGET_SDKVERSION_KEY[] = "McuSupport.McuTargetSdkVersion"; const char KIT_MCUTARGET_KITVERSION_KEY[] = "McuSupport.McuTargetKitVersion"; +const char KIT_MCUTARGET_COLORDEPTH_KEY[] = "McuSupport.McuTargetColorDepth"; const char SETTINGS_GROUP[] = "McuSupport"; const char SETTINGS_KEY_PACKAGE_PREFIX[] = "Package_"; diff --git a/src/plugins/mcusupport/mcusupportoptions.cpp b/src/plugins/mcusupport/mcusupportoptions.cpp index 15936c316ff..d9aac20374a 100644 --- a/src/plugins/mcusupport/mcusupportoptions.cpp +++ b/src/plugins/mcusupport/mcusupportoptions.cpp @@ -61,7 +61,7 @@ namespace McuSupport { namespace Internal { -static const int KIT_VERSION = 1; // Bumps up whenever details in Kit creation change +static const int KIT_VERSION = 2; // Bumps up whenever details in Kit creation change static QString packagePathFromSettings(const QString &settingsKey, const QString &defaultPath = {}) { @@ -469,17 +469,18 @@ static void setKitProperties(const QString &kitName, ProjectExplorer::Kit *k, const McuTarget* mcuTarget) { using namespace ProjectExplorer; + using namespace Constants; k->setUnexpandedDisplayName(kitName); - k->setValue(Constants::KIT_MCUTARGET_VENDOR_KEY, mcuTarget->vendor()); - k->setValue(Constants::KIT_MCUTARGET_MODEL_KEY, mcuTarget->qulPlatform()); - k->setValue(Constants::KIT_MCUTARGET_SDKVERSION_KEY, - McuSupportOptions::supportedQulVersion().toString()); - k->setValue(Constants::KIT_MCUTARGET_KITVERSION_KEY, KIT_VERSION); + k->setValue(KIT_MCUTARGET_VENDOR_KEY, mcuTarget->vendor()); + k->setValue(KIT_MCUTARGET_MODEL_KEY, mcuTarget->qulPlatform()); + k->setValue(KIT_MCUTARGET_COLORDEPTH_KEY, mcuTarget->colorDepth()); + k->setValue(KIT_MCUTARGET_SDKVERSION_KEY, McuSupportOptions::supportedQulVersion().toString()); + k->setValue(KIT_MCUTARGET_KITVERSION_KEY, KIT_VERSION); k->setAutoDetected(true); k->makeSticky(); if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop) - k->setDeviceTypeForIcon(Constants::DEVICE_TYPE); + k->setDeviceTypeForIcon(DEVICE_TYPE); QSet irrelevant = { SysRootKitAspect::id(), QtSupport::QtKitAspect::id() @@ -609,9 +610,17 @@ QString McuSupportOptions::kitName(const McuTarget *mcuTarget) QList McuSupportOptions::existingKits(const McuTarget *mcuTarget) { using namespace ProjectExplorer; - const QString mcuTargetKitName = kitName(mcuTarget); - return Utils::filtered(KitManager::kits(), [&mcuTargetKitName](Kit *kit) { - return kit->isAutoDetected() && kit->unexpandedDisplayName() == mcuTargetKitName; + using namespace Constants; + return Utils::filtered(KitManager::kits(), [mcuTarget](Kit *kit) { + return kit->isAutoDetected() + && kit->value(KIT_MCUTARGET_KITVERSION_KEY) == KIT_VERSION + && kit->value(KIT_MCUTARGET_SDKVERSION_KEY) == + McuSupportOptions::supportedQulVersion().toString() + && (!mcuTarget || ( + kit->value(KIT_MCUTARGET_VENDOR_KEY) == mcuTarget->vendor() + && kit->value(KIT_MCUTARGET_MODEL_KEY) == mcuTarget->qulPlatform() + && kit->value(KIT_MCUTARGET_COLORDEPTH_KEY) == mcuTarget->colorDepth() + )); }); }