forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -61,7 +61,7 @@
|
|||||||
namespace McuSupport {
|
namespace McuSupport {
|
||||||
namespace Internal {
|
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,
|
static QString packagePathFromSettings(const QString &settingsKey,
|
||||||
QSettings::Scope scope = QSettings::UserScope,
|
QSettings::Scope scope = QSettings::UserScope,
|
||||||
@@ -227,8 +227,10 @@ void McuPackage::updateStatus()
|
|||||||
m_path != m_defaultPath);
|
m_path != m_defaultPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage::McuToolChainPackage(const QString &label, const QString &defaultPath,
|
McuToolChainPackage::McuToolChainPackage(const QString &label,
|
||||||
const QString &detectionPath, const QString &settingsKey,
|
const QString &defaultPath,
|
||||||
|
const QString &detectionPath,
|
||||||
|
const QString &settingsKey,
|
||||||
McuToolChainPackage::Type type)
|
McuToolChainPackage::Type type)
|
||||||
: McuPackage(label, defaultPath, detectionPath, settingsKey)
|
: McuPackage(label, defaultPath, detectionPath, settingsKey)
|
||||||
, m_type(type)
|
, m_type(type)
|
||||||
@@ -240,15 +242,32 @@ McuToolChainPackage::Type McuToolChainPackage::type() const
|
|||||||
return m_type;
|
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;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
||||||
const Abi abi = t->targetAbi();
|
const Abi abi = t->targetAbi();
|
||||||
return (abi.os() != Abi::WindowsOS
|
return (abi.osFlavor() == Abi::WindowsMsvc2017Flavor || abi.osFlavor() == Abi::WindowsMsvc2019Flavor)
|
||||||
|| (abi.osFlavor() == Abi::WindowsMsvc2017Flavor
|
&& abi.architecture() == Abi::X86Architecture
|
||||||
|| abi.osFlavor() == Abi::WindowsMsvc2019Flavor))
|
&& 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.architecture() == Abi::X86Architecture
|
&& abi.architecture() == Abi::X86Architecture
|
||||||
&& abi.wordWidth() == 64
|
&& abi.wordWidth() == 64
|
||||||
&& t->language() == language;
|
&& 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 *McuToolChainPackage::toolChain(Utils::Id language) const
|
||||||
{
|
{
|
||||||
ProjectExplorer::ToolChain *tc = nullptr;
|
ProjectExplorer::ToolChain *tc = nullptr;
|
||||||
if (m_type == TypeDesktop) {
|
if (m_type == TypeMSVC)
|
||||||
tc = desktopToolChain(language);
|
tc = msvcToolChain(language);
|
||||||
} else {
|
else if (m_type == TypeGCC)
|
||||||
|
tc = gccToolChain(language);
|
||||||
|
else {
|
||||||
const QLatin1String compilerName(
|
const QLatin1String compilerName(
|
||||||
language == ProjectExplorer::Constants::C_LANGUAGE_ID ? "gcc" : "g++");
|
language == ProjectExplorer::Constants::C_LANGUAGE_ID ? "gcc" : "g++");
|
||||||
const Utils::FilePath compiler = Utils::FilePath::fromUserInput(
|
const Utils::FilePath compiler = Utils::FilePath::fromUserInput(
|
||||||
@@ -336,24 +357,18 @@ QVariant McuToolChainPackage::debuggerId() const
|
|||||||
return debuggerId;
|
return debuggerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
McuTarget::McuTarget(const QVersionNumber &qulVersion, const QString &vendor,
|
McuTarget::McuTarget(const QVersionNumber &qulVersion,
|
||||||
const QString &platform, OS os,
|
const Platform &platform, OS os,
|
||||||
const QVector<McuPackage *> &packages,
|
const QVector<McuPackage *> &packages,
|
||||||
const McuToolChainPackage *toolChainPackage)
|
const McuToolChainPackage *toolChainPackage)
|
||||||
: m_qulVersion(qulVersion)
|
: m_qulVersion(qulVersion)
|
||||||
, m_vendor(vendor)
|
, m_platform(platform)
|
||||||
, m_qulPlatform(platform)
|
|
||||||
, m_os(os)
|
, m_os(os)
|
||||||
, m_packages(packages)
|
, m_packages(packages)
|
||||||
, m_toolChainPackage(toolChainPackage)
|
, m_toolChainPackage(toolChainPackage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString McuTarget::vendor() const
|
|
||||||
{
|
|
||||||
return m_vendor;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<McuPackage *> McuTarget::packages() const
|
QVector<McuPackage *> McuTarget::packages() const
|
||||||
{
|
{
|
||||||
return m_packages;
|
return m_packages;
|
||||||
@@ -369,9 +384,9 @@ McuTarget::OS McuTarget::os() const
|
|||||||
return m_os;
|
return m_os;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString McuTarget::qulPlatform() const
|
McuTarget::Platform McuTarget::platform() const
|
||||||
{
|
{
|
||||||
return m_qulPlatform;
|
return m_platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool McuTarget::isValid() const
|
bool McuTarget::isValid() const
|
||||||
@@ -502,15 +517,15 @@ static void setKitProperties(const QString &kitName, ProjectExplorer::Kit *k,
|
|||||||
using namespace Constants;
|
using namespace Constants;
|
||||||
|
|
||||||
k->setUnexpandedDisplayName(kitName);
|
k->setUnexpandedDisplayName(kitName);
|
||||||
k->setValue(KIT_MCUTARGET_VENDOR_KEY, mcuTarget->vendor());
|
k->setValue(KIT_MCUTARGET_VENDOR_KEY, mcuTarget->platform().vendor);
|
||||||
k->setValue(KIT_MCUTARGET_MODEL_KEY, mcuTarget->qulPlatform());
|
k->setValue(KIT_MCUTARGET_MODEL_KEY, mcuTarget->platform().name);
|
||||||
k->setValue(KIT_MCUTARGET_COLORDEPTH_KEY, mcuTarget->colorDepth());
|
k->setValue(KIT_MCUTARGET_COLORDEPTH_KEY, mcuTarget->colorDepth());
|
||||||
k->setValue(KIT_MCUTARGET_SDKVERSION_KEY, mcuTarget->qulVersion().toString());
|
k->setValue(KIT_MCUTARGET_SDKVERSION_KEY, mcuTarget->qulVersion().toString());
|
||||||
k->setValue(KIT_MCUTARGET_KITVERSION_KEY, KIT_VERSION);
|
k->setValue(KIT_MCUTARGET_KITVERSION_KEY, KIT_VERSION);
|
||||||
k->setValue(KIT_MCUTARGET_OS_KEY, static_cast<int>(mcuTarget->os()));
|
k->setValue(KIT_MCUTARGET_OS_KEY, static_cast<int>(mcuTarget->os()));
|
||||||
k->setAutoDetected(true);
|
k->setAutoDetected(true);
|
||||||
k->makeSticky();
|
k->makeSticky();
|
||||||
if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop)
|
if (mcuTarget->toolChainPackage()->isDesktopToolchain())
|
||||||
k->setDeviceTypeForIcon(DEVICE_TYPE);
|
k->setDeviceTypeForIcon(DEVICE_TYPE);
|
||||||
QSet<Utils::Id> irrelevant = {
|
QSet<Utils::Id> irrelevant = {
|
||||||
SysRootKitAspect::id(),
|
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
|
// 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.
|
// 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.
|
// No Green Hills debugger, because support for it is missing.
|
||||||
|| tcPackage->type() == McuToolChainPackage::TypeGHS)
|
|| tcPackage->type() == McuToolChainPackage::TypeGHS)
|
||||||
return;
|
return;
|
||||||
@@ -548,7 +563,7 @@ static void setKitDebugger(ProjectExplorer::Kit *k, const McuToolChainPackage *t
|
|||||||
static void setKitDevice(ProjectExplorer::Kit *k, const McuTarget* mcuTarget)
|
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
|
// "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;
|
return;
|
||||||
|
|
||||||
ProjectExplorer::DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DEVICE_TYPE);
|
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.
|
// 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"
|
// 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.
|
// 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())
|
&& !CMakeProjectManager::CMakeToolManager::defaultCMakeTool()->hasFileApi())
|
||||||
pathAdditions.append(QDir::toNativeSeparators(qtForMCUsSdkPackage->path() + "/bin"));
|
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_CXX_COMPILER", "%{Compiler:Executable:Cxx}"));
|
||||||
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
|
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
|
||||||
}
|
}
|
||||||
if (mcuTarget->toolChainPackage()->type() != McuToolChainPackage::TypeDesktop)
|
if (!mcuTarget->toolChainPackage()->isDesktopToolchain())
|
||||||
config.append(CMakeConfigItem(
|
config.append(CMakeConfigItem(
|
||||||
"CMAKE_TOOLCHAIN_FILE",
|
"CMAKE_TOOLCHAIN_FILE",
|
||||||
(qulDir + "/lib/cmake/Qul/toolchain/"
|
(qulDir + "/lib/cmake/Qul/toolchain/"
|
||||||
@@ -606,7 +621,7 @@ static void setKitCMakeOptions(ProjectExplorer::Kit *k, const McuTarget* mcuTarg
|
|||||||
config.append(CMakeConfigItem("QUL_GENERATORS",
|
config.append(CMakeConfigItem("QUL_GENERATORS",
|
||||||
(qulDir + "/lib/cmake/Qul/QulGenerators.cmake").toUtf8()));
|
(qulDir + "/lib/cmake/Qul/QulGenerators.cmake").toUtf8()));
|
||||||
config.append(CMakeConfigItem("QUL_PLATFORM",
|
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
|
if (mcuTarget->qulVersion() <= QVersionNumber{1,3} // OS variable was removed in Qul 1.4
|
||||||
&& mcuTarget->os() == McuTarget::OS::FreeRTOS)
|
&& mcuTarget->os() == McuTarget::OS::FreeRTOS)
|
||||||
@@ -630,19 +645,16 @@ static void setKitQtVersionOptions(ProjectExplorer::Kit *k)
|
|||||||
QString McuSupportOptions::kitName(const McuTarget *mcuTarget)
|
QString McuSupportOptions::kitName(const McuTarget *mcuTarget)
|
||||||
{
|
{
|
||||||
QString os;
|
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
|
// Starting from Qul 1.4 each OS is a separate platform
|
||||||
os = QLatin1String(" FreeRTOS");
|
os = QLatin1String(" FreeRTOS");
|
||||||
}
|
|
||||||
|
|
||||||
const QString colorDepth = mcuTarget->colorDepth() > 0
|
const QString colorDepth = mcuTarget->colorDepth() > 0
|
||||||
? QString::fromLatin1(" %1bpp").arg(mcuTarget->colorDepth())
|
? 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->platform().displayName.isEmpty()
|
||||||
const QString targetName =
|
? mcuTarget->platform().name
|
||||||
mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop
|
: mcuTarget->platform().displayName;
|
||||||
? "Desktop"
|
|
||||||
: mcuTarget->qulPlatform();
|
|
||||||
return QString::fromLatin1("Qt for MCUs %1.%2 - %3%4%5")
|
return QString::fromLatin1("Qt for MCUs %1.%2 - %3%4%5")
|
||||||
.arg(QString::number(mcuTarget->qulVersion().majorVersion()),
|
.arg(QString::number(mcuTarget->qulVersion().majorVersion()),
|
||||||
QString::number(mcuTarget->qulVersion().minorVersion()),
|
QString::number(mcuTarget->qulVersion().minorVersion()),
|
||||||
@@ -659,8 +671,8 @@ QList<ProjectExplorer::Kit *> McuSupportOptions::existingKits(const McuTarget *m
|
|||||||
return kit->isAutoDetected()
|
return kit->isAutoDetected()
|
||||||
&& kit->value(KIT_MCUTARGET_KITVERSION_KEY) == KIT_VERSION
|
&& kit->value(KIT_MCUTARGET_KITVERSION_KEY) == KIT_VERSION
|
||||||
&& (!mcuTarget || (
|
&& (!mcuTarget || (
|
||||||
kit->value(KIT_MCUTARGET_VENDOR_KEY) == mcuTarget->vendor()
|
kit->value(KIT_MCUTARGET_VENDOR_KEY) == mcuTarget->platform().vendor
|
||||||
&& kit->value(KIT_MCUTARGET_MODEL_KEY) == mcuTarget->qulPlatform()
|
&& kit->value(KIT_MCUTARGET_MODEL_KEY) == mcuTarget->platform().name
|
||||||
&& kit->value(KIT_MCUTARGET_COLORDEPTH_KEY) == mcuTarget->colorDepth()
|
&& kit->value(KIT_MCUTARGET_COLORDEPTH_KEY) == mcuTarget->colorDepth()
|
||||||
&& kit->value(KIT_MCUTARGET_OS_KEY).toInt()
|
&& kit->value(KIT_MCUTARGET_OS_KEY).toInt()
|
||||||
== static_cast<int>(mcuTarget->os())
|
== static_cast<int>(mcuTarget->os())
|
||||||
|
@@ -110,13 +110,18 @@ public:
|
|||||||
TypeIAR,
|
TypeIAR,
|
||||||
TypeKEIL,
|
TypeKEIL,
|
||||||
TypeGHS,
|
TypeGHS,
|
||||||
TypeDesktop
|
TypeMSVC,
|
||||||
|
TypeGCC
|
||||||
};
|
};
|
||||||
|
|
||||||
McuToolChainPackage(const QString &label, const QString &defaultPath,
|
McuToolChainPackage(const QString &label,
|
||||||
const QString &detectionPath, const QString &settingsKey, Type type);
|
const QString &defaultPath,
|
||||||
|
const QString &detectionPath,
|
||||||
|
const QString &settingsKey,
|
||||||
|
Type type);
|
||||||
|
|
||||||
Type type() const;
|
Type type() const;
|
||||||
|
bool isDesktopToolchain() const;
|
||||||
ProjectExplorer::ToolChain *toolChain(Utils::Id language) const;
|
ProjectExplorer::ToolChain *toolChain(Utils::Id language) const;
|
||||||
QString cmakeToolChainFileName() const;
|
QString cmakeToolChainFileName() const;
|
||||||
QVariant debuggerId() const;
|
QVariant debuggerId() const;
|
||||||
@@ -136,15 +141,20 @@ public:
|
|||||||
FreeRTOS
|
FreeRTOS
|
||||||
};
|
};
|
||||||
|
|
||||||
McuTarget(const QVersionNumber &qulVersion, const QString &vendor, const QString &platform,
|
struct Platform {
|
||||||
OS os, const QVector<McuPackage *> &packages,
|
QString name;
|
||||||
|
QString displayName;
|
||||||
|
QString vendor;
|
||||||
|
};
|
||||||
|
|
||||||
|
McuTarget(const QVersionNumber &qulVersion, const Platform &platform, OS os,
|
||||||
|
const QVector<McuPackage *> &packages,
|
||||||
const McuToolChainPackage *toolChainPackage);
|
const McuToolChainPackage *toolChainPackage);
|
||||||
|
|
||||||
QVersionNumber qulVersion() const;
|
QVersionNumber qulVersion() const;
|
||||||
QString vendor() const;
|
|
||||||
QVector<McuPackage *> packages() const;
|
QVector<McuPackage *> packages() const;
|
||||||
const McuToolChainPackage *toolChainPackage() const;
|
const McuToolChainPackage *toolChainPackage() const;
|
||||||
QString qulPlatform() const;
|
Platform platform() const;
|
||||||
OS os() const;
|
OS os() const;
|
||||||
void setColorDepth(int colorDepth);
|
void setColorDepth(int colorDepth);
|
||||||
int colorDepth() const;
|
int colorDepth() const;
|
||||||
@@ -152,8 +162,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const QVersionNumber m_qulVersion;
|
const QVersionNumber m_qulVersion;
|
||||||
const QString m_vendor;
|
const Platform m_platform;
|
||||||
const QString m_qulPlatform;
|
|
||||||
const OS m_os = OS::BareMetal;
|
const OS m_os = OS::BareMetal;
|
||||||
const QVector<McuPackage*> m_packages;
|
const QVector<McuPackage*> m_packages;
|
||||||
const McuToolChainPackage *m_toolChainPackage;
|
const McuToolChainPackage *m_toolChainPackage;
|
||||||
|
@@ -68,9 +68,14 @@ McuPackage *createQtForMCUsPackage()
|
|||||||
return result;
|
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()
|
static McuToolChainPackage *createArmGccPackage()
|
||||||
@@ -203,8 +208,14 @@ static McuPackage *createMcuXpressoIdePackage()
|
|||||||
|
|
||||||
struct McuTargetDescription
|
struct McuTargetDescription
|
||||||
{
|
{
|
||||||
|
enum class TargetType {
|
||||||
|
MCU,
|
||||||
|
Desktop
|
||||||
|
};
|
||||||
|
|
||||||
QString qulVersion;
|
QString qulVersion;
|
||||||
QString platform;
|
QString platform;
|
||||||
|
QString platformName;
|
||||||
QString platformVendor;
|
QString platformVendor;
|
||||||
QVector<int> colorDepths;
|
QVector<int> colorDepths;
|
||||||
QString toolchainId;
|
QString toolchainId;
|
||||||
@@ -213,6 +224,7 @@ struct McuTargetDescription
|
|||||||
QString boardSdkDefaultPath;
|
QString boardSdkDefaultPath;
|
||||||
QString freeRTOSEnvVar;
|
QString freeRTOSEnvVar;
|
||||||
QString freeRTOSBoardSdkSubDir;
|
QString freeRTOSBoardSdkSubDir;
|
||||||
|
TargetType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
|
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,
|
static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar, const QString &boardSdkDir,
|
||||||
const QString &freeRTOSBoardSdkSubDir)
|
const QString &freeRTOSBoardSdkSubDir)
|
||||||
{
|
{
|
||||||
const QString envVarPrefix = envVar.chopped(strlen("_FREERTOS_DIR"));
|
const QString envVarPrefix = envVar.chopped(int(strlen("_FREERTOS_DIR")));
|
||||||
|
|
||||||
QString defaultPath;
|
QString defaultPath;
|
||||||
if (qEnvironmentVariableIsSet(envVar.toLatin1()))
|
if (qEnvironmentVariableIsSet(envVar.toLatin1()))
|
||||||
@@ -283,16 +295,16 @@ struct McuTargetFactory
|
|||||||
|
|
||||||
QVector<McuTarget *> createTargets(const McuTargetDescription& description)
|
QVector<McuTarget *> createTargets(const McuTargetDescription& description)
|
||||||
{
|
{
|
||||||
if (description.toolchainId == "desktop") {
|
|
||||||
return createDesktopTargets(description);
|
|
||||||
}
|
|
||||||
auto qulVersion = QVersionNumber::fromString(description.qulVersion);
|
auto qulVersion = QVersionNumber::fromString(description.qulVersion);
|
||||||
if (qulVersion <= QVersionNumber({1,3})) {
|
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
|
// There was a platform backends related refactoring in Qul 1.4
|
||||||
// This requires different processing of McuTargetDescriptions
|
// This requires different processing of McuTargetDescriptions
|
||||||
return createMcuTargetsLegacy(description);
|
return createMcuTargetsLegacy(description);
|
||||||
}
|
}
|
||||||
return createMcuTargets(description);
|
return createTargetsImpl(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<McuPackage *> getMcuPackages() const
|
QVector<McuPackage *> getMcuPackages() const
|
||||||
@@ -305,16 +317,16 @@ struct McuTargetFactory
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Implementation for Qul version <= 1.3
|
// Implementation for Qul version <= 1.3
|
||||||
QVector<McuTarget *> createMcuTargetsLegacy(const McuTargetDescription& desc)
|
QVector<McuTarget *> createMcuTargetsLegacy(const McuTargetDescription &desc)
|
||||||
{
|
{
|
||||||
QVector<McuTarget *> mcuTargets;
|
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 (auto os : {McuTarget::OS::BareMetal, McuTarget::OS::FreeRTOS}) {
|
||||||
for (int colorDepth : desc.colorDepths) {
|
for (int colorDepth : desc.colorDepths) {
|
||||||
QVector<McuPackage*> required3rdPartyPkgs = { tcPkg };
|
QVector<McuPackage*> required3rdPartyPkgs = { tcPkg };
|
||||||
if (vendorPkgs.contains(desc.platformVendor)) {
|
if (vendorPkgs.contains(desc.platformVendor))
|
||||||
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platformVendor));
|
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platformVendor));
|
||||||
}
|
|
||||||
QString boardSdkDefaultPath;
|
QString boardSdkDefaultPath;
|
||||||
if (!desc.boardSdkEnvVar.isEmpty()) {
|
if (!desc.boardSdkEnvVar.isEmpty()) {
|
||||||
if (!boardSdkPkgs.contains(desc.boardSdkEnvVar)) {
|
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),
|
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
||||||
desc.platformVendor, desc.platform, os,
|
platform, os, required3rdPartyPkgs, tcPkg);
|
||||||
required3rdPartyPkgs, tcPkg);
|
|
||||||
if (desc.colorDepths.count() > 1)
|
if (desc.colorDepths.count() > 1)
|
||||||
mcuTarget->setColorDepth(colorDepth);
|
mcuTarget->setColorDepth(colorDepth);
|
||||||
mcuTargets.append(mcuTarget);
|
mcuTargets.append(mcuTarget);
|
||||||
@@ -351,15 +363,39 @@ protected:
|
|||||||
return mcuTargets;
|
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;
|
QVector<McuTarget *> mcuTargets;
|
||||||
auto tcPkg = tcPkgs.value(desc.toolchainId);
|
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchainId);
|
||||||
for (int colorDepth : desc.colorDepths) {
|
for (int colorDepth : desc.colorDepths) {
|
||||||
QVector<McuPackage*> required3rdPartyPkgs = { tcPkg };
|
QVector<McuPackage*> required3rdPartyPkgs;
|
||||||
if (vendorPkgs.contains(desc.platformVendor)) {
|
// 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));
|
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platformVendor));
|
||||||
}
|
|
||||||
|
// Board SDK specific settings
|
||||||
QString boardSdkDefaultPath;
|
QString boardSdkDefaultPath;
|
||||||
if (!desc.boardSdkEnvVar.isEmpty()) {
|
if (!desc.boardSdkEnvVar.isEmpty()) {
|
||||||
if (!boardSdkPkgs.contains(desc.boardSdkEnvVar)) {
|
if (!boardSdkPkgs.contains(desc.boardSdkEnvVar)) {
|
||||||
@@ -371,9 +407,8 @@ protected:
|
|||||||
required3rdPartyPkgs.append(boardSdkPkg);
|
required3rdPartyPkgs.append(boardSdkPkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto os = McuTarget::OS::BareMetal;
|
// Free RTOS specific settings
|
||||||
if (!desc.freeRTOSEnvVar.isEmpty()) {
|
if (!desc.freeRTOSEnvVar.isEmpty()) {
|
||||||
os = McuTarget::OS::FreeRTOS;
|
|
||||||
if (!freeRTOSPkgs.contains(desc.freeRTOSEnvVar)) {
|
if (!freeRTOSPkgs.contains(desc.freeRTOSEnvVar)) {
|
||||||
freeRTOSPkgs.insert(desc.freeRTOSEnvVar, createFreeRTOSSourcesPackage(
|
freeRTOSPkgs.insert(desc.freeRTOSEnvVar, createFreeRTOSSourcesPackage(
|
||||||
desc.freeRTOSEnvVar, boardSdkDefaultPath,
|
desc.freeRTOSEnvVar, boardSdkDefaultPath,
|
||||||
@@ -382,24 +417,15 @@ protected:
|
|||||||
required3rdPartyPkgs.append(freeRTOSPkgs.value(desc.freeRTOSEnvVar));
|
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),
|
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
||||||
desc.platformVendor, desc.platform, os,
|
platform, os, required3rdPartyPkgs, tcPkg);
|
||||||
required3rdPartyPkgs, tcPkg);
|
|
||||||
mcuTarget->setColorDepth(colorDepth);
|
mcuTarget->setColorDepth(colorDepth);
|
||||||
mcuTargets.append(mcuTarget);
|
mcuTargets.append(mcuTarget);
|
||||||
}
|
}
|
||||||
return mcuTargets;
|
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:
|
private:
|
||||||
const QHash<QString, McuToolChainPackage *> &tcPkgs;
|
const QHash<QString, McuToolChainPackage *> &tcPkgs;
|
||||||
const QHash<QString, McuPackage *> &vendorPkgs;
|
const QHash<QString, McuPackage *> &vendorPkgs;
|
||||||
@@ -414,7 +440,8 @@ static QVector<McuTarget *> targetsFromDescriptions(const QList<McuTargetDescrip
|
|||||||
const QHash<QString, McuToolChainPackage *> tcPkgs = {
|
const QHash<QString, McuToolChainPackage *> tcPkgs = {
|
||||||
{{"armgcc"}, createArmGccPackage()},
|
{{"armgcc"}, createArmGccPackage()},
|
||||||
{{"greenhills"}, createGhsToolchainPackage()},
|
{{"greenhills"}, createGhsToolchainPackage()},
|
||||||
{{"desktop"}, createDesktopToolChainPackage()},
|
{{"msvc"}, createMsvcToolChainPackage()},
|
||||||
|
{{"gcc"}, createGccToolChainPackage()},
|
||||||
};
|
};
|
||||||
|
|
||||||
const QHash<QString, McuPackage *> vendorPkgs = {
|
const QHash<QString, McuPackage *> vendorPkgs = {
|
||||||
@@ -452,15 +479,14 @@ static McuTargetDescription parseDescriptionJson(const QByteArray &data)
|
|||||||
const QJsonObject boardSdk = target.value("boardSdk").toObject();
|
const QJsonObject boardSdk = target.value("boardSdk").toObject();
|
||||||
const QJsonObject freeRTOS = target.value("freeRTOS").toObject();
|
const QJsonObject freeRTOS = target.value("freeRTOS").toObject();
|
||||||
|
|
||||||
const QString platform = target.value("platform").toString();
|
|
||||||
|
|
||||||
const QVariantList colorDepths = target.value("colorDepths").toArray().toVariantList();
|
const QVariantList colorDepths = target.value("colorDepths").toArray().toVariantList();
|
||||||
const auto colorDepthsVector = Utils::transform<QVector<int> >(
|
const auto colorDepthsVector = Utils::transform<QVector<int> >(
|
||||||
colorDepths, [&](const QVariant &colorDepth) { return colorDepth.toInt(); });
|
colorDepths, [&](const QVariant &colorDepth) { return colorDepth.toInt(); });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
target.value("qulVersion").toString(),
|
target.value("qulVersion").toString(),
|
||||||
platform,
|
target.value("platform").toString(),
|
||||||
|
target.value("platformName").toString(),
|
||||||
target.value("platformVendor").toString(),
|
target.value("platformVendor").toString(),
|
||||||
colorDepthsVector,
|
colorDepthsVector,
|
||||||
toolchain.value("id").toString(),
|
toolchain.value("id").toString(),
|
||||||
@@ -468,7 +494,8 @@ static McuTargetDescription parseDescriptionJson(const QByteArray &data)
|
|||||||
boardSdk.value("name").toString(),
|
boardSdk.value("name").toString(),
|
||||||
boardSdk.value("defaultPath").toString(),
|
boardSdk.value("defaultPath").toString(),
|
||||||
freeRTOS.value("envVar").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);
|
descriptions.append(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround for missing JSON file for Desktop target:
|
// Workaround for missing JSON file for Desktop target.
|
||||||
Utils::FilePath desktopLib;
|
// Desktop JSON file is shipped starting from Qul 1.5.
|
||||||
if (Utils::HostOsInfo::isWindowsHost())
|
// This whole section could be removed when minimalQulVersion will reach 1.5 or above
|
||||||
desktopLib = dir / "lib/QulQuickUltralite_QT_32bpp_Windows_Release.lib";
|
{
|
||||||
else
|
const bool hasDesktopDescription = Utils::contains(descriptions, [](const McuTargetDescription &desc) {
|
||||||
desktopLib = dir / "lib/libQulQuickUltralite_QT_32bpp_Linux_Debug.a";
|
return desc.type == McuTargetDescription::TargetType::Desktop;
|
||||||
|
});
|
||||||
|
|
||||||
if (desktopLib.exists()) {
|
if (!hasDesktopDescription) {
|
||||||
McuTargetDescription desktopDescription;
|
Utils::FilePath desktopLib;
|
||||||
desktopDescription.qulVersion = descriptions.empty() ?
|
if (Utils::HostOsInfo::isWindowsHost())
|
||||||
McuSupportOptions::minimalQulVersion().toString()
|
desktopLib = dir / "lib/QulQuickUltralite_QT_32bpp_Windows_Release.lib";
|
||||||
: descriptions.first().qulVersion;
|
else
|
||||||
desktopDescription.platform = desktopDescription.platformVendor = "Qt";
|
desktopLib = dir / "lib/libQulQuickUltralite_QT_32bpp_Linux_Debug.a";
|
||||||
desktopDescription.colorDepths = {32};
|
|
||||||
desktopDescription.toolchainId = "desktop";
|
if (desktopLib.exists()) {
|
||||||
descriptions.prepend(desktopDescription);
|
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));
|
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
|
} // namespace Sdk
|
||||||
|
Reference in New Issue
Block a user