aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacek Nijaki <jacek.nijaki@siili.com>2020-09-18 11:16:37 +0200
committerJacek Nijaki <jacek.nijaki@siili.com>2020-09-22 08:32:00 +0000
commit08541305b6edabd00b80f46f16945e28f03dafda (patch)
treec070fd2cc3ef8c1af61fc8b939bf0110f32525c8 /src
parent698a0dd8c8362495256fabe6f555d9ead1debee5 (diff)
McuSupport: Add support for desktop backend JSON file
Starting from Qul 1.5 json kit file will be shipped for desktop platform. This change is backward compatible with previous Qul version - if no desktop specific json file is found a legacy code is executed. This change removes "desktop" toolchain, instead "msvc" and "gcc" toolchains are introduced. Additional parameter was introduced to the josn kit file: "platformName" which enables using different strings in kit name and in QUL_PLATFORM cmake variable. Change-Id: Ie0a212aaad47a8033e9a81467f60a23c2bc19a51 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/mcusupport/mcusupportoptions.cpp88
-rw-r--r--src/plugins/mcusupport/mcusupportoptions.h27
-rw-r--r--src/plugins/mcusupport/mcusupportsdk.cpp149
3 files changed, 165 insertions, 99 deletions
diff --git a/src/plugins/mcusupport/mcusupportoptions.cpp b/src/plugins/mcusupport/mcusupportoptions.cpp
index 16a36bebd9..7fa6c98ceb 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 = 6; // Bumps up whenever details in Kit creation change
+static const int KIT_VERSION = 7; // Bumps up whenever details in Kit creation change
static QString packagePathFromSettings(const QString &settingsKey,
QSettings::Scope scope = QSettings::UserScope,
@@ -227,8 +227,10 @@ void McuPackage::updateStatus()
m_path != m_defaultPath);
}
-McuToolChainPackage::McuToolChainPackage(const QString &label, const QString &defaultPath,
- const QString &detectionPath, const QString &settingsKey,
+McuToolChainPackage::McuToolChainPackage(const QString &label,
+ const QString &defaultPath,
+ const QString &detectionPath,
+ const QString &settingsKey,
McuToolChainPackage::Type type)
: McuPackage(label, defaultPath, detectionPath, settingsKey)
, m_type(type)
@@ -240,15 +242,32 @@ McuToolChainPackage::Type McuToolChainPackage::type() const
return m_type;
}
-static ProjectExplorer::ToolChain *desktopToolChain(Utils::Id language)
+bool McuToolChainPackage::isDesktopToolchain() const
+{
+ return m_type == TypeMSVC || m_type == TypeGCC;
+}
+
+static ProjectExplorer::ToolChain *msvcToolChain(Utils::Id language)
+{
+ using namespace ProjectExplorer;
+
+ ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
+ const Abi abi = t->targetAbi();
+ return (abi.osFlavor() == Abi::WindowsMsvc2017Flavor || abi.osFlavor() == Abi::WindowsMsvc2019Flavor)
+ && abi.architecture() == Abi::X86Architecture
+ && abi.wordWidth() == 64
+ && t->language() == language;
+ });
+ return toolChain;
+}
+
+static ProjectExplorer::ToolChain *gccToolChain(Utils::Id language)
{
using namespace ProjectExplorer;
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
const Abi abi = t->targetAbi();
- return (abi.os() != Abi::WindowsOS
- || (abi.osFlavor() == Abi::WindowsMsvc2017Flavor
- || abi.osFlavor() == Abi::WindowsMsvc2019Flavor))
+ return abi.os() != Abi::WindowsOS
&& abi.architecture() == Abi::X86Architecture
&& abi.wordWidth() == 64
&& t->language() == language;
@@ -285,9 +304,11 @@ static ProjectExplorer::ToolChain* armGccToolChain(const Utils::FilePath &path,
ProjectExplorer::ToolChain *McuToolChainPackage::toolChain(Utils::Id language) const
{
ProjectExplorer::ToolChain *tc = nullptr;
- if (m_type == TypeDesktop) {
- tc = desktopToolChain(language);
- } else {
+ if (m_type == TypeMSVC)
+ tc = msvcToolChain(language);
+ else if (m_type == TypeGCC)
+ tc = gccToolChain(language);
+ else {
const QLatin1String compilerName(
language == ProjectExplorer::Constants::C_LANGUAGE_ID ? "gcc" : "g++");
const Utils::FilePath compiler = Utils::FilePath::fromUserInput(
@@ -336,24 +357,18 @@ QVariant McuToolChainPackage::debuggerId() const
return debuggerId;
}
-McuTarget::McuTarget(const QVersionNumber &qulVersion, const QString &vendor,
- const QString &platform, OS os,
+McuTarget::McuTarget(const QVersionNumber &qulVersion,
+ const Platform &platform, OS os,
const QVector<McuPackage *> &packages,
const McuToolChainPackage *toolChainPackage)
: m_qulVersion(qulVersion)
- , m_vendor(vendor)
- , m_qulPlatform(platform)
+ , m_platform(platform)
, m_os(os)
, m_packages(packages)
, m_toolChainPackage(toolChainPackage)
{
}
-QString McuTarget::vendor() const
-{
- return m_vendor;
-}
-
QVector<McuPackage *> McuTarget::packages() const
{
return m_packages;
@@ -369,9 +384,9 @@ McuTarget::OS McuTarget::os() const
return m_os;
}
-QString McuTarget::qulPlatform() const
+McuTarget::Platform McuTarget::platform() const
{
- return m_qulPlatform;
+ return m_platform;
}
bool McuTarget::isValid() const
@@ -502,15 +517,15 @@ static void setKitProperties(const QString &kitName, ProjectExplorer::Kit *k,
using namespace Constants;
k->setUnexpandedDisplayName(kitName);
- k->setValue(KIT_MCUTARGET_VENDOR_KEY, mcuTarget->vendor());
- k->setValue(KIT_MCUTARGET_MODEL_KEY, mcuTarget->qulPlatform());
+ k->setValue(KIT_MCUTARGET_VENDOR_KEY, mcuTarget->platform().vendor);
+ k->setValue(KIT_MCUTARGET_MODEL_KEY, mcuTarget->platform().name);
k->setValue(KIT_MCUTARGET_COLORDEPTH_KEY, mcuTarget->colorDepth());
k->setValue(KIT_MCUTARGET_SDKVERSION_KEY, mcuTarget->qulVersion().toString());
k->setValue(KIT_MCUTARGET_KITVERSION_KEY, KIT_VERSION);
k->setValue(KIT_MCUTARGET_OS_KEY, static_cast<int>(mcuTarget->os()));
k->setAutoDetected(true);
k->makeSticky();
- if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop)
+ if (mcuTarget->toolChainPackage()->isDesktopToolchain())
k->setDeviceTypeForIcon(DEVICE_TYPE);
QSet<Utils::Id> irrelevant = {
SysRootKitAspect::id(),
@@ -537,7 +552,7 @@ static void setKitDebugger(ProjectExplorer::Kit *k, const McuToolChainPackage *t
{
// Qt Creator seems to be smart enough to deduce the right Kit debugger from the ToolChain
// We rely on that at least in the Desktop case.
- if (tcPackage->type() == McuToolChainPackage::TypeDesktop
+ if (tcPackage->isDesktopToolchain()
// No Green Hills debugger, because support for it is missing.
|| tcPackage->type() == McuToolChainPackage::TypeGHS)
return;
@@ -548,7 +563,7 @@ static void setKitDebugger(ProjectExplorer::Kit *k, const McuToolChainPackage *t
static void setKitDevice(ProjectExplorer::Kit *k, const McuTarget* mcuTarget)
{
// "Device Type" Desktop is the default. We use that for the Qt for MCUs Desktop Kit
- if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop)
+ if (mcuTarget->toolChainPackage()->isDesktopToolchain())
return;
ProjectExplorer::DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DEVICE_TYPE);
@@ -565,7 +580,7 @@ static void setKitEnvironment(ProjectExplorer::Kit *k, const McuTarget* mcuTarge
// The Desktop version depends on the Qt shared libs in Qul_DIR/bin.
// If CMake's fileApi is avaialble, we can rely on the "Add library search path to PATH"
// feature of the run configuration. Otherwise, we just prepend the path, here.
- if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop
+ if (mcuTarget->toolChainPackage()->isDesktopToolchain()
&& !CMakeProjectManager::CMakeToolManager::defaultCMakeTool()->hasFileApi())
pathAdditions.append(QDir::toNativeSeparators(qtForMCUsSdkPackage->path() + "/bin"));
@@ -598,7 +613,7 @@ static void setKitCMakeOptions(ProjectExplorer::Kit *k, const McuTarget* mcuTarg
config.append(CMakeConfigItem("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}"));
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
}
- if (mcuTarget->toolChainPackage()->type() != McuToolChainPackage::TypeDesktop)
+ if (!mcuTarget->toolChainPackage()->isDesktopToolchain())
config.append(CMakeConfigItem(
"CMAKE_TOOLCHAIN_FILE",
(qulDir + "/lib/cmake/Qul/toolchain/"
@@ -606,7 +621,7 @@ static void setKitCMakeOptions(ProjectExplorer::Kit *k, const McuTarget* mcuTarg
config.append(CMakeConfigItem("QUL_GENERATORS",
(qulDir + "/lib/cmake/Qul/QulGenerators.cmake").toUtf8()));
config.append(CMakeConfigItem("QUL_PLATFORM",
- mcuTarget->qulPlatform().toUtf8()));
+ mcuTarget->platform().name.toUtf8()));
if (mcuTarget->qulVersion() <= QVersionNumber{1,3} // OS variable was removed in Qul 1.4
&& mcuTarget->os() == McuTarget::OS::FreeRTOS)
@@ -630,19 +645,16 @@ static void setKitQtVersionOptions(ProjectExplorer::Kit *k)
QString McuSupportOptions::kitName(const McuTarget *mcuTarget)
{
QString os;
- if (mcuTarget->qulVersion() <= QVersionNumber{1,3} && mcuTarget->os() == McuTarget::OS::FreeRTOS) {
+ if (mcuTarget->qulVersion() <= QVersionNumber{1,3} && mcuTarget->os() == McuTarget::OS::FreeRTOS)
// Starting from Qul 1.4 each OS is a separate platform
os = QLatin1String(" FreeRTOS");
- }
const QString colorDepth = mcuTarget->colorDepth() > 0
? QString::fromLatin1(" %1bpp").arg(mcuTarget->colorDepth())
: "";
- // Hack: Use the platform name in the kit name. Exception for the "Qt" platform: use "Desktop"
- const QString targetName =
- mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop
- ? "Desktop"
- : mcuTarget->qulPlatform();
+ const QString targetName = mcuTarget->platform().displayName.isEmpty()
+ ? mcuTarget->platform().name
+ : mcuTarget->platform().displayName;
return QString::fromLatin1("Qt for MCUs %1.%2 - %3%4%5")
.arg(QString::number(mcuTarget->qulVersion().majorVersion()),
QString::number(mcuTarget->qulVersion().minorVersion()),
@@ -659,8 +671,8 @@ QList<ProjectExplorer::Kit *> McuSupportOptions::existingKits(const McuTarget *m
return kit->isAutoDetected()
&& kit->value(KIT_MCUTARGET_KITVERSION_KEY) == KIT_VERSION
&& (!mcuTarget || (
- kit->value(KIT_MCUTARGET_VENDOR_KEY) == mcuTarget->vendor()
- && kit->value(KIT_MCUTARGET_MODEL_KEY) == mcuTarget->qulPlatform()
+ kit->value(KIT_MCUTARGET_VENDOR_KEY) == mcuTarget->platform().vendor
+ && kit->value(KIT_MCUTARGET_MODEL_KEY) == mcuTarget->platform().name
&& kit->value(KIT_MCUTARGET_COLORDEPTH_KEY) == mcuTarget->colorDepth()
&& kit->value(KIT_MCUTARGET_OS_KEY).toInt()
== static_cast<int>(mcuTarget->os())
diff --git a/src/plugins/mcusupport/mcusupportoptions.h b/src/plugins/mcusupport/mcusupportoptions.h
index f8a9ac52bf..afed7dcf5e 100644
--- a/src/plugins/mcusupport/mcusupportoptions.h
+++ b/src/plugins/mcusupport/mcusupportoptions.h
@@ -110,13 +110,18 @@ public:
TypeIAR,
TypeKEIL,
TypeGHS,
- TypeDesktop
+ TypeMSVC,
+ TypeGCC
};
- McuToolChainPackage(const QString &label, const QString &defaultPath,
- const QString &detectionPath, const QString &settingsKey, Type type);
+ McuToolChainPackage(const QString &label,
+ const QString &defaultPath,
+ const QString &detectionPath,
+ const QString &settingsKey,
+ Type type);
Type type() const;
+ bool isDesktopToolchain() const;
ProjectExplorer::ToolChain *toolChain(Utils::Id language) const;
QString cmakeToolChainFileName() const;
QVariant debuggerId() const;
@@ -136,15 +141,20 @@ public:
FreeRTOS
};
- McuTarget(const QVersionNumber &qulVersion, const QString &vendor, const QString &platform,
- OS os, const QVector<McuPackage *> &packages,
+ struct Platform {
+ QString name;
+ QString displayName;
+ QString vendor;
+ };
+
+ McuTarget(const QVersionNumber &qulVersion, const Platform &platform, OS os,
+ const QVector<McuPackage *> &packages,
const McuToolChainPackage *toolChainPackage);
QVersionNumber qulVersion() const;
- QString vendor() const;
QVector<McuPackage *> packages() const;
const McuToolChainPackage *toolChainPackage() const;
- QString qulPlatform() const;
+ Platform platform() const;
OS os() const;
void setColorDepth(int colorDepth);
int colorDepth() const;
@@ -152,8 +162,7 @@ public:
private:
const QVersionNumber m_qulVersion;
- const QString m_vendor;
- const QString m_qulPlatform;
+ const Platform m_platform;
const OS m_os = OS::BareMetal;
const QVector<McuPackage*> m_packages;
const McuToolChainPackage *m_toolChainPackage;
diff --git a/src/plugins/mcusupport/mcusupportsdk.cpp b/src/plugins/mcusupport/mcusupportsdk.cpp
index 7af6110579..7f61a24728 100644
--- a/src/plugins/mcusupport/mcusupportsdk.cpp
+++ b/src/plugins/mcusupport/mcusupportsdk.cpp
@@ -68,9 +68,14 @@ McuPackage *createQtForMCUsPackage()
return result;
}
-static McuToolChainPackage *createDesktopToolChainPackage()
+static McuToolChainPackage *createMsvcToolChainPackage()
{
- return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::TypeDesktop);
+ return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::TypeMSVC);
+}
+
+static McuToolChainPackage *createGccToolChainPackage()
+{
+ return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::TypeGCC);
}
static McuToolChainPackage *createArmGccPackage()
@@ -203,8 +208,14 @@ static McuPackage *createMcuXpressoIdePackage()
struct McuTargetDescription
{
+ enum class TargetType {
+ MCU,
+ Desktop
+ };
+
QString qulVersion;
QString platform;
+ QString platformName;
QString platformVendor;
QVector<int> colorDepths;
QString toolchainId;
@@ -213,6 +224,7 @@ struct McuTargetDescription
QString boardSdkDefaultPath;
QString freeRTOSEnvVar;
QString freeRTOSBoardSdkSubDir;
+ TargetType type;
};
static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
@@ -253,7 +265,7 @@ static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar, const QString &boardSdkDir,
const QString &freeRTOSBoardSdkSubDir)
{
- const QString envVarPrefix = envVar.chopped(strlen("_FREERTOS_DIR"));
+ const QString envVarPrefix = envVar.chopped(int(strlen("_FREERTOS_DIR")));
QString defaultPath;
if (qEnvironmentVariableIsSet(envVar.toLatin1()))
@@ -283,16 +295,16 @@ struct McuTargetFactory
QVector<McuTarget *> createTargets(const McuTargetDescription& description)
{
- if (description.toolchainId == "desktop") {
- return createDesktopTargets(description);
- }
auto qulVersion = QVersionNumber::fromString(description.qulVersion);
if (qulVersion <= QVersionNumber({1,3})) {
+ if (description.type == McuTargetDescription::TargetType::Desktop)
+ return createDesktopTargetsLegacy(description);
+
// There was a platform backends related refactoring in Qul 1.4
// This requires different processing of McuTargetDescriptions
return createMcuTargetsLegacy(description);
}
- return createMcuTargets(description);
+ return createTargetsImpl(description);
}
QVector<McuPackage *> getMcuPackages() const
@@ -305,16 +317,16 @@ struct McuTargetFactory
protected:
// Implementation for Qul version <= 1.3
- QVector<McuTarget *> createMcuTargetsLegacy(const McuTargetDescription& desc)
+ QVector<McuTarget *> createMcuTargetsLegacy(const McuTargetDescription &desc)
{
QVector<McuTarget *> mcuTargets;
- auto tcPkg = tcPkgs.value(desc.toolchainId);
+ McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchainId);
for (auto os : {McuTarget::OS::BareMetal, McuTarget::OS::FreeRTOS}) {
for (int colorDepth : desc.colorDepths) {
QVector<McuPackage*> required3rdPartyPkgs = { tcPkg };
- if (vendorPkgs.contains(desc.platformVendor)) {
+ if (vendorPkgs.contains(desc.platformVendor))
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platformVendor));
- }
+
QString boardSdkDefaultPath;
if (!desc.boardSdkEnvVar.isEmpty()) {
if (!boardSdkPkgs.contains(desc.boardSdkEnvVar)) {
@@ -340,9 +352,9 @@ protected:
}
}
+ const auto platform = McuTarget::Platform{ desc.platform, desc.platformName, desc.platformVendor };
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
- desc.platformVendor, desc.platform, os,
- required3rdPartyPkgs, tcPkg);
+ platform, os, required3rdPartyPkgs, tcPkg);
if (desc.colorDepths.count() > 1)
mcuTarget->setColorDepth(colorDepth);
mcuTargets.append(mcuTarget);
@@ -351,15 +363,39 @@ protected:
return mcuTargets;
}
- QVector<McuTarget *> createMcuTargets(const McuTargetDescription& desc)
+ QVector<McuTarget *> createDesktopTargetsLegacy(const McuTargetDescription& desc)
{
+ McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchainId);
+ const auto platform = McuTarget::Platform{ desc.platform, desc.platformName, desc.platformVendor };
+ auto desktopTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
+ platform, McuTarget::OS::Desktop, {}, tcPkg);
+ return { desktopTarget };
+ }
+
+ QVector<McuTarget *> createTargetsImpl(const McuTargetDescription& desc)
+ {
+ // OS deduction
+ const auto os = [&] {
+ if (desc.type == McuTargetDescription::TargetType::Desktop)
+ return McuTarget::OS::Desktop;
+ else if (!desc.freeRTOSEnvVar.isEmpty())
+ return McuTarget::OS::FreeRTOS;
+ return McuTarget::OS::BareMetal;
+ }();
+
QVector<McuTarget *> mcuTargets;
- auto tcPkg = tcPkgs.value(desc.toolchainId);
+ McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchainId);
for (int colorDepth : desc.colorDepths) {
- QVector<McuPackage*> required3rdPartyPkgs = { tcPkg };
- if (vendorPkgs.contains(desc.platformVendor)) {
+ QVector<McuPackage*> required3rdPartyPkgs;
+ // Desktop toolchains don't need any additional settings
+ if (tcPkg && !tcPkg->isDesktopToolchain())
+ required3rdPartyPkgs.append(tcPkg);
+
+ // Add setting specific to platform IDE
+ if (vendorPkgs.contains(desc.platformVendor))
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platformVendor));
- }
+
+ // Board SDK specific settings
QString boardSdkDefaultPath;
if (!desc.boardSdkEnvVar.isEmpty()) {
if (!boardSdkPkgs.contains(desc.boardSdkEnvVar)) {
@@ -371,9 +407,8 @@ protected:
required3rdPartyPkgs.append(boardSdkPkg);
}
- auto os = McuTarget::OS::BareMetal;
+ // Free RTOS specific settings
if (!desc.freeRTOSEnvVar.isEmpty()) {
- os = McuTarget::OS::FreeRTOS;
if (!freeRTOSPkgs.contains(desc.freeRTOSEnvVar)) {
freeRTOSPkgs.insert(desc.freeRTOSEnvVar, createFreeRTOSSourcesPackage(
desc.freeRTOSEnvVar, boardSdkDefaultPath,
@@ -382,24 +417,15 @@ protected:
required3rdPartyPkgs.append(freeRTOSPkgs.value(desc.freeRTOSEnvVar));
}
+ const auto platform = McuTarget::Platform{ desc.platform, desc.platformName, desc.platformVendor };
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
- desc.platformVendor, desc.platform, os,
- required3rdPartyPkgs, tcPkg);
+ platform, os, required3rdPartyPkgs, tcPkg);
mcuTarget->setColorDepth(colorDepth);
mcuTargets.append(mcuTarget);
}
return mcuTargets;
}
- QVector<McuTarget *> createDesktopTargets(const McuTargetDescription& desc)
- {
- auto tcPkg = tcPkgs.value(desc.toolchainId);
- auto desktopTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
- desc.platformVendor, desc.platform,
- McuTarget::OS::Desktop, {}, tcPkg);
- return { desktopTarget };
- }
-
private:
const QHash<QString, McuToolChainPackage *> &tcPkgs;
const QHash<QString, McuPackage *> &vendorPkgs;
@@ -414,7 +440,8 @@ static QVector<McuTarget *> targetsFromDescriptions(const QList<McuTargetDescrip
const QHash<QString, McuToolChainPackage *> tcPkgs = {
{{"armgcc"}, createArmGccPackage()},
{{"greenhills"}, createGhsToolchainPackage()},
- {{"desktop"}, createDesktopToolChainPackage()},
+ {{"msvc"}, createMsvcToolChainPackage()},
+ {{"gcc"}, createGccToolChainPackage()},
};
const QHash<QString, McuPackage *> vendorPkgs = {
@@ -452,15 +479,14 @@ static McuTargetDescription parseDescriptionJson(const QByteArray &data)
const QJsonObject boardSdk = target.value("boardSdk").toObject();
const QJsonObject freeRTOS = target.value("freeRTOS").toObject();
- const QString platform = target.value("platform").toString();
-
const QVariantList colorDepths = target.value("colorDepths").toArray().toVariantList();
const auto colorDepthsVector = Utils::transform<QVector<int> >(
colorDepths, [&](const QVariant &colorDepth) { return colorDepth.toInt(); });
return {
target.value("qulVersion").toString(),
- platform,
+ target.value("platform").toString(),
+ target.value("platformName").toString(),
target.value("platformVendor").toString(),
colorDepthsVector,
toolchain.value("id").toString(),
@@ -468,7 +494,8 @@ static McuTargetDescription parseDescriptionJson(const QByteArray &data)
boardSdk.value("name").toString(),
boardSdk.value("defaultPath").toString(),
freeRTOS.value("envVar").toString(),
- freeRTOS.value("boardSdkSubDir").toString()
+ freeRTOS.value("boardSdkSubDir").toString(),
+ boardSdk.empty() ? McuTargetDescription::TargetType::Desktop : McuTargetDescription::TargetType::MCU
};
}
@@ -487,25 +514,43 @@ void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packa
descriptions.append(desc);
}
- // Workaround for missing JSON file for Desktop target:
- Utils::FilePath desktopLib;
- if (Utils::HostOsInfo::isWindowsHost())
- desktopLib = dir / "lib/QulQuickUltralite_QT_32bpp_Windows_Release.lib";
- else
- desktopLib = dir / "lib/libQulQuickUltralite_QT_32bpp_Linux_Debug.a";
-
- if (desktopLib.exists()) {
- McuTargetDescription desktopDescription;
- desktopDescription.qulVersion = descriptions.empty() ?
- McuSupportOptions::minimalQulVersion().toString()
- : descriptions.first().qulVersion;
- desktopDescription.platform = desktopDescription.platformVendor = "Qt";
- desktopDescription.colorDepths = {32};
- desktopDescription.toolchainId = "desktop";
- descriptions.prepend(desktopDescription);
+ // Workaround for missing JSON file for Desktop target.
+ // Desktop JSON file is shipped starting from Qul 1.5.
+ // This whole section could be removed when minimalQulVersion will reach 1.5 or above
+ {
+ const bool hasDesktopDescription = Utils::contains(descriptions, [](const McuTargetDescription &desc) {
+ return desc.type == McuTargetDescription::TargetType::Desktop;
+ });
+
+ if (!hasDesktopDescription) {
+ Utils::FilePath desktopLib;
+ if (Utils::HostOsInfo::isWindowsHost())
+ desktopLib = dir / "lib/QulQuickUltralite_QT_32bpp_Windows_Release.lib";
+ else
+ desktopLib = dir / "lib/libQulQuickUltralite_QT_32bpp_Linux_Debug.a";
+
+ if (desktopLib.exists()) {
+ McuTargetDescription desktopDescription;
+ desktopDescription.qulVersion = descriptions.empty() ?
+ McuSupportOptions::minimalQulVersion().toString()
+ : descriptions.first().qulVersion;
+ desktopDescription.platform = "Qt";
+ desktopDescription.platformName = "Desktop";
+ desktopDescription.platformVendor = "Qt";
+ desktopDescription.colorDepths = {32};
+ desktopDescription.toolchainId = Utils::HostOsInfo::isWindowsHost() ? QString("msvc") : QString("gcc");
+ desktopDescription.type = McuTargetDescription::TargetType::Desktop;
+ descriptions.prepend(desktopDescription);
+ }
+ }
}
mcuTargets->append(targetsFromDescriptions(descriptions, packages));
+
+ // Keep targets sorted lexicographically
+ std::sort(mcuTargets->begin(), mcuTargets->end(), [] (const McuTarget* lhs, const McuTarget* rhs) {
+ return McuSupportOptions::kitName(lhs) < McuSupportOptions::kitName(rhs);
+ });
}
} // namespace Sdk