forked from qt-creator/qt-creator
BareMetal: Fix parsing of software pack description files for UVSC provider
A target device info locates in the *.pdsc files provided by the device description packages which are installed into the Keil MDK-ARM instance. We parse this files to provide possibility for the user to choose a specific MCU target for debugging. Previous parsing implementation was complicated and did not take in account the specific *.pdsc format features: * https://www.keil.com/pack/doc/CMSIS/Pack/html/packFormat.html It turns out that the following entries as 'family', 'sub-family', 'device', and 'device-variant' may contain an attributes with the same names. So, we can simplify creation of an items, use only one base implementation for all items. Besides, a new implementation simplifies parsing and for other *.pdsc files (e.g. non only for STMicroelectronics). Tested with Keil MDK-ARM v5.23 using STM32 NUCLEO-F767ZI board. Change-Id: Idd51b8fa3e36a7896254b4cb8aa4c1287b9f0df5 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -54,16 +54,9 @@ static QString buildToolsetNumber(int number)
|
|||||||
return QStringLiteral("0x%1").arg(QString::number(number, 16));
|
return QStringLiteral("0x%1").arg(QString::number(number, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString buildVendor(const QString &vendor)
|
|
||||||
{
|
|
||||||
// Remove the colon symbol.
|
|
||||||
const int colonIndex = vendor.lastIndexOf(':');
|
|
||||||
return vendor.mid(0, colonIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString buildPackageId(const DeviceSelection::Package &package)
|
static QString buildPackageId(const DeviceSelection::Package &package)
|
||||||
{
|
{
|
||||||
return QStringLiteral("%1.%2.%3").arg(package.vendor, package.name, package.version);
|
return QStringLiteral("%1.%2.%3").arg(package.vendorName, package.name, package.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString buildCpu(const DeviceSelection &device)
|
static QString buildCpu(const DeviceSelection &device)
|
||||||
@@ -139,8 +132,7 @@ Project::Project(const UvscServerProvider *provider, DebuggerRunTool *runTool)
|
|||||||
const auto targetCommonOption = targetOption->appendPropertyGroup("TargetCommonOption");
|
const auto targetCommonOption = targetOption->appendPropertyGroup("TargetCommonOption");
|
||||||
const DeviceSelection device = provider->deviceSelection();
|
const DeviceSelection device = provider->deviceSelection();
|
||||||
targetCommonOption->appendProperty("Device", device.name);
|
targetCommonOption->appendProperty("Device", device.name);
|
||||||
const QString vendor = buildVendor(device.vendor);
|
targetCommonOption->appendProperty("Vendor", device.vendorName);
|
||||||
targetCommonOption->appendProperty("Vendor", vendor);
|
|
||||||
const QString packageId = buildPackageId(device.package);
|
const QString packageId = buildPackageId(device.package);
|
||||||
targetCommonOption->appendProperty("PackID", packageId);
|
targetCommonOption->appendProperty("PackID", packageId);
|
||||||
targetCommonOption->appendProperty("PackURL", device.package.url);
|
targetCommonOption->appendProperty("PackURL", device.package.url);
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "uvtargetdevicemodel.h"
|
#include "uvtargetdevicemodel.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
@@ -81,14 +83,19 @@ static QStringList findKeilPackFiles(const QString &path)
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fillElementProperty(QXmlStreamReader &in, QString &prop)
|
||||||
|
{
|
||||||
|
prop = in.readElementText().trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
static void fillCpu(QXmlStreamReader &in, DeviceSelection::Cpu &cpu)
|
static void fillCpu(QXmlStreamReader &in, DeviceSelection::Cpu &cpu)
|
||||||
{
|
{
|
||||||
const QXmlStreamAttributes attrs = in.attributes();
|
const QXmlStreamAttributes attrs = in.attributes();
|
||||||
in.skipCurrentElement();
|
in.skipCurrentElement();
|
||||||
cpu.core = attrs.hasAttribute("Dcore") ? attrs.value("Dcore").toString() : cpu.core;
|
cpu.core = attrs.value("Dcore").toString();
|
||||||
cpu.clock = attrs.hasAttribute("Dclock") ? attrs.value("Dclock").toString() : cpu.clock;
|
cpu.clock = attrs.value("Dclock").toString();
|
||||||
cpu.fpu = attrs.hasAttribute("Dfpu") ? attrs.value("Dfpu").toString() : cpu.fpu;
|
cpu.fpu = attrs.value("Dfpu").toString();
|
||||||
cpu.mpu = attrs.hasAttribute("Dmpu") ? attrs.value("Dmpu").toString() : cpu.mpu;
|
cpu.mpu = attrs.value("Dmpu").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fillMemories(QXmlStreamReader &in, DeviceSelection::Memories &memories)
|
static void fillMemories(QXmlStreamReader &in, DeviceSelection::Memories &memories)
|
||||||
@@ -113,140 +120,67 @@ static void fillAlgorithms(QXmlStreamReader &in, DeviceSelection::Algorithms &al
|
|||||||
algorithms.push_back(algorithm);
|
algorithms.push_back(algorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fillVendor(const QString &vendor, QString &vendorName, QString &vendorId)
|
||||||
|
{
|
||||||
|
const auto colonIndex = vendor.lastIndexOf(':');
|
||||||
|
vendorName = vendor.mid(0, colonIndex);
|
||||||
|
if (colonIndex != -1)
|
||||||
|
vendorId = vendor.mid(colonIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fillVendor(QXmlStreamReader &in, QString &vendorName, QString &vendorId)
|
||||||
|
{
|
||||||
|
QString vendor;
|
||||||
|
fillElementProperty(in, vendor);
|
||||||
|
fillVendor(vendor, vendorName, vendorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fillSvd(QXmlStreamReader &in, QString &svd)
|
||||||
|
{
|
||||||
|
const QXmlStreamAttributes attrs = in.attributes();
|
||||||
|
in.skipCurrentElement();
|
||||||
|
svd = attrs.value("svd").toString();
|
||||||
|
}
|
||||||
|
|
||||||
// DeviceSelectionItem
|
// DeviceSelectionItem
|
||||||
|
|
||||||
class DeviceSelectionItem : public TreeItem
|
class DeviceSelectionItem final : public TreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class Type { Unknown, Package, Family, SubFamily, Device, DeviceVariant };
|
enum Column { NameColumn, VersionColumn, VendorNameColumn };
|
||||||
enum Column { NameColumn, VersionColumn, VendorColumn };
|
explicit DeviceSelectionItem()
|
||||||
explicit DeviceSelectionItem(Type type = Type::Unknown)
|
|
||||||
: m_type(type)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QVariant data(int column, int role) const override
|
|
||||||
{
|
|
||||||
if (role == Qt::DisplayRole && column == NameColumn)
|
|
||||||
return m_name;
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::ItemFlags flags(int column) const override
|
|
||||||
{
|
|
||||||
Q_UNUSED(column)
|
|
||||||
return Qt::ItemIsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceSelectionItem *parentPackItem() const
|
|
||||||
{
|
|
||||||
return static_cast<DeviceSelectionItem *>(parent());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString m_name;
|
|
||||||
const Type m_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// PackageItem
|
|
||||||
|
|
||||||
class PackageItem final : public DeviceSelectionItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit PackageItem(const QString &file)
|
|
||||||
: DeviceSelectionItem(Type::Package), m_file(file), m_version(extractPackVersion(file))
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QVariant data(int column, int role) const final
|
QVariant data(int column, int role) const final
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if (column == NameColumn)
|
if (column == NameColumn)
|
||||||
return m_name;
|
return name;
|
||||||
else if (column == VersionColumn)
|
else if (column == VersionColumn)
|
||||||
return m_version;
|
return version;
|
||||||
else if (column == VendorColumn)
|
else if (column == VendorNameColumn)
|
||||||
return m_vendor;
|
return vendorName;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString m_file;
|
|
||||||
QString m_version;
|
|
||||||
QString m_desc;
|
|
||||||
QString m_vendor;
|
|
||||||
QString m_url;
|
|
||||||
};
|
|
||||||
|
|
||||||
// FamilyItem
|
|
||||||
|
|
||||||
class FamilyItem final : public DeviceSelectionItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit FamilyItem()
|
|
||||||
: DeviceSelectionItem(Type::Family)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QVariant data(int column, int role) const final
|
|
||||||
{
|
|
||||||
if (role == Qt::DisplayRole) {
|
|
||||||
if (column == NameColumn) {
|
|
||||||
return m_name;
|
|
||||||
} else if (column == VendorColumn) {
|
|
||||||
const auto colonIndex = m_vendor.lastIndexOf(':');
|
|
||||||
return m_vendor.mid(0, colonIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
QString m_desc;
|
|
||||||
QString m_vendor;
|
|
||||||
};
|
|
||||||
|
|
||||||
// SubFamilyItem
|
|
||||||
|
|
||||||
class SubFamilyItem final : public DeviceSelectionItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit SubFamilyItem()
|
|
||||||
: DeviceSelectionItem(Type::SubFamily)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QString m_svd;
|
|
||||||
};
|
|
||||||
|
|
||||||
// DeviceItem
|
|
||||||
|
|
||||||
class DeviceItem final : public DeviceSelectionItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit DeviceItem()
|
|
||||||
: DeviceSelectionItem(Type::Device)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Qt::ItemFlags flags(int column) const final
|
Qt::ItemFlags flags(int column) const final
|
||||||
{
|
{
|
||||||
Q_UNUSED(column)
|
Q_UNUSED(column)
|
||||||
return hasChildren() ? Qt::ItemIsEnabled : (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
return hasChildren() ? Qt::ItemIsEnabled : (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceSelection::Cpu m_cpu;
|
QString desc;
|
||||||
DeviceSelection::Memories m_memories;
|
QString fullPath;
|
||||||
DeviceSelection::Algorithms m_algorithms;
|
QString name;
|
||||||
};
|
QString svd;
|
||||||
|
QString url;
|
||||||
// DeviceVariantItem
|
QString vendorId;
|
||||||
|
QString vendorName;
|
||||||
class DeviceVariantItem final : public DeviceSelectionItem
|
QString version;
|
||||||
{
|
DeviceSelection::Algorithms algorithms;
|
||||||
public:
|
DeviceSelection::Cpu cpu;
|
||||||
explicit DeviceVariantItem()
|
DeviceSelection::Memories memories;
|
||||||
: DeviceSelectionItem(Type::DeviceVariant)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Qt::ItemFlags flags(int column) const final
|
|
||||||
{
|
|
||||||
Q_UNUSED(column)
|
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// DeviceSelectionModel
|
// DeviceSelectionModel
|
||||||
@@ -298,20 +232,23 @@ void DeviceSelectionModel::parsePackage(const QString &packageFile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSelectionModel::parsePackage(QXmlStreamReader &in, const QString &file)
|
void DeviceSelectionModel::parsePackage(QXmlStreamReader &in, const QString &packageFile)
|
||||||
{
|
{
|
||||||
const auto child = new PackageItem(file);
|
// Create and fill the 'package' item.
|
||||||
|
const auto child = new DeviceSelectionItem;
|
||||||
rootItem()->appendChild(child);
|
rootItem()->appendChild(child);
|
||||||
|
child->fullPath = packageFile;
|
||||||
|
child->version = extractPackVersion(packageFile);
|
||||||
while (in.readNextStartElement()) {
|
while (in.readNextStartElement()) {
|
||||||
const QStringRef elementName = in.name();
|
const QStringRef elementName = in.name();
|
||||||
if (elementName == "name") {
|
if (elementName == "name") {
|
||||||
child->m_name = in.readElementText().trimmed();
|
fillElementProperty(in, child->name);
|
||||||
} else if (elementName == "description") {
|
} else if (elementName == "description") {
|
||||||
child->m_desc = in.readElementText().trimmed();
|
fillElementProperty(in, child->desc);
|
||||||
} else if (elementName == "vendor") {
|
} else if (elementName == "vendor") {
|
||||||
child->m_vendor = in.readElementText().trimmed();
|
fillVendor(in, child->vendorName, child->vendorId);
|
||||||
} else if (elementName == "url") {
|
} else if (elementName == "url") {
|
||||||
child->m_url = in.readElementText().trimmed();
|
fillElementProperty(in, child->url);
|
||||||
} else if (elementName == "devices") {
|
} else if (elementName == "devices") {
|
||||||
while (in.readNextStartElement()) {
|
while (in.readNextStartElement()) {
|
||||||
const QStringRef elementName = in.name();
|
const QStringRef elementName = in.name();
|
||||||
@@ -328,90 +265,93 @@ void DeviceSelectionModel::parsePackage(QXmlStreamReader &in, const QString &fil
|
|||||||
|
|
||||||
void DeviceSelectionModel::parseFamily(QXmlStreamReader &in, DeviceSelectionItem *parent)
|
void DeviceSelectionModel::parseFamily(QXmlStreamReader &in, DeviceSelectionItem *parent)
|
||||||
{
|
{
|
||||||
const auto child = new FamilyItem;
|
// Create and fill the 'family' item.
|
||||||
|
const auto child = new DeviceSelectionItem;
|
||||||
parent->appendChild(child);
|
parent->appendChild(child);
|
||||||
const QXmlStreamAttributes attrs = in.attributes();
|
const QXmlStreamAttributes attrs = in.attributes();
|
||||||
child->m_name = attrs.value("Dfamily").toString();
|
child->name = attrs.value("Dfamily").toString();
|
||||||
child->m_vendor = attrs.value("Dvendor").toString();
|
fillVendor(attrs.value("Dvendor").toString(), child->vendorName, child->vendorId);
|
||||||
DeviceSelection::Cpu cpu;
|
|
||||||
DeviceSelection::Memories memories;
|
|
||||||
while (in.readNextStartElement()) {
|
while (in.readNextStartElement()) {
|
||||||
const QStringRef elementName = in.name();
|
const QStringRef elementName = in.name();
|
||||||
if (elementName == "processor") {
|
if (elementName == "processor") {
|
||||||
fillCpu(in, cpu);
|
fillCpu(in, child->cpu);
|
||||||
} else if (elementName == "memory") {
|
} else if (elementName == "memory") {
|
||||||
fillMemories(in, memories);
|
fillMemories(in, child->memories);
|
||||||
} else if (elementName == "description") {
|
} else if (elementName == "description") {
|
||||||
child->m_desc = in.readElementText().trimmed();
|
fillElementProperty(in, child->desc);
|
||||||
} else if (elementName == "subFamily") {
|
} else if (elementName == "subFamily") {
|
||||||
parseSubFamily(in, child, cpu);
|
parseSubFamily(in, child);
|
||||||
} else if (elementName == "device") {
|
} else if (elementName == "device") {
|
||||||
parseDevice(in, child, cpu, memories);
|
parseDevice(in, child);
|
||||||
} else {
|
} else {
|
||||||
in.skipCurrentElement();
|
in.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSelectionModel::parseSubFamily(QXmlStreamReader &in, DeviceSelectionItem *parent,
|
void DeviceSelectionModel::parseSubFamily(QXmlStreamReader &in, DeviceSelectionItem *parent)
|
||||||
DeviceSelection::Cpu &cpu)
|
|
||||||
{
|
{
|
||||||
const auto child = new SubFamilyItem;
|
// Create and fill the 'sub-family' item.
|
||||||
|
const auto child = new DeviceSelectionItem;
|
||||||
parent->appendChild(child);
|
parent->appendChild(child);
|
||||||
const QXmlStreamAttributes attrs = in.attributes();
|
const QXmlStreamAttributes attrs = in.attributes();
|
||||||
child->m_name = attrs.value("DsubFamily").toString();
|
child->name = attrs.value("DsubFamily").toString();
|
||||||
while (in.readNextStartElement()) {
|
while (in.readNextStartElement()) {
|
||||||
const QStringRef elementName = in.name();
|
const QStringRef elementName = in.name();
|
||||||
if (elementName == "processor") {
|
if (elementName == "processor") {
|
||||||
fillCpu(in, cpu);
|
fillCpu(in, child->cpu);
|
||||||
} else if (elementName == "debug") {
|
} else if (elementName == "debug") {
|
||||||
const QXmlStreamAttributes attrs = in.attributes();
|
fillSvd(in, child->svd);
|
||||||
in.skipCurrentElement();
|
|
||||||
child->m_svd = attrs.value("svd").toString();
|
|
||||||
} else if (elementName == "device") {
|
} else if (elementName == "device") {
|
||||||
DeviceSelection::Memories memories;
|
parseDevice(in, child);
|
||||||
parseDevice(in, child, cpu, memories);
|
|
||||||
} else {
|
} else {
|
||||||
in.skipCurrentElement();
|
in.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSelectionModel::parseDevice(QXmlStreamReader &in, DeviceSelectionItem *parent,
|
void DeviceSelectionModel::parseDevice(QXmlStreamReader &in, DeviceSelectionItem *parent)
|
||||||
DeviceSelection::Cpu &cpu,
|
|
||||||
DeviceSelection::Memories &memories)
|
|
||||||
{
|
{
|
||||||
const auto child = new DeviceItem;
|
// Create and fill the 'device' item.
|
||||||
|
const auto child = new DeviceSelectionItem;
|
||||||
parent->appendChild(child);
|
parent->appendChild(child);
|
||||||
const QXmlStreamAttributes attrs = in.attributes();
|
const QXmlStreamAttributes attrs = in.attributes();
|
||||||
child->m_name = attrs.value("Dname").toString();
|
child->name = attrs.value("Dname").toString();
|
||||||
DeviceSelection::Algorithms algorithms;
|
|
||||||
while (in.readNextStartElement()) {
|
while (in.readNextStartElement()) {
|
||||||
const QStringRef elementName = in.name();
|
const QStringRef elementName = in.name();
|
||||||
if (elementName == "processor") {
|
if (elementName == "processor") {
|
||||||
fillCpu(in, cpu);
|
fillCpu(in, child->cpu);
|
||||||
} else if (elementName == "memory") {
|
} else if (elementName == "memory") {
|
||||||
fillMemories(in, memories);
|
fillMemories(in, child->memories);
|
||||||
} else if (elementName == "algorithm") {
|
} else if (elementName == "algorithm") {
|
||||||
fillAlgorithms(in, algorithms);
|
fillAlgorithms(in, child->algorithms);
|
||||||
} else if (elementName == "variant") {
|
} else if (elementName == "variant") {
|
||||||
parseDeviceVariant(in, child);
|
parseDeviceVariant(in, child);
|
||||||
} else {
|
} else {
|
||||||
in.skipCurrentElement();
|
in.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child->m_cpu = cpu;
|
|
||||||
child->m_memories = memories;
|
|
||||||
child->m_algorithms = algorithms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSelectionModel::parseDeviceVariant(QXmlStreamReader &in, DeviceSelectionItem *parent)
|
void DeviceSelectionModel::parseDeviceVariant(QXmlStreamReader &in, DeviceSelectionItem *parent)
|
||||||
{
|
{
|
||||||
const auto child = new DeviceVariantItem;
|
// Create and fill the 'device-variant' item.
|
||||||
|
const auto child = new DeviceSelectionItem;
|
||||||
parent->appendChild(child);
|
parent->appendChild(child);
|
||||||
const QXmlStreamAttributes attrs = in.attributes();
|
const QXmlStreamAttributes attrs = in.attributes();
|
||||||
|
child->name = attrs.value("Dvariant").toString();
|
||||||
|
while (in.readNextStartElement()) {
|
||||||
|
const QStringRef elementName = in.name();
|
||||||
|
if (elementName == "processor") {
|
||||||
|
fillCpu(in, child->cpu);
|
||||||
|
} else if (elementName == "memory") {
|
||||||
|
fillMemories(in, child->memories);
|
||||||
|
} else if (elementName == "algorithm") {
|
||||||
|
fillAlgorithms(in, child->algorithms);
|
||||||
|
} else {
|
||||||
in.skipCurrentElement();
|
in.skipCurrentElement();
|
||||||
child->m_name = attrs.value("Dvariant").toString();
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeviceSelectionView
|
// DeviceSelectionView
|
||||||
@@ -433,70 +373,87 @@ void DeviceSelectionView::currentChanged(const QModelIndex ¤t, const QMode
|
|||||||
if (!selectionModel)
|
if (!selectionModel)
|
||||||
return;
|
return;
|
||||||
const DeviceSelectionItem *item = selectionModel->itemForIndex(current);
|
const DeviceSelectionItem *item = selectionModel->itemForIndex(current);
|
||||||
if (isValidItem(item)) {
|
if (!item || item->hasChildren())
|
||||||
|
return; // We need only in a last 'device' or 'device-variant' item!
|
||||||
|
|
||||||
const auto selection = buildSelection(item);
|
const auto selection = buildSelection(item);
|
||||||
if (!selection.name.isEmpty())
|
if (!selection.name.isEmpty())
|
||||||
emit deviceSelected(selection);
|
emit deviceSelected(selection);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool DeviceSelectionView::isValidItem(const DeviceSelectionItem *item) const
|
|
||||||
{
|
|
||||||
if (!item)
|
|
||||||
return false;
|
|
||||||
if (item->m_type == DeviceSelectionItem::Type::DeviceVariant)
|
|
||||||
return true;
|
|
||||||
if (item->m_type == DeviceSelectionItem::Type::Device && !item->hasChildren())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceSelection DeviceSelectionView::buildSelection(const DeviceSelectionItem *item) const
|
DeviceSelection DeviceSelectionView::buildSelection(const DeviceSelectionItem *item) const
|
||||||
{
|
{
|
||||||
DeviceSelection selection;
|
DeviceSelection selection;
|
||||||
// We need to iterate from the lower 'Device|DeviceVariant' items to
|
// We need to iterate from the lower 'device' or 'device-variant' item to
|
||||||
// the upper 'Package' item to fill whole information.
|
// the upper 'package' item to fill a whole information.
|
||||||
|
DeviceSelection::Algorithms &algs = selection.algorithms;
|
||||||
|
DeviceSelection::Cpu &cpu = selection.cpu;
|
||||||
|
DeviceSelection::Memories &mems = selection.memories;
|
||||||
|
DeviceSelection::Package &pkg = selection.package;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
switch (item->m_type) {
|
if (selection.name.isEmpty())
|
||||||
case DeviceSelectionItem::Type::DeviceVariant:
|
selection.name = item->name;
|
||||||
selection.name = item->m_name;
|
else if (selection.subfamily.isEmpty())
|
||||||
break;
|
selection.subfamily = item->name;
|
||||||
case DeviceSelectionItem::Type::Device: {
|
else if (selection.family.isEmpty())
|
||||||
const auto deviceItem = static_cast<const DeviceItem *>(item);
|
selection.family = item->name;
|
||||||
if (!deviceItem->hasChildren())
|
else if (pkg.name.isEmpty())
|
||||||
selection.name = item->m_name;
|
pkg.name = item->name;
|
||||||
selection.cpu = deviceItem->m_cpu;
|
|
||||||
selection.memories = deviceItem->m_memories;
|
if (selection.desc.isEmpty())
|
||||||
selection.algorithms = deviceItem->m_algorithms;
|
selection.desc = item->desc;
|
||||||
|
else if (pkg.desc.isEmpty())
|
||||||
|
pkg.desc = item->desc;
|
||||||
|
|
||||||
|
if (selection.vendorId.isEmpty())
|
||||||
|
selection.vendorId = item->vendorId;
|
||||||
|
else if (pkg.vendorId.isEmpty())
|
||||||
|
pkg.vendorId = item->vendorId;
|
||||||
|
|
||||||
|
if (selection.vendorName.isEmpty())
|
||||||
|
selection.vendorName = item->vendorName;
|
||||||
|
else if (pkg.vendorName.isEmpty())
|
||||||
|
pkg.vendorName = item->vendorName;
|
||||||
|
|
||||||
|
if (selection.svd.isEmpty())
|
||||||
|
selection.svd = item->svd;
|
||||||
|
|
||||||
|
if (cpu.clock.isEmpty())
|
||||||
|
cpu.clock = item->cpu.clock;
|
||||||
|
if (cpu.core.isEmpty())
|
||||||
|
cpu.core = item->cpu.core;
|
||||||
|
if (cpu.fpu.isEmpty())
|
||||||
|
cpu.fpu = item->cpu.fpu;
|
||||||
|
if (cpu.mpu.isEmpty())
|
||||||
|
cpu.mpu = item->cpu.mpu;
|
||||||
|
|
||||||
|
if (pkg.file.isEmpty())
|
||||||
|
pkg.file = item->fullPath;
|
||||||
|
if (pkg.url.isEmpty())
|
||||||
|
pkg.url = item->url;
|
||||||
|
if (pkg.version.isEmpty())
|
||||||
|
pkg.version = item->version;
|
||||||
|
|
||||||
|
// Add only new flash algorithms.
|
||||||
|
for (const DeviceSelection::Algorithm &newAlg : item->algorithms) {
|
||||||
|
const bool contains = Utils::contains(algs, [&newAlg](const DeviceSelection::Algorithm &existAlg) {
|
||||||
|
return newAlg.path == existAlg.path;
|
||||||
|
});
|
||||||
|
if (!contains)
|
||||||
|
algs.push_back(newAlg);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case DeviceSelectionItem::Type::SubFamily: {
|
// Add only new memory regions.
|
||||||
const auto subFamilyItem = static_cast<const SubFamilyItem *>(item);
|
for (const DeviceSelection::Memory &newMem : item->memories) {
|
||||||
selection.subfamily = subFamilyItem->m_name;
|
const bool contains = Utils::contains(mems, [&newMem](const DeviceSelection::Memory &existMem) {
|
||||||
selection.svd = subFamilyItem->m_svd;
|
return newMem.id == existMem.id;
|
||||||
|
});
|
||||||
|
if (!contains)
|
||||||
|
mems.push_back(newMem);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case DeviceSelectionItem::Type::Family: {
|
} while ((item->level() > 1) && (item = static_cast<const DeviceSelectionItem *>(item->parent())));
|
||||||
const auto familyItem = static_cast<const FamilyItem *>(item);
|
|
||||||
selection.family = familyItem->m_name;
|
|
||||||
selection.desc = familyItem->m_desc;
|
|
||||||
selection.vendor = familyItem->m_vendor;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DeviceSelectionItem::Type::Package: {
|
|
||||||
const auto packageItem = static_cast<const PackageItem *>(item);
|
|
||||||
selection.package.desc = packageItem->m_desc;
|
|
||||||
selection.package.file = packageItem->m_file;
|
|
||||||
selection.package.name = packageItem->m_name;
|
|
||||||
selection.package.url = packageItem->m_url;
|
|
||||||
selection.package.vendor = packageItem->m_vendor;
|
|
||||||
selection.package.version = packageItem->m_version;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while ((item = item->parentPackItem()));
|
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,12 +52,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void parsePackage(const QString &packageFile);
|
void parsePackage(const QString &packageFile);
|
||||||
void parsePackage(QXmlStreamReader &in, const QString &file);
|
void parsePackage(QXmlStreamReader &in, const QString &packageFile);
|
||||||
void parseFamily(QXmlStreamReader &in, DeviceSelectionItem *parent);
|
void parseFamily(QXmlStreamReader &in, DeviceSelectionItem *parent);
|
||||||
void parseSubFamily(QXmlStreamReader &in, DeviceSelectionItem *parent,
|
void parseSubFamily(QXmlStreamReader &in, DeviceSelectionItem *parent);
|
||||||
DeviceSelection::Cpu &cpu);
|
void parseDevice(QXmlStreamReader &in, DeviceSelectionItem *parent);
|
||||||
void parseDevice(QXmlStreamReader &in, DeviceSelectionItem *parent,
|
|
||||||
DeviceSelection::Cpu &cpu, DeviceSelection::Memories &memories);
|
|
||||||
void parseDeviceVariant(QXmlStreamReader &in, DeviceSelectionItem *parent);
|
void parseDeviceVariant(QXmlStreamReader &in, DeviceSelectionItem *parent);
|
||||||
|
|
||||||
Utils::FilePath m_toolsIniFile;
|
Utils::FilePath m_toolsIniFile;
|
||||||
@@ -77,7 +75,6 @@ signals:
|
|||||||
private:
|
private:
|
||||||
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) final;
|
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) final;
|
||||||
|
|
||||||
bool isValidItem(const DeviceSelectionItem *item) const;
|
|
||||||
DeviceSelection buildSelection(const DeviceSelectionItem *item) const;
|
DeviceSelection buildSelection(const DeviceSelectionItem *item) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -41,14 +41,16 @@ constexpr char packageDescrKeyC[] = "BareMetal.UvscServerProvider.PackageDescrip
|
|||||||
constexpr char packageFileKeyC[] = "BareMetal.UvscServerProvider.PackageFile";
|
constexpr char packageFileKeyC[] = "BareMetal.UvscServerProvider.PackageFile";
|
||||||
constexpr char packageNameKeyC[] = "BareMetal.UvscServerProvider.PackageName";
|
constexpr char packageNameKeyC[] = "BareMetal.UvscServerProvider.PackageName";
|
||||||
constexpr char packageUrlKeyC[] = "BareMetal.UvscServerProvider.PackageUrl";
|
constexpr char packageUrlKeyC[] = "BareMetal.UvscServerProvider.PackageUrl";
|
||||||
constexpr char packageVendorKeyC[] = "BareMetal.UvscServerProvider.PackageVendor";
|
constexpr char packageVendorNameKeyC[] = "BareMetal.UvscServerProvider.PackageVendorName";
|
||||||
|
constexpr char packageVendorIdKeyC[] = "BareMetal.UvscServerProvider.PackageVendorId";
|
||||||
constexpr char packageVersionKeyC[] = "BareMetal.UvscServerProvider.PackageVersion";
|
constexpr char packageVersionKeyC[] = "BareMetal.UvscServerProvider.PackageVersion";
|
||||||
// Device data keys.
|
// Device data keys.
|
||||||
constexpr char deviceNameKeyC[] = "BareMetal.UvscServerProvider.DeviceName";
|
constexpr char deviceNameKeyC[] = "BareMetal.UvscServerProvider.DeviceName";
|
||||||
constexpr char deviceDescrKeyC[] = "BareMetal.UvscServerProvider.DeviceDescription";
|
constexpr char deviceDescrKeyC[] = "BareMetal.UvscServerProvider.DeviceDescription";
|
||||||
constexpr char deviceFamilyKeyC[] = "BareMetal.UvscServerProvider.DeviceFamily";
|
constexpr char deviceFamilyKeyC[] = "BareMetal.UvscServerProvider.DeviceFamily";
|
||||||
constexpr char deviceSubFamilyKeyC[] = "BareMetal.UvscServerProvider.DeviceSubFamily";
|
constexpr char deviceSubFamilyKeyC[] = "BareMetal.UvscServerProvider.DeviceSubFamily";
|
||||||
constexpr char deviceVendorKeyC[] = "BareMetal.UvscServerProvider.DeviceVendor";
|
constexpr char deviceVendorNameKeyC[] = "BareMetal.UvscServerProvider.DeviceVendorName";
|
||||||
|
constexpr char deviceVendorIdKeyC[] = "BareMetal.UvscServerProvider.DeviceVendorId";
|
||||||
constexpr char deviceSvdKeyC[] = "BareMetal.UvscServerProvider.DeviceSVD";
|
constexpr char deviceSvdKeyC[] = "BareMetal.UvscServerProvider.DeviceSVD";
|
||||||
// Device CPU data keys.
|
// Device CPU data keys.
|
||||||
constexpr char deviceClockKeyC[] = "BareMetal.UvscServerProvider.DeviceClock";
|
constexpr char deviceClockKeyC[] = "BareMetal.UvscServerProvider.DeviceClock";
|
||||||
@@ -77,14 +79,16 @@ QVariantMap DeviceSelection::toMap() const
|
|||||||
map.insert(packageFileKeyC, package.file);
|
map.insert(packageFileKeyC, package.file);
|
||||||
map.insert(packageNameKeyC, package.name);
|
map.insert(packageNameKeyC, package.name);
|
||||||
map.insert(packageUrlKeyC, package.url);
|
map.insert(packageUrlKeyC, package.url);
|
||||||
map.insert(packageVendorKeyC, package.vendor);
|
map.insert(packageVendorNameKeyC, package.vendorName);
|
||||||
|
map.insert(packageVendorIdKeyC, package.vendorId);
|
||||||
map.insert(packageVersionKeyC, package.version);
|
map.insert(packageVersionKeyC, package.version);
|
||||||
// Device.
|
// Device.
|
||||||
map.insert(deviceNameKeyC, name);
|
map.insert(deviceNameKeyC, name);
|
||||||
map.insert(deviceDescrKeyC, desc);
|
map.insert(deviceDescrKeyC, desc);
|
||||||
map.insert(deviceFamilyKeyC, family);
|
map.insert(deviceFamilyKeyC, family);
|
||||||
map.insert(deviceSubFamilyKeyC, subfamily);
|
map.insert(deviceSubFamilyKeyC, subfamily);
|
||||||
map.insert(deviceVendorKeyC, vendor);
|
map.insert(deviceVendorNameKeyC, vendorName);
|
||||||
|
map.insert(deviceVendorIdKeyC, vendorId);
|
||||||
map.insert(deviceSvdKeyC, svd);
|
map.insert(deviceSvdKeyC, svd);
|
||||||
// Device CPU.
|
// Device CPU.
|
||||||
map.insert(deviceClockKeyC, cpu.clock);
|
map.insert(deviceClockKeyC, cpu.clock);
|
||||||
@@ -122,14 +126,16 @@ void DeviceSelection::fromMap(const QVariantMap &map)
|
|||||||
package.file = map.value(packageFileKeyC).toString();
|
package.file = map.value(packageFileKeyC).toString();
|
||||||
package.name = map.value(packageNameKeyC).toString();
|
package.name = map.value(packageNameKeyC).toString();
|
||||||
package.url = map.value(packageUrlKeyC).toString();
|
package.url = map.value(packageUrlKeyC).toString();
|
||||||
package.vendor = map.value(packageVendorKeyC).toString();
|
package.vendorName = map.value(packageVendorNameKeyC).toString();
|
||||||
|
package.vendorId = map.value(packageVendorIdKeyC).toString();
|
||||||
package.version = map.value(packageVersionKeyC).toString();
|
package.version = map.value(packageVersionKeyC).toString();
|
||||||
// Device.
|
// Device.
|
||||||
name = map.value(deviceNameKeyC).toString();
|
name = map.value(deviceNameKeyC).toString();
|
||||||
desc = map.value(deviceDescrKeyC).toString();
|
desc = map.value(deviceDescrKeyC).toString();
|
||||||
family = map.value(deviceFamilyKeyC).toString();
|
family = map.value(deviceFamilyKeyC).toString();
|
||||||
subfamily = map.value(deviceSubFamilyKeyC).toString();
|
subfamily = map.value(deviceSubFamilyKeyC).toString();
|
||||||
vendor = map.value(deviceVendorKeyC).toString();
|
vendorName = map.value(deviceVendorNameKeyC).toString();
|
||||||
|
vendorId = map.value(deviceVendorIdKeyC).toString();
|
||||||
svd = map.value(deviceSvdKeyC).toString();
|
svd = map.value(deviceSvdKeyC).toString();
|
||||||
// Device CPU.
|
// Device CPU.
|
||||||
cpu.clock = map.value(deviceClockKeyC).toString();
|
cpu.clock = map.value(deviceClockKeyC).toString();
|
||||||
@@ -163,7 +169,8 @@ bool DeviceSelection::Package::operator==(const Package &other) const
|
|||||||
{
|
{
|
||||||
return desc == other.desc && file == other.file
|
return desc == other.desc && file == other.file
|
||||||
&& name == other.name && url == other.url
|
&& name == other.name && url == other.url
|
||||||
&& vendor == other.vendor && version == other.version;
|
&& vendorName == other.vendorName && vendorId == other.vendorId
|
||||||
|
&& version == other.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceSelection::Cpu::operator==(const Cpu &other) const
|
bool DeviceSelection::Cpu::operator==(const Cpu &other) const
|
||||||
@@ -186,7 +193,8 @@ bool DeviceSelection::operator==(const DeviceSelection &other) const
|
|||||||
{
|
{
|
||||||
return package == other.package && name == other.name && desc == other.desc
|
return package == other.package && name == other.name && desc == other.desc
|
||||||
&& family == other.family && subfamily == other.subfamily
|
&& family == other.family && subfamily == other.subfamily
|
||||||
&& vendor == other.vendor && svd == other.svd && cpu == other.cpu
|
&& vendorName == other.vendorName && vendorId == other.vendorId
|
||||||
|
&& svd == other.svd && cpu == other.cpu
|
||||||
&& memories == other.memories && algorithms == other.algorithms
|
&& memories == other.memories && algorithms == other.algorithms
|
||||||
&& algorithmIndex == other.algorithmIndex;
|
&& algorithmIndex == other.algorithmIndex;
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,8 @@ public:
|
|||||||
QString file;
|
QString file;
|
||||||
QString name;
|
QString name;
|
||||||
QString url;
|
QString url;
|
||||||
QString vendor;
|
QString vendorId;
|
||||||
|
QString vendorName;
|
||||||
QString version;
|
QString version;
|
||||||
|
|
||||||
bool operator==(const Package &other) const;
|
bool operator==(const Package &other) const;
|
||||||
@@ -84,7 +85,8 @@ public:
|
|||||||
QString desc;
|
QString desc;
|
||||||
QString family;
|
QString family;
|
||||||
QString subfamily;
|
QString subfamily;
|
||||||
QString vendor;
|
QString vendorId;
|
||||||
|
QString vendorName;
|
||||||
QString svd;
|
QString svd;
|
||||||
Cpu cpu;
|
Cpu cpu;
|
||||||
Memories memories;
|
Memories memories;
|
||||||
|
@@ -105,7 +105,7 @@ static QString trimVendor(const QString &vendor)
|
|||||||
|
|
||||||
void DeviceSelectorDetailsPanel::refresh()
|
void DeviceSelectorDetailsPanel::refresh()
|
||||||
{
|
{
|
||||||
m_vendorEdit->setText(trimVendor(m_selection.vendor));
|
m_vendorEdit->setText(trimVendor(m_selection.vendorName));
|
||||||
m_fimilyEdit->setText(m_selection.family);
|
m_fimilyEdit->setText(m_selection.family);
|
||||||
m_descEdit->setPlainText(m_selection.desc);
|
m_descEdit->setPlainText(m_selection.desc);
|
||||||
m_memoryView->refresh();
|
m_memoryView->refresh();
|
||||||
|
Reference in New Issue
Block a user