forked from qt-creator/qt-creator
McuSupport: support for SDK 2.0
This is a quick fix for the current situation. Proper support will need a rewrite of part of the plugin code. QtQuickUltralite SDK 1.x relies on environment variables for the dependencies. SDK 2.x uses CMake variables for that purpose. Some of the variables have been renamed, others grouped together. Here a mapping between those is hardcoded as an urgent solution. A proper implementation should make the plugin independent of the existence or lack of specific environment variables. Also, all the hardcoded information needs to be moved to the json kit files in the SDK. Otherwise, compatibility breaks between versions every time the built-in assumptions relating to that information change. Task-number: UL-4396 Change-Id: I7f40a694a773881f20b29bae9d02c7c1c8bd747b Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -12,4 +12,5 @@ add_qtc_plugin(McuSupport
|
|||||||
mcusupportsdk.cpp mcusupportsdk.h
|
mcusupportsdk.cpp mcusupportsdk.h
|
||||||
mcusupportrunconfiguration.cpp mcusupportrunconfiguration.h
|
mcusupportrunconfiguration.cpp mcusupportrunconfiguration.h
|
||||||
mcusupportversiondetection.cpp mcusupportversiondetection.h
|
mcusupportversiondetection.cpp mcusupportversiondetection.h
|
||||||
|
mcusupportcmakemapper.cpp mcusupportcmakemapper.h
|
||||||
)
|
)
|
||||||
|
@@ -13,7 +13,8 @@ HEADERS += \
|
|||||||
mcusupportplugin.h \
|
mcusupportplugin.h \
|
||||||
mcusupportsdk.h \
|
mcusupportsdk.h \
|
||||||
mcusupportrunconfiguration.h \
|
mcusupportrunconfiguration.h \
|
||||||
mcusupportversiondetection.h
|
mcusupportversiondetection.h \
|
||||||
|
mcusupportcmakemapper.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
mcusupportdevice.cpp \
|
mcusupportdevice.cpp \
|
||||||
@@ -22,7 +23,8 @@ SOURCES += \
|
|||||||
mcusupportplugin.cpp \
|
mcusupportplugin.cpp \
|
||||||
mcusupportsdk.cpp \
|
mcusupportsdk.cpp \
|
||||||
mcusupportrunconfiguration.cpp \
|
mcusupportrunconfiguration.cpp \
|
||||||
mcusupportversiondetection.cpp
|
mcusupportversiondetection.cpp \
|
||||||
|
mcusupportcmakemapper.cpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
mcusupport.qrc
|
mcusupport.qrc
|
||||||
|
@@ -32,5 +32,7 @@ QtcPlugin {
|
|||||||
"mcusupportrunconfiguration.h",
|
"mcusupportrunconfiguration.h",
|
||||||
"mcusupportversiondetection.cpp",
|
"mcusupportversiondetection.cpp",
|
||||||
"mcusupportversiondetection.h",
|
"mcusupportversiondetection.h",
|
||||||
|
"mcusupportcmakemapper.h",
|
||||||
|
"mcusupportcmakemapper.cpp"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
76
src/plugins/mcusupport/mcusupportcmakemapper.cpp
Normal file
76
src/plugins/mcusupport/mcusupportcmakemapper.cpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#include "mcusupportcmakemapper.h"
|
||||||
|
#include "utils/namevalueitem.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static const QHash<QString, QString> &envVarToCMakeVarMapping()
|
||||||
|
{
|
||||||
|
static const QHash<QString, QString> mapping = {
|
||||||
|
{"EVK_MIMXRT1060_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"EVK_MIMXRT1064_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"EVK_MIMXRT595_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"EVK_MIMXRT1170_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"EVKB_IMXRT1050_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"STM32Cube_FW_F7_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"STM32Cube_FW_F4_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"STM32Cube_FW_L4_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"STM32Cube_FW_H7_SDK_PATH","QUL_BOARD_SDK_DIR"},
|
||||||
|
{"ARMGCC_DIR", "QUL_TARGET_TOOLCHAIN_DIR"},
|
||||||
|
{"IAR_ARM_COMPILER_DIR", "QUL_TARGET_TOOLCHAIN_DIR"},
|
||||||
|
{"GHS_COMPILER_DIR", "QUL_TARGET_TOOLCHAIN_DIR"},
|
||||||
|
{"GHS_ARM_COMPILER_DIR", "QUL_TARGET_TOOLCHAIN_DIR"},
|
||||||
|
{"EVK_MIMXRT1170_FREERTOS_PATH","FREERTOS_DIR"},
|
||||||
|
{"EVK_MIMXRT1170_FREERTOS_PATH","FREERTOS_DIR"},
|
||||||
|
{"IMXRT1064_FREERTOS_DIR","FREERTOS_DIR"},
|
||||||
|
{"IMXRT595_FREERTOS_DIR","FREERTOS_DIR"},
|
||||||
|
{"STM32F7_FREERTOS_DIR", "FREERTOS_DIR"},
|
||||||
|
{"eFlashLoad_PATH","eFlashLoad_PATH"},
|
||||||
|
{"RenesasFlashProgrammer_PATH", "RenesasFlashProgrammer_PATH"},
|
||||||
|
{"MCUXpressoIDE_PATH", "MCUXpressoIDE_PATH"},
|
||||||
|
{"JLINK_PATH", "JLINK_PATH"},
|
||||||
|
{"TVII_GRAPHICS_DRIVER_DIR", "TVII_GRAPHICS_DRIVER_DIR"},
|
||||||
|
{"CYPRESS_AUTO_FLASH_UTILITY_DIR", "CYPRESS_AUTO_FLASH_UTILITY_DIR"},
|
||||||
|
{"EK_RA6M3G_E2_PROJECT_PATH", "EK_RA6M3G_E2_PROJECT_PATH"},
|
||||||
|
{"EK_RA6M3G_FSP_PATH", "EK_RA6M3G_FSP_PATH"},
|
||||||
|
};
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
QList<CMakeProjectManager::CMakeConfigItem> McuSupport::Internal::mapEnvVarsToQul2xCmakeVars(
|
||||||
|
const Utils::EnvironmentItems &envVars)
|
||||||
|
{
|
||||||
|
const auto &mapping = envVarToCMakeVarMapping();
|
||||||
|
auto cmakeVars = Utils::transform(envVars, [mapping](const Utils::EnvironmentItem &envVar) {
|
||||||
|
return CMakeProjectManager::CMakeConfigItem(mapping.value(envVar.name, "").toUtf8(), envVar.value.toUtf8());
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return Utils::filtered(cmakeVars, [](const CMakeProjectManager::CMakeConfigItem &item) {
|
||||||
|
return !item.key.isEmpty();
|
||||||
|
});
|
||||||
|
}
|
35
src/plugins/mcusupport/mcusupportcmakemapper.h
Normal file
35
src/plugins/mcusupport/mcusupportcmakemapper.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cmakeprojectmanager/cmakeconfigitem.h"
|
||||||
|
#include "utils/environmentfwd.h"
|
||||||
|
|
||||||
|
namespace McuSupport {
|
||||||
|
namespace Internal {
|
||||||
|
QList<CMakeProjectManager::CMakeConfigItem> mapEnvVarsToQul2xCmakeVars(
|
||||||
|
const Utils::EnvironmentItems &envVars);
|
||||||
|
}
|
||||||
|
} // namespace McuSupport
|
@@ -27,6 +27,7 @@
|
|||||||
#include "mcusupportoptions.h"
|
#include "mcusupportoptions.h"
|
||||||
#include "mcusupportsdk.h"
|
#include "mcusupportsdk.h"
|
||||||
#include "mcusupportplugin.h"
|
#include "mcusupportplugin.h"
|
||||||
|
#include "mcusupportcmakemapper.h"
|
||||||
|
|
||||||
#include <baremetal/baremetalconstants.h>
|
#include <baremetal/baremetalconstants.h>
|
||||||
#include <cmakeprojectmanager/cmaketoolmanager.h>
|
#include <cmakeprojectmanager/cmaketoolmanager.h>
|
||||||
@@ -70,7 +71,7 @@ using namespace Utils;
|
|||||||
namespace McuSupport {
|
namespace McuSupport {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static const int KIT_VERSION = 8; // Bumps up whenever details in Kit creation change
|
static const int KIT_VERSION = 9; // Bumps up whenever details in Kit creation change
|
||||||
|
|
||||||
static FilePath packagePathFromSettings(const QString &settingsKey,
|
static FilePath packagePathFromSettings(const QString &settingsKey,
|
||||||
QSettings::Scope scope = QSettings::UserScope,
|
QSettings::Scope scope = QSettings::UserScope,
|
||||||
@@ -99,6 +100,22 @@ static bool kitNeedsQtVersion()
|
|||||||
return !HostOsInfo::isWindowsHost();
|
return !HostOsInfo::isWindowsHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void remapQul2xCmakeVars(Kit *kit, const EnvironmentItems &envItems)
|
||||||
|
{
|
||||||
|
using namespace CMakeProjectManager;
|
||||||
|
const auto cmakeVars = mapEnvVarsToQul2xCmakeVars(envItems);
|
||||||
|
const auto cmakeVarNames = Utils::transform(cmakeVars, &CMakeConfigItem::key);
|
||||||
|
|
||||||
|
// First filter out all Qul2.x CMake vars
|
||||||
|
auto config = Utils::filtered(CMakeConfigurationKitAspect::configuration(kit),
|
||||||
|
[&](const auto &configItem) {
|
||||||
|
return !cmakeVarNames.contains(configItem.key);
|
||||||
|
});
|
||||||
|
// Then append them with new values
|
||||||
|
config.append(cmakeVars);
|
||||||
|
CMakeConfigurationKitAspect::setConfiguration(kit, config);
|
||||||
|
}
|
||||||
|
|
||||||
McuPackage::McuPackage(const QString &label, const FilePath &defaultPath,
|
McuPackage::McuPackage(const QString &label, const FilePath &defaultPath,
|
||||||
const QString &detectionPath, const QString &settingsKey,
|
const QString &detectionPath, const QString &settingsKey,
|
||||||
const McuPackageVersionDetector *versionDetector)
|
const McuPackageVersionDetector *versionDetector)
|
||||||
@@ -231,7 +248,7 @@ bool McuPackage::writeToSettings() const
|
|||||||
const FilePath savedPath = packagePathFromSettings(m_settingsKey, QSettings::UserScope, m_defaultPath);
|
const FilePath savedPath = packagePathFromSettings(m_settingsKey, QSettings::UserScope, m_defaultPath);
|
||||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
||||||
QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey;
|
QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey;
|
||||||
Core::ICore::settings()->setValueWithDefault(key, m_path, m_defaultPath);
|
Core::ICore::settings()->setValueWithDefault(key, m_path.toString(), m_defaultPath.toString());
|
||||||
|
|
||||||
return savedPath != m_path;
|
return savedPath != m_path;
|
||||||
}
|
}
|
||||||
@@ -573,6 +590,14 @@ void McuTarget::setColorDepth(int colorDepth)
|
|||||||
m_colorDepth = colorDepth;
|
m_colorDepth = colorDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void McuSdkRepository::deletePackagesAndTargets()
|
||||||
|
{
|
||||||
|
qDeleteAll(packages);
|
||||||
|
packages.clear();
|
||||||
|
qDeleteAll(mcuTargets);
|
||||||
|
mcuTargets.clear();
|
||||||
|
}
|
||||||
|
|
||||||
McuSupportOptions::McuSupportOptions(QObject *parent)
|
McuSupportOptions::McuSupportOptions(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage())
|
, qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage())
|
||||||
@@ -635,14 +660,6 @@ void McuSupportOptions::registerExamples()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportOptions::deletePackagesAndTargets()
|
|
||||||
{
|
|
||||||
qDeleteAll(packages);
|
|
||||||
packages.clear();
|
|
||||||
qDeleteAll(mcuTargets);
|
|
||||||
mcuTargets.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
const QVersionNumber &McuSupportOptions::minimalQulVersion()
|
const QVersionNumber &McuSupportOptions::minimalQulVersion()
|
||||||
{
|
{
|
||||||
static const QVersionNumber v({1, 3});
|
static const QVersionNumber v({1, 3});
|
||||||
@@ -654,8 +671,8 @@ void McuSupportOptions::setQulDir(const FilePath &dir)
|
|||||||
deletePackagesAndTargets();
|
deletePackagesAndTargets();
|
||||||
qtForMCUsSdkPackage->updateStatus();
|
qtForMCUsSdkPackage->updateStatus();
|
||||||
if (qtForMCUsSdkPackage->validStatus())
|
if (qtForMCUsSdkPackage->validStatus())
|
||||||
Sdk::targetsAndPackages(dir, &packages, &mcuTargets);
|
Sdk::targetsAndPackages(dir, &sdkRepository);
|
||||||
for (auto package : qAsConst(packages))
|
for (const auto &package : qAsConst(sdkRepository.packages))
|
||||||
connect(package, &McuPackage::changed, this, &McuSupportOptions::changed);
|
connect(package, &McuPackage::changed, this, &McuSupportOptions::changed);
|
||||||
|
|
||||||
emit changed();
|
emit changed();
|
||||||
@@ -736,6 +753,11 @@ static void setKitDevice(Kit *k, const McuTarget* mcuTarget)
|
|||||||
DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DEVICE_TYPE);
|
DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DEVICE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool expectsCmakeVars(const McuTarget *mcuTarget)
|
||||||
|
{
|
||||||
|
return mcuTarget->qulVersion() >= QVersionNumber{2,0};
|
||||||
|
}
|
||||||
|
|
||||||
static void setKitEnvironment(Kit *k, const McuTarget *mcuTarget,
|
static void setKitEnvironment(Kit *k, const McuTarget *mcuTarget,
|
||||||
const McuPackage *qtForMCUsSdkPackage)
|
const McuPackage *qtForMCUsSdkPackage)
|
||||||
{
|
{
|
||||||
@@ -770,6 +792,11 @@ static void setKitEnvironment(Kit *k, const McuTarget *mcuTarget,
|
|||||||
if (kitNeedsQtVersion())
|
if (kitNeedsQtVersion())
|
||||||
changes.append({QLatin1String("LD_LIBRARY_PATH"), "%{Qt:QT_INSTALL_LIBS}"});
|
changes.append({QLatin1String("LD_LIBRARY_PATH"), "%{Qt:QT_INSTALL_LIBS}"});
|
||||||
|
|
||||||
|
// Hack, this problem should be solved in lower layer
|
||||||
|
if (expectsCmakeVars(mcuTarget)) {
|
||||||
|
remapQul2xCmakeVars(k, changes);
|
||||||
|
}
|
||||||
|
|
||||||
EnvironmentKitAspect::setEnvironmentChanges(k, changes);
|
EnvironmentKitAspect::setEnvironmentChanges(k, changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -812,6 +839,11 @@ static void updateKitEnvironment(Kit *k, const McuTarget *mcuTarget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hack, this problem should be solved in lower layer
|
||||||
|
if (expectsCmakeVars(mcuTarget)) {
|
||||||
|
remapQul2xCmakeVars(k, changes);
|
||||||
|
}
|
||||||
|
|
||||||
EnvironmentKitAspect::setEnvironmentChanges(k, changes);
|
EnvironmentKitAspect::setEnvironmentChanges(k, changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1015,6 +1047,11 @@ bool McuSupportOptions::kitUpToDate(const Kit *kit, const McuTarget *mcuTarget,
|
|||||||
kitDependencyPath(kit, qtForMCUsSdkPackage->environmentVariableName()) == qtForMCUsSdkPackage->path();
|
kitDependencyPath(kit, qtForMCUsSdkPackage->environmentVariableName()) == qtForMCUsSdkPackage->path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void McuSupportOptions::deletePackagesAndTargets()
|
||||||
|
{
|
||||||
|
sdkRepository.deletePackagesAndTargets();
|
||||||
|
}
|
||||||
|
|
||||||
McuSupportOptions::UpgradeOption McuSupportOptions::askForKitUpgrades()
|
McuSupportOptions::UpgradeOption McuSupportOptions::askForKitUpgrades()
|
||||||
{
|
{
|
||||||
QMessageBox upgradePopup(Core::ICore::dialogParent());
|
QMessageBox upgradePopup(Core::ICore::dialogParent());
|
||||||
@@ -1076,12 +1113,11 @@ void McuSupportOptions::createAutomaticKits()
|
|||||||
}
|
}
|
||||||
|
|
||||||
FilePath dir = qtForMCUsPackage->path();
|
FilePath dir = qtForMCUsPackage->path();
|
||||||
QVector<McuPackage*> packages;
|
McuSdkRepository repo;
|
||||||
QVector<McuTarget*> mcuTargets;
|
Sdk::targetsAndPackages(dir, &repo);
|
||||||
Sdk::targetsAndPackages(dir, &packages, &mcuTargets);
|
|
||||||
|
|
||||||
bool needsUpgrade = false;
|
bool needsUpgrade = false;
|
||||||
for (auto target: qAsConst(mcuTargets)) {
|
for (const auto &target: qAsConst(repo.mcuTargets)) {
|
||||||
// if kit already exists, skip
|
// if kit already exists, skip
|
||||||
if (!matchingKits(target, qtForMCUsPackage).empty())
|
if (!matchingKits(target, qtForMCUsPackage).empty())
|
||||||
continue;
|
continue;
|
||||||
@@ -1096,8 +1132,7 @@ void McuSupportOptions::createAutomaticKits()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDeleteAll(packages);
|
repo.deletePackagesAndTargets();
|
||||||
qDeleteAll(mcuTargets);
|
|
||||||
|
|
||||||
if (needsUpgrade)
|
if (needsUpgrade)
|
||||||
McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade();
|
McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade();
|
||||||
@@ -1110,10 +1145,10 @@ void McuSupportOptions::createAutomaticKits()
|
|||||||
|
|
||||||
void McuSupportOptions::checkUpgradeableKits()
|
void McuSupportOptions::checkUpgradeableKits()
|
||||||
{
|
{
|
||||||
if (!qtForMCUsSdkPackage->validStatus() || mcuTargets.length() == 0)
|
if (!qtForMCUsSdkPackage->validStatus() || sdkRepository.mcuTargets.length() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Utils::anyOf(mcuTargets, [this](const McuTarget *target) {
|
if (Utils::anyOf(sdkRepository.mcuTargets, [this](const McuTarget *target) {
|
||||||
return !upgradeableKits(target, this->qtForMCUsSdkPackage).empty() &&
|
return !upgradeableKits(target, this->qtForMCUsSdkPackage).empty() &&
|
||||||
matchingKits(target, this->qtForMCUsSdkPackage).empty();
|
matchingKits(target, this->qtForMCUsSdkPackage).empty();
|
||||||
}))
|
}))
|
||||||
@@ -1128,11 +1163,10 @@ void McuSupportOptions::upgradeKits(UpgradeOption upgradeOption)
|
|||||||
auto qtForMCUsPackage = Sdk::createQtForMCUsPackage();
|
auto qtForMCUsPackage = Sdk::createQtForMCUsPackage();
|
||||||
|
|
||||||
auto dir = qtForMCUsPackage->path();
|
auto dir = qtForMCUsPackage->path();
|
||||||
QVector<McuPackage*> packages;
|
McuSdkRepository repo;
|
||||||
QVector<McuTarget*> mcuTargets;
|
Sdk::targetsAndPackages(dir, &repo);
|
||||||
Sdk::targetsAndPackages(dir, &packages, &mcuTargets);
|
|
||||||
|
|
||||||
for (auto target: qAsConst(mcuTargets)) {
|
for (const auto &target: qAsConst(repo.mcuTargets)) {
|
||||||
if (!matchingKits(target, qtForMCUsPackage).empty())
|
if (!matchingKits(target, qtForMCUsPackage).empty())
|
||||||
// already up-to-date
|
// already up-to-date
|
||||||
continue;
|
continue;
|
||||||
@@ -1149,8 +1183,7 @@ void McuSupportOptions::upgradeKits(UpgradeOption upgradeOption)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDeleteAll(packages);
|
repo.deletePackagesAndTargets();
|
||||||
qDeleteAll(mcuTargets);
|
|
||||||
delete qtForMCUsPackage;
|
delete qtForMCUsPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1166,10 +1199,9 @@ void McuSupportOptions::fixKitsDependencies()
|
|||||||
auto qtForMCUsPackage = Sdk::createQtForMCUsPackage();
|
auto qtForMCUsPackage = Sdk::createQtForMCUsPackage();
|
||||||
|
|
||||||
FilePath dir = qtForMCUsPackage->path();
|
FilePath dir = qtForMCUsPackage->path();
|
||||||
QVector<McuPackage*> packages;
|
McuSdkRepository repo;
|
||||||
QVector<McuTarget*> mcuTargets;
|
Sdk::targetsAndPackages(dir, &repo);
|
||||||
Sdk::targetsAndPackages(dir, &packages, &mcuTargets);
|
for (const auto &target: qAsConst(repo.mcuTargets)) {
|
||||||
for (auto target: qAsConst(mcuTargets)) {
|
|
||||||
if (target->isValid()) {
|
if (target->isValid()) {
|
||||||
for (auto kit : kitsWithMismatchedDependencies(target)) {
|
for (auto kit : kitsWithMismatchedDependencies(target)) {
|
||||||
updateKitEnvironment(kit, target);
|
updateKitEnvironment(kit, target);
|
||||||
@@ -1177,8 +1209,7 @@ void McuSupportOptions::fixKitsDependencies()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDeleteAll(packages);
|
repo.deletePackagesAndTargets();
|
||||||
qDeleteAll(mcuTargets);
|
|
||||||
delete qtForMCUsPackage;
|
delete qtForMCUsPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1242,18 +1273,16 @@ void McuSupportOptions::fixExistingKits()
|
|||||||
qtForMCUsPackage->updateStatus();
|
qtForMCUsPackage->updateStatus();
|
||||||
if (qtForMCUsPackage->validStatus()) {
|
if (qtForMCUsPackage->validStatus()) {
|
||||||
FilePath dir = qtForMCUsPackage->path();
|
FilePath dir = qtForMCUsPackage->path();
|
||||||
QVector<McuPackage*> packages;
|
McuSdkRepository repo;
|
||||||
QVector<McuTarget*> mcuTargets;
|
Sdk::targetsAndPackages(dir, &repo);
|
||||||
Sdk::targetsAndPackages(dir, &packages, &mcuTargets);
|
for (const auto &target: qAsConst(repo.mcuTargets))
|
||||||
for (auto target: qAsConst(mcuTargets))
|
|
||||||
for (auto kit: existingKits(target)) {
|
for (auto kit: existingKits(target)) {
|
||||||
if (McuDependenciesKitAspect::dependencies(kit).isEmpty()) {
|
if (McuDependenciesKitAspect::dependencies(kit).isEmpty()) {
|
||||||
setKitDependencies(kit, target, qtForMCUsPackage);
|
setKitDependencies(kit, target, qtForMCUsPackage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDeleteAll(packages);
|
repo.deletePackagesAndTargets();
|
||||||
qDeleteAll(mcuTargets);
|
|
||||||
}
|
}
|
||||||
delete qtForMCUsPackage;
|
delete qtForMCUsPackage;
|
||||||
}
|
}
|
||||||
|
@@ -200,6 +200,14 @@ private:
|
|||||||
int m_colorDepth = -1;
|
int m_colorDepth = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct McuSdkRepository
|
||||||
|
{
|
||||||
|
QVector<McuPackage*> packages;
|
||||||
|
QVector<McuTarget*> mcuTargets;
|
||||||
|
|
||||||
|
void deletePackagesAndTargets();
|
||||||
|
};
|
||||||
|
|
||||||
class McuSupportOptions : public QObject
|
class McuSupportOptions : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -214,9 +222,8 @@ public:
|
|||||||
McuSupportOptions(QObject *parent = nullptr);
|
McuSupportOptions(QObject *parent = nullptr);
|
||||||
~McuSupportOptions() override;
|
~McuSupportOptions() override;
|
||||||
|
|
||||||
QVector<McuPackage*> packages;
|
|
||||||
QVector<McuTarget*> mcuTargets;
|
|
||||||
McuPackage *qtForMCUsSdkPackage = nullptr;
|
McuPackage *qtForMCUsSdkPackage = nullptr;
|
||||||
|
McuSdkRepository sdkRepository;
|
||||||
|
|
||||||
void setQulDir(const Utils::FilePath &dir);
|
void setQulDir(const Utils::FilePath &dir);
|
||||||
static Utils::FilePath qulDirFromSettings();
|
static Utils::FilePath qulDirFromSettings();
|
||||||
|
@@ -190,7 +190,7 @@ void McuSupportOptionsWidget::updateStatus()
|
|||||||
m_mcuTargetsGroupBox->setVisible(ready);
|
m_mcuTargetsGroupBox->setVisible(ready);
|
||||||
m_packagesGroupBox->setVisible(ready && !mcuTarget->packages().isEmpty());
|
m_packagesGroupBox->setVisible(ready && !mcuTarget->packages().isEmpty());
|
||||||
m_kitCreationGroupBox->setVisible(ready);
|
m_kitCreationGroupBox->setVisible(ready);
|
||||||
m_mcuTargetsInfoLabel->setVisible(valid && m_options.mcuTargets.isEmpty());
|
m_mcuTargetsInfoLabel->setVisible(valid && m_options.sdkRepository.mcuTargets.isEmpty());
|
||||||
if (m_mcuTargetsInfoLabel->isVisible()) {
|
if (m_mcuTargetsInfoLabel->isVisible()) {
|
||||||
m_mcuTargetsInfoLabel->setType(Utils::InfoLabel::NotOk);
|
m_mcuTargetsInfoLabel->setType(Utils::InfoLabel::NotOk);
|
||||||
const Utils::FilePath sdkPath = m_options.qtForMCUsSdkPackage->basePath();
|
const Utils::FilePath sdkPath = m_options.qtForMCUsSdkPackage->basePath();
|
||||||
@@ -261,7 +261,7 @@ void McuSupportOptionsWidget::showMcuTargetPackages()
|
|||||||
row.fieldItem->widget()->hide();
|
row.fieldItem->widget()->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto package : qAsConst(m_options.packages)) {
|
for (auto package : qAsConst(m_options.sdkRepository.packages)) {
|
||||||
QWidget *packageWidget = package->widget();
|
QWidget *packageWidget = package->widget();
|
||||||
if (!mcuTarget->packages().contains(package))
|
if (!mcuTarget->packages().contains(package))
|
||||||
continue;
|
continue;
|
||||||
@@ -275,9 +275,9 @@ void McuSupportOptionsWidget::showMcuTargetPackages()
|
|||||||
McuTarget *McuSupportOptionsWidget::currentMcuTarget() const
|
McuTarget *McuSupportOptionsWidget::currentMcuTarget() const
|
||||||
{
|
{
|
||||||
const int mcuTargetIndex = m_mcuTargetsComboBox->currentIndex();
|
const int mcuTargetIndex = m_mcuTargetsComboBox->currentIndex();
|
||||||
return (mcuTargetIndex == -1 || m_options.mcuTargets.isEmpty())
|
return (mcuTargetIndex == -1 || m_options.sdkRepository.mcuTargets.isEmpty())
|
||||||
? nullptr
|
? nullptr
|
||||||
: m_options.mcuTargets.at(mcuTargetIndex);
|
: m_options.sdkRepository.mcuTargets.at(mcuTargetIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportOptionsWidget::showEvent(QShowEvent *event)
|
void McuSupportOptionsWidget::showEvent(QShowEvent *event)
|
||||||
@@ -292,7 +292,7 @@ void McuSupportOptionsWidget::apply()
|
|||||||
|
|
||||||
m_options.qtForMCUsSdkPackage->writeGeneralSettings();
|
m_options.qtForMCUsSdkPackage->writeGeneralSettings();
|
||||||
pathsChanged |= m_options.qtForMCUsSdkPackage->writeToSettings();
|
pathsChanged |= m_options.qtForMCUsSdkPackage->writeToSettings();
|
||||||
for (auto package : qAsConst(m_options.packages))
|
for (auto package : qAsConst(m_options.sdkRepository.packages))
|
||||||
pathsChanged |= package->writeToSettings();
|
pathsChanged |= package->writeToSettings();
|
||||||
|
|
||||||
if (pathsChanged) {
|
if (pathsChanged) {
|
||||||
@@ -306,7 +306,7 @@ void McuSupportOptionsWidget::populateMcuTargetsComboBox()
|
|||||||
m_options.populatePackagesAndTargets();
|
m_options.populatePackagesAndTargets();
|
||||||
m_mcuTargetsComboBox->clear();
|
m_mcuTargetsComboBox->clear();
|
||||||
m_mcuTargetsComboBox->addItems(
|
m_mcuTargetsComboBox->addItems(
|
||||||
Utils::transform<QStringList>(m_options.mcuTargets, [](McuTarget *t) {
|
Utils::transform<QStringList>(m_options.sdkRepository.mcuTargets, [](McuTarget *t) {
|
||||||
return McuSupportOptions::kitName(t);
|
return McuSupportOptions::kitName(t);
|
||||||
}));
|
}));
|
||||||
updateStatus();
|
updateStatus();
|
||||||
|
@@ -331,19 +331,28 @@ struct McuTargetDescription
|
|||||||
};
|
};
|
||||||
|
|
||||||
QString qulVersion;
|
QString qulVersion;
|
||||||
QString platform;
|
QString compatVersion;
|
||||||
QString platformName;
|
struct {
|
||||||
QString platformVendor;
|
QString id;
|
||||||
QVector<int> colorDepths;
|
QString name;
|
||||||
QString toolchainId;
|
QString vendor;
|
||||||
QVector<QString> toolchainVersions;
|
QVector<int> colorDepths;
|
||||||
QString boardSdkEnvVar;
|
TargetType type;
|
||||||
QString boardSdkName;
|
} platform;
|
||||||
QString boardSdkDefaultPath;
|
struct {
|
||||||
QVector<QString> boardSdkVersions;
|
QString id;
|
||||||
QString freeRTOSEnvVar;
|
QVector<QString> versions;
|
||||||
QString freeRTOSBoardSdkSubDir;
|
} toolchain;
|
||||||
TargetType type;
|
struct {
|
||||||
|
QString name;
|
||||||
|
QString defaultPath;
|
||||||
|
QString envVar;
|
||||||
|
QVector<QString> versions;
|
||||||
|
} boardSdk;
|
||||||
|
struct {
|
||||||
|
QString envVar;
|
||||||
|
QString boardSdkSubDir;
|
||||||
|
} freeRTOS;
|
||||||
};
|
};
|
||||||
|
|
||||||
static McuPackageVersionDetector* generatePackageVersionDetector(QString envVar)
|
static McuPackageVersionDetector* generatePackageVersionDetector(QString envVar)
|
||||||
@@ -373,29 +382,29 @@ static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
|
|||||||
auto sdkName = postfixPos > 0 ? envVar.left(postfixPos) : envVar;
|
auto sdkName = postfixPos > 0 ? envVar.left(postfixPos) : envVar;
|
||||||
return QString::fromLatin1("MCU SDK (%1)").arg(sdkName);
|
return QString::fromLatin1("MCU SDK (%1)").arg(sdkName);
|
||||||
};
|
};
|
||||||
const QString sdkName = desc.boardSdkName.isEmpty() ? generateSdkName(desc.boardSdkEnvVar) : desc.boardSdkName;
|
const QString sdkName = desc.boardSdk.name.isEmpty() ? generateSdkName(desc.boardSdk.envVar) : desc.boardSdk.name;
|
||||||
|
|
||||||
const FilePath defaultPath = [&] {
|
const FilePath defaultPath = [&] {
|
||||||
const auto envVar = desc.boardSdkEnvVar.toLatin1();
|
const auto envVar = desc.boardSdk.envVar.toLatin1();
|
||||||
if (qEnvironmentVariableIsSet(envVar))
|
if (qEnvironmentVariableIsSet(envVar))
|
||||||
return FilePath::fromUserInput(qEnvironmentVariable(envVar));
|
return FilePath::fromUserInput(qEnvironmentVariable(envVar));
|
||||||
if (!desc.boardSdkDefaultPath.isEmpty()) {
|
if (!desc.boardSdk.defaultPath.isEmpty()) {
|
||||||
FilePath defaultPath = FilePath::fromUserInput(QDir::rootPath() + desc.boardSdkDefaultPath);
|
FilePath defaultPath = FilePath::fromUserInput(QDir::rootPath() + desc.boardSdk.defaultPath);
|
||||||
if (defaultPath.exists())
|
if (defaultPath.exists())
|
||||||
return defaultPath;
|
return defaultPath;
|
||||||
}
|
}
|
||||||
return FileUtils::homePath();
|
return FileUtils::homePath();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const auto versionDetector = generatePackageVersionDetector(desc.boardSdkEnvVar);
|
const auto versionDetector = generatePackageVersionDetector(desc.boardSdk.envVar);
|
||||||
|
|
||||||
auto result = new McuPackage(
|
auto result = new McuPackage(
|
||||||
sdkName,
|
sdkName,
|
||||||
defaultPath,
|
defaultPath,
|
||||||
{},
|
{},
|
||||||
desc.boardSdkEnvVar,
|
desc.boardSdk.envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
result->setEnvironmentVariableName(desc.boardSdkEnvVar);
|
result->setEnvironmentVariableName(desc.boardSdk.envVar);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,7 +443,7 @@ struct McuTargetFactory
|
|||||||
{
|
{
|
||||||
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)
|
if (description.platform.type == McuTargetDescription::TargetType::Desktop)
|
||||||
return createDesktopTargetsLegacy(description);
|
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
|
||||||
@@ -459,44 +468,44 @@ protected:
|
|||||||
QVector<McuTarget *> createMcuTargetsLegacy(const McuTargetDescription &desc)
|
QVector<McuTarget *> createMcuTargetsLegacy(const McuTargetDescription &desc)
|
||||||
{
|
{
|
||||||
QVector<McuTarget *> mcuTargets;
|
QVector<McuTarget *> mcuTargets;
|
||||||
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchainId);
|
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchain.id);
|
||||||
if (!tcPkg)
|
if (!tcPkg)
|
||||||
tcPkg = createUnsupportedToolChainPackage();
|
tcPkg = createUnsupportedToolChainPackage();
|
||||||
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.platform.colorDepths) {
|
||||||
QVector<McuPackage*> required3rdPartyPkgs = { tcPkg };
|
QVector<McuPackage*> required3rdPartyPkgs = { tcPkg };
|
||||||
if (vendorPkgs.contains(desc.platformVendor))
|
if (vendorPkgs.contains(desc.platform.vendor))
|
||||||
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platformVendor));
|
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platform.vendor));
|
||||||
|
|
||||||
FilePath boardSdkDefaultPath;
|
FilePath boardSdkDefaultPath;
|
||||||
if (!desc.boardSdkEnvVar.isEmpty()) {
|
if (!desc.boardSdk.envVar.isEmpty()) {
|
||||||
if (!boardSdkPkgs.contains(desc.boardSdkEnvVar)) {
|
if (!boardSdkPkgs.contains(desc.boardSdk.envVar)) {
|
||||||
auto boardSdkPkg = desc.boardSdkEnvVar != "RGL_DIR"
|
auto boardSdkPkg = desc.boardSdk.envVar != "RGL_DIR"
|
||||||
? createBoardSdkPackage(desc)
|
? createBoardSdkPackage(desc)
|
||||||
: createRGLPackage();
|
: createRGLPackage();
|
||||||
boardSdkPkgs.insert(desc.boardSdkEnvVar, boardSdkPkg);
|
boardSdkPkgs.insert(desc.boardSdk.envVar, boardSdkPkg);
|
||||||
}
|
}
|
||||||
auto boardSdkPkg = boardSdkPkgs.value(desc.boardSdkEnvVar);
|
auto boardSdkPkg = boardSdkPkgs.value(desc.boardSdk.envVar);
|
||||||
boardSdkDefaultPath = boardSdkPkg->defaultPath();
|
boardSdkDefaultPath = boardSdkPkg->defaultPath();
|
||||||
required3rdPartyPkgs.append(boardSdkPkg);
|
required3rdPartyPkgs.append(boardSdkPkg);
|
||||||
}
|
}
|
||||||
if (os == McuTarget::OS::FreeRTOS) {
|
if (os == McuTarget::OS::FreeRTOS) {
|
||||||
if (desc.freeRTOSEnvVar.isEmpty()) {
|
if (desc.freeRTOS.envVar.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (!freeRTOSPkgs.contains(desc.freeRTOSEnvVar)) {
|
if (!freeRTOSPkgs.contains(desc.freeRTOS.envVar)) {
|
||||||
freeRTOSPkgs.insert(desc.freeRTOSEnvVar, createFreeRTOSSourcesPackage(
|
freeRTOSPkgs.insert(desc.freeRTOS.envVar, createFreeRTOSSourcesPackage(
|
||||||
desc.freeRTOSEnvVar, boardSdkDefaultPath,
|
desc.freeRTOS.envVar, boardSdkDefaultPath,
|
||||||
desc.freeRTOSBoardSdkSubDir));
|
desc.freeRTOS.boardSdkSubDir));
|
||||||
}
|
}
|
||||||
required3rdPartyPkgs.append(freeRTOSPkgs.value(desc.freeRTOSEnvVar));
|
required3rdPartyPkgs.append(freeRTOSPkgs.value(desc.freeRTOS.envVar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto platform = McuTarget::Platform{ desc.platform, desc.platformName, desc.platformVendor };
|
const auto platform = McuTarget::Platform{ desc.platform.id, desc.platform.name, desc.platform.vendor };
|
||||||
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
||||||
platform, os, required3rdPartyPkgs, tcPkg);
|
platform, os, required3rdPartyPkgs, tcPkg);
|
||||||
if (desc.colorDepths.count() > 1)
|
if (desc.platform.colorDepths.count() > 1)
|
||||||
mcuTarget->setColorDepth(colorDepth);
|
mcuTarget->setColorDepth(colorDepth);
|
||||||
mcuTargets.append(mcuTarget);
|
mcuTargets.append(mcuTarget);
|
||||||
}
|
}
|
||||||
@@ -506,10 +515,10 @@ protected:
|
|||||||
|
|
||||||
QVector<McuTarget *> createDesktopTargetsLegacy(const McuTargetDescription& desc)
|
QVector<McuTarget *> createDesktopTargetsLegacy(const McuTargetDescription& desc)
|
||||||
{
|
{
|
||||||
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchainId);
|
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchain.id);
|
||||||
if (!tcPkg)
|
if (!tcPkg)
|
||||||
tcPkg = createUnsupportedToolChainPackage();
|
tcPkg = createUnsupportedToolChainPackage();
|
||||||
const auto platform = McuTarget::Platform{ desc.platform, desc.platformName, desc.platformVendor };
|
const auto platform = McuTarget::Platform{ desc.platform.id, desc.platform.name, desc.platform.vendor };
|
||||||
auto desktopTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
auto desktopTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
||||||
platform, McuTarget::OS::Desktop, {}, tcPkg);
|
platform, McuTarget::OS::Desktop, {}, tcPkg);
|
||||||
return { desktopTarget };
|
return { desktopTarget };
|
||||||
@@ -519,21 +528,21 @@ protected:
|
|||||||
{
|
{
|
||||||
// OS deduction
|
// OS deduction
|
||||||
const auto os = [&] {
|
const auto os = [&] {
|
||||||
if (desc.type == McuTargetDescription::TargetType::Desktop)
|
if (desc.platform.type == McuTargetDescription::TargetType::Desktop)
|
||||||
return McuTarget::OS::Desktop;
|
return McuTarget::OS::Desktop;
|
||||||
else if (!desc.freeRTOSEnvVar.isEmpty())
|
else if (!desc.freeRTOS.envVar.isEmpty())
|
||||||
return McuTarget::OS::FreeRTOS;
|
return McuTarget::OS::FreeRTOS;
|
||||||
return McuTarget::OS::BareMetal;
|
return McuTarget::OS::BareMetal;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
QVector<McuTarget *> mcuTargets;
|
QVector<McuTarget *> mcuTargets;
|
||||||
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchainId);
|
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchain.id);
|
||||||
if (tcPkg) {
|
if (tcPkg) {
|
||||||
if (QVersionNumber::fromString(desc.qulVersion) >= QVersionNumber({1,8}))
|
if (QVersionNumber::fromString(desc.qulVersion) >= QVersionNumber({1,8}))
|
||||||
tcPkg->setVersions(desc.toolchainVersions);
|
tcPkg->setVersions(desc.toolchain.versions);
|
||||||
} else
|
} else
|
||||||
tcPkg = createUnsupportedToolChainPackage();
|
tcPkg = createUnsupportedToolChainPackage();
|
||||||
for (int colorDepth : desc.colorDepths) {
|
for (int colorDepth : desc.platform.colorDepths) {
|
||||||
QVector<McuPackage*> required3rdPartyPkgs;
|
QVector<McuPackage*> required3rdPartyPkgs;
|
||||||
// Desktop toolchains don't need any additional settings
|
// Desktop toolchains don't need any additional settings
|
||||||
if (tcPkg
|
if (tcPkg
|
||||||
@@ -542,34 +551,34 @@ protected:
|
|||||||
required3rdPartyPkgs.append(tcPkg);
|
required3rdPartyPkgs.append(tcPkg);
|
||||||
|
|
||||||
// Add setting specific to platform IDE
|
// Add setting specific to platform IDE
|
||||||
if (vendorPkgs.contains(desc.platformVendor))
|
if (vendorPkgs.contains(desc.platform.vendor))
|
||||||
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platformVendor));
|
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platform.vendor));
|
||||||
|
|
||||||
// Board SDK specific settings
|
// Board SDK specific settings
|
||||||
FilePath boardSdkDefaultPath;
|
FilePath boardSdkDefaultPath;
|
||||||
if (!desc.boardSdkEnvVar.isEmpty()) {
|
if (!desc.boardSdk.envVar.isEmpty()) {
|
||||||
if (!boardSdkPkgs.contains(desc.boardSdkEnvVar)) {
|
if (!boardSdkPkgs.contains(desc.boardSdk.envVar)) {
|
||||||
auto boardSdkPkg = createBoardSdkPackage(desc);
|
auto boardSdkPkg = createBoardSdkPackage(desc);
|
||||||
boardSdkPkgs.insert(desc.boardSdkEnvVar, boardSdkPkg);
|
boardSdkPkgs.insert(desc.boardSdk.envVar, boardSdkPkg);
|
||||||
}
|
}
|
||||||
auto boardSdkPkg = boardSdkPkgs.value(desc.boardSdkEnvVar);
|
auto boardSdkPkg = boardSdkPkgs.value(desc.boardSdk.envVar);
|
||||||
if (QVersionNumber::fromString(desc.qulVersion) >= QVersionNumber({1,8}))
|
if (QVersionNumber::fromString(desc.qulVersion) >= QVersionNumber({1,8}))
|
||||||
boardSdkPkg->setVersions(desc.boardSdkVersions);
|
boardSdkPkg->setVersions(desc.boardSdk.versions);
|
||||||
boardSdkDefaultPath = boardSdkPkg->defaultPath();
|
boardSdkDefaultPath = boardSdkPkg->defaultPath();
|
||||||
required3rdPartyPkgs.append(boardSdkPkg);
|
required3rdPartyPkgs.append(boardSdkPkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free RTOS specific settings
|
// Free RTOS specific settings
|
||||||
if (!desc.freeRTOSEnvVar.isEmpty()) {
|
if (!desc.freeRTOS.envVar.isEmpty()) {
|
||||||
if (!freeRTOSPkgs.contains(desc.freeRTOSEnvVar)) {
|
if (!freeRTOSPkgs.contains(desc.freeRTOS.envVar)) {
|
||||||
freeRTOSPkgs.insert(desc.freeRTOSEnvVar, createFreeRTOSSourcesPackage(
|
freeRTOSPkgs.insert(desc.freeRTOS.envVar, createFreeRTOSSourcesPackage(
|
||||||
desc.freeRTOSEnvVar, boardSdkDefaultPath,
|
desc.freeRTOS.envVar, boardSdkDefaultPath,
|
||||||
desc.freeRTOSBoardSdkSubDir));
|
desc.freeRTOS.boardSdkSubDir));
|
||||||
}
|
}
|
||||||
required3rdPartyPkgs.append(freeRTOSPkgs.value(desc.freeRTOSEnvVar));
|
required3rdPartyPkgs.append(freeRTOSPkgs.value(desc.freeRTOS.envVar));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto platform = McuTarget::Platform{ desc.platform, desc.platformName, desc.platformVendor };
|
const auto platform = McuTarget::Platform{ desc.platform.id, desc.platform.name, desc.platform.vendor };
|
||||||
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
||||||
platform, os, required3rdPartyPkgs, tcPkg);
|
platform, os, required3rdPartyPkgs, tcPkg);
|
||||||
mcuTarget->setColorDepth(colorDepth);
|
mcuTarget->setColorDepth(colorDepth);
|
||||||
@@ -634,17 +643,20 @@ static QFileInfoList targetDescriptionFiles(const Utils::FilePath &dir)
|
|||||||
return kitsDir.entryInfoList();
|
return kitsDir.entryInfoList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuTargetDescription parseDescriptionJson(const QByteArray &data)
|
static QString extractQulVersion(const QByteArray &data)
|
||||||
{
|
{
|
||||||
const QJsonDocument document = QJsonDocument::fromJson(data);
|
const QJsonDocument document = QJsonDocument::fromJson(data);
|
||||||
const QJsonObject target = document.object();
|
const QJsonObject target = document.object();
|
||||||
|
return target.value("qulVersion").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static McuTargetDescription parseDescriptionJsonCommon(const QString &qulVersion, const QJsonObject &target)
|
||||||
|
{
|
||||||
|
const QString compatVersion = target.value("compatVersion").toString();
|
||||||
const QJsonObject toolchain = target.value("toolchain").toObject();
|
const QJsonObject toolchain = target.value("toolchain").toObject();
|
||||||
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 QVariantList colorDepths = target.value("colorDepths").toArray().toVariantList();
|
|
||||||
const auto colorDepthsVector = Utils::transform<QVector<int> >(
|
|
||||||
colorDepths, [&](const QVariant &colorDepth) { return colorDepth.toInt(); });
|
|
||||||
const QVariantList toolchainVersions = toolchain.value("versions").toArray().toVariantList();
|
const QVariantList toolchainVersions = toolchain.value("versions").toArray().toVariantList();
|
||||||
const auto toolchainVersionsVector = Utils::transform<QVector<QString> >(
|
const auto toolchainVersionsVector = Utils::transform<QVector<QString> >(
|
||||||
toolchainVersions, [&](const QVariant &version) { return version.toString(); });
|
toolchainVersions, [&](const QVariant &version) { return version.toString(); });
|
||||||
@@ -653,23 +665,78 @@ static McuTargetDescription parseDescriptionJson(const QByteArray &data)
|
|||||||
boardSdkVersions, [&](const QVariant &version) { return version.toString(); });
|
boardSdkVersions, [&](const QVariant &version) { return version.toString(); });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
target.value("qulVersion").toString(),
|
qulVersion,
|
||||||
target.value("platform").toString(),
|
compatVersion,
|
||||||
target.value("platformName").toString(),
|
{},
|
||||||
target.value("platformVendor").toString(),
|
{
|
||||||
colorDepthsVector,
|
toolchain.value("id").toString(),
|
||||||
toolchain.value("id").toString(),
|
toolchainVersionsVector,
|
||||||
toolchainVersionsVector,
|
},
|
||||||
boardSdk.value("envVar").toString(),
|
{
|
||||||
boardSdk.value("name").toString(),
|
boardSdk.value("name").toString(),
|
||||||
boardSdk.value("defaultPath").toString(),
|
boardSdk.value("defaultPath").toString(),
|
||||||
boardSdkVersionsVector,
|
boardSdk.value("envVar").toString(),
|
||||||
freeRTOS.value("envVar").toString(),
|
boardSdkVersionsVector,
|
||||||
freeRTOS.value("boardSdkSubDir").toString(),
|
},
|
||||||
boardSdk.empty() ? McuTargetDescription::TargetType::Desktop : McuTargetDescription::TargetType::MCU
|
{
|
||||||
|
freeRTOS.value("envVar").toString(),
|
||||||
|
freeRTOS.value("boardSdkSubDir").toString(),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static McuTargetDescription parseDescriptionJsonV1x(const QString &qulVersion, const QJsonObject &target)
|
||||||
|
{
|
||||||
|
auto description = parseDescriptionJsonCommon(qulVersion, target);
|
||||||
|
|
||||||
|
const QVariantList colorDepths = target.value("colorDepths").toArray().toVariantList();
|
||||||
|
const auto colorDepthsVector = Utils::transform<QVector<int> >(
|
||||||
|
colorDepths, [&](const QVariant &colorDepth) { return colorDepth.toInt(); });
|
||||||
|
|
||||||
|
description.platform = {
|
||||||
|
target.value("platform").toString(),
|
||||||
|
target.value("platformName").toString(),
|
||||||
|
target.value("platformVendor").toString(),
|
||||||
|
colorDepthsVector,
|
||||||
|
description.boardSdk.envVar.isEmpty() ? McuTargetDescription::TargetType::Desktop : McuTargetDescription::TargetType::MCU
|
||||||
|
};
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
static McuTargetDescription parseDescriptionJsonV2x(const QString &qulVersion, const QJsonObject &target)
|
||||||
|
{
|
||||||
|
const QJsonObject platform = target.value("platform").toObject();
|
||||||
|
|
||||||
|
const QVariantList colorDepths = platform.value("colorDepths").toArray().toVariantList();
|
||||||
|
const auto colorDepthsVector = Utils::transform<QVector<int> >(
|
||||||
|
colorDepths, [&](const QVariant &colorDepth) { return colorDepth.toInt(); });
|
||||||
|
const QString platformName = platform.value("platformName").toString();
|
||||||
|
McuTargetDescription description = parseDescriptionJsonCommon(qulVersion, target);
|
||||||
|
description.platform = {
|
||||||
|
platform.value("id").toString(),
|
||||||
|
platformName,
|
||||||
|
platform.value("vendor").toString(),
|
||||||
|
colorDepthsVector,
|
||||||
|
platformName == "Desktop" ? McuTargetDescription::TargetType::Desktop : McuTargetDescription::TargetType::MCU,
|
||||||
|
};
|
||||||
|
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
static McuTargetDescription parseDescriptionJson(const QByteArray &data)
|
||||||
|
{
|
||||||
|
const QJsonDocument document = QJsonDocument::fromJson(data);
|
||||||
|
const QJsonObject target = document.object();
|
||||||
|
|
||||||
|
const QString qulVersion = target.value("qulVersion").toString();
|
||||||
|
|
||||||
|
switch (QVersionNumber::fromString(qulVersion).majorVersion()) {
|
||||||
|
case 1: return parseDescriptionJsonV1x(qulVersion, target);
|
||||||
|
case 2: return parseDescriptionJsonV2x(qulVersion, target);
|
||||||
|
default: return { qulVersion };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://doc.qt.io/qtcreator/creator-developing-mcu.html#supported-qt-for-mcus-sdks
|
// https://doc.qt.io/qtcreator/creator-developing-mcu.html#supported-qt-for-mcus-sdks
|
||||||
const QHash<QString, QString> oldSdkQtcRequiredVersion = {
|
const QHash<QString, QString> oldSdkQtcRequiredVersion = {
|
||||||
{{"1.0"}, {"4.11.x"}},
|
{{"1.0"}, {"4.11.x"}},
|
||||||
@@ -695,8 +762,7 @@ bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packages,
|
void targetsAndPackages(const Utils::FilePath &dir, McuSdkRepository *repo)
|
||||||
QVector<McuTarget *> *mcuTargets)
|
|
||||||
{
|
{
|
||||||
QList<McuTargetDescription> descriptions;
|
QList<McuTargetDescription> descriptions;
|
||||||
|
|
||||||
@@ -706,8 +772,17 @@ void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packa
|
|||||||
if (!file.open(QFile::ReadOnly))
|
if (!file.open(QFile::ReadOnly))
|
||||||
continue;
|
continue;
|
||||||
const McuTargetDescription desc = parseDescriptionJson(file.readAll());
|
const McuTargetDescription desc = parseDescriptionJson(file.readAll());
|
||||||
|
const auto pth = Utils::FilePath::fromString(fileInfo.filePath());
|
||||||
|
bool ok = false;
|
||||||
|
const int compatVersion = desc.compatVersion.toInt(&ok);
|
||||||
|
if (!desc.compatVersion.isEmpty() && ok && compatVersion > MAX_COMPATIBILITY_VERSION) {
|
||||||
|
printMessage(McuTarget::tr("Skipped %1. Unsupported version \"%2\".").arg(
|
||||||
|
QDir::toNativeSeparators(pth.fileNameWithPathComponents(1)),
|
||||||
|
desc.qulVersion),
|
||||||
|
false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (QVersionNumber::fromString(desc.qulVersion) < McuSupportOptions::minimalQulVersion()) {
|
if (QVersionNumber::fromString(desc.qulVersion) < McuSupportOptions::minimalQulVersion()) {
|
||||||
const auto pth = Utils::FilePath::fromString(fileInfo.filePath());
|
|
||||||
const QString qtcSupportText = oldSdkQtcRequiredVersion.contains(desc.qulVersion) ?
|
const QString qtcSupportText = oldSdkQtcRequiredVersion.contains(desc.qulVersion) ?
|
||||||
McuTarget::tr("Detected version \"%1\", only supported by Qt Creator %2.")
|
McuTarget::tr("Detected version \"%1\", only supported by Qt Creator %2.")
|
||||||
.arg(desc.qulVersion, oldSdkQtcRequiredVersion.value(desc.qulVersion))
|
.arg(desc.qulVersion, oldSdkQtcRequiredVersion.value(desc.qulVersion))
|
||||||
@@ -744,7 +819,7 @@ void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packa
|
|||||||
// This whole section could be removed when minimalQulVersion will reach 1.5 or above
|
// This whole section could be removed when minimalQulVersion will reach 1.5 or above
|
||||||
{
|
{
|
||||||
const bool hasDesktopDescription = Utils::contains(descriptions, [](const McuTargetDescription &desc) {
|
const bool hasDesktopDescription = Utils::contains(descriptions, [](const McuTargetDescription &desc) {
|
||||||
return desc.type == McuTargetDescription::TargetType::Desktop;
|
return desc.platform.type == McuTargetDescription::TargetType::Desktop;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!hasDesktopDescription) {
|
if (!hasDesktopDescription) {
|
||||||
@@ -764,12 +839,12 @@ void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packa
|
|||||||
desktopDescription.qulVersion = descriptions.empty() ?
|
desktopDescription.qulVersion = descriptions.empty() ?
|
||||||
McuSupportOptions::minimalQulVersion().toString()
|
McuSupportOptions::minimalQulVersion().toString()
|
||||||
: descriptions.first().qulVersion;
|
: descriptions.first().qulVersion;
|
||||||
desktopDescription.platform = "Qt";
|
desktopDescription.platform.id = "Qt";
|
||||||
desktopDescription.platformName = "Desktop";
|
desktopDescription.platform.name = "Desktop";
|
||||||
desktopDescription.platformVendor = "Qt";
|
desktopDescription.platform.vendor = "Qt";
|
||||||
desktopDescription.colorDepths = {32};
|
desktopDescription.platform.colorDepths = {32};
|
||||||
desktopDescription.toolchainId = Utils::HostOsInfo::isWindowsHost() ? QString("msvc") : QString("gcc");
|
desktopDescription.toolchain.id = Utils::HostOsInfo::isWindowsHost() ? QString("msvc") : QString("gcc");
|
||||||
desktopDescription.type = McuTargetDescription::TargetType::Desktop;
|
desktopDescription.platform.type = McuTargetDescription::TargetType::Desktop;
|
||||||
descriptions.prepend(desktopDescription);
|
descriptions.prepend(desktopDescription);
|
||||||
} else {
|
} else {
|
||||||
if (dir.exists())
|
if (dir.exists())
|
||||||
@@ -782,10 +857,10 @@ void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mcuTargets->append(targetsFromDescriptions(descriptions, packages));
|
repo->mcuTargets.append(targetsFromDescriptions(descriptions, &(repo->packages)));
|
||||||
|
|
||||||
// Keep targets sorted lexicographically
|
// Keep targets sorted lexicographically
|
||||||
std::sort(mcuTargets->begin(), mcuTargets->end(), [] (const McuTarget* lhs, const McuTarget* rhs) {
|
std::sort(repo->mcuTargets.begin(), repo->mcuTargets.end(), [] (const McuTarget* lhs, const McuTarget* rhs) {
|
||||||
return McuSupportOptions::kitName(lhs) < McuSupportOptions::kitName(rhs);
|
return McuSupportOptions::kitName(lhs) < McuSupportOptions::kitName(rhs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -33,17 +33,18 @@ class FilePath;
|
|||||||
|
|
||||||
namespace McuSupport {
|
namespace McuSupport {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class McuPackage;
|
|
||||||
|
#define MAX_COMPATIBILITY_VERSION 1
|
||||||
|
|
||||||
|
class McuSdkRepository;
|
||||||
class McuToolChainPackage;
|
class McuToolChainPackage;
|
||||||
class McuTarget;
|
|
||||||
namespace Sdk {
|
namespace Sdk {
|
||||||
|
|
||||||
McuPackage *createQtForMCUsPackage();
|
McuPackage *createQtForMCUsPackage();
|
||||||
|
|
||||||
bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message);
|
bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message);
|
||||||
|
|
||||||
void targetsAndPackages(const Utils::FilePath &qulDir,
|
void targetsAndPackages(const Utils::FilePath &qulDir, McuSdkRepository *repo);
|
||||||
QVector<McuPackage*> *packages, QVector<McuTarget*> *mcuTargets);
|
|
||||||
|
|
||||||
Utils::FilePath kitsPath(const Utils::FilePath &dir);
|
Utils::FilePath kitsPath(const Utils::FilePath &dir);
|
||||||
|
|
||||||
|
@@ -14,6 +14,10 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
qul_target_qml_sources(%{ProjectName} %{MainQmlFile})
|
qul_target_qml_sources(%{ProjectName} %{MainQmlFile})
|
||||||
|
|
||||||
app_target_setup_os(%{ProjectName})
|
app_target_setup_os(%{ProjectName})
|
||||||
app_target_default_main(%{ProjectName} %{RootItemName})
|
|
||||||
|
if(Qul_VERSION VERSION_GREATER_EQUAL "2.0")
|
||||||
|
app_target_default_entrypoint(%{ProjectName} %{RootItemName})
|
||||||
|
else()
|
||||||
|
app_target_default_main(%{ProjectName} %{RootItemName})
|
||||||
|
endif()
|
||||||
|
Reference in New Issue
Block a user