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 <eike.ziller@qt.io>
This commit is contained in:
Alessandro Portale
2020-04-23 23:30:40 +02:00
parent fc94174bf7
commit 185f03cb33
2 changed files with 21 additions and 10 deletions

View File

@@ -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_";

View File

@@ -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<Core::Id> irrelevant = {
SysRootKitAspect::id(),
QtSupport::QtKitAspect::id()
@@ -609,9 +610,17 @@ QString McuSupportOptions::kitName(const McuTarget *mcuTarget)
QList<ProjectExplorer::Kit *> 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()
));
});
}