forked from qt-creator/qt-creator
McuSupport: plugin code formatting
Change-Id: I561bd66431ff3da7819bb9b2ff780197b5593708 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -64,21 +64,24 @@ Tasks McuDependenciesKitAspect::validate(const Kit *k) const
|
||||
|
||||
const QVariant checkFormat = k->value(McuDependenciesKitAspect::id());
|
||||
if (!checkFormat.isNull() && !checkFormat.canConvert(QVariant::List))
|
||||
return { BuildSystemTask(Task::Error, tr("The MCU dependencies setting value is invalid.")) };
|
||||
return {BuildSystemTask(Task::Error, tr("The MCU dependencies setting value is invalid."))};
|
||||
|
||||
const QVariant envStringList = k->value(EnvironmentKitAspect::id());
|
||||
if (!envStringList.isNull() && !envStringList.canConvert(QVariant::List))
|
||||
return { BuildSystemTask(Task::Error, tr("The environment setting value is invalid.")) };
|
||||
return {BuildSystemTask(Task::Error, tr("The environment setting value is invalid."))};
|
||||
|
||||
const auto environment = Utils::NameValueDictionary(envStringList.toStringList());
|
||||
for (const auto &dependency: dependencies(k)) {
|
||||
for (const auto &dependency : dependencies(k)) {
|
||||
if (!environment.hasKey(dependency.name)) {
|
||||
result << BuildSystemTask(Task::Warning, tr("Environment variable %1 not defined.").arg(dependency.name));
|
||||
result << BuildSystemTask(Task::Warning,
|
||||
tr("Environment variable %1 not defined.")
|
||||
.arg(dependency.name));
|
||||
} else {
|
||||
const auto path = Utils::FilePath::fromUserInput(
|
||||
environment.value(dependency.name) + "/" + dependency.value);
|
||||
const auto path = Utils::FilePath::fromUserInput(environment.value(dependency.name)
|
||||
+ "/" + dependency.value);
|
||||
if (!path.exists()) {
|
||||
result << BuildSystemTask(Task::Warning, tr("%1 not found.").arg(path.toUserOutput()));
|
||||
result << BuildSystemTask(Task::Warning,
|
||||
tr("%1 not found.").arg(path.toUserOutput()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +91,7 @@ Tasks McuDependenciesKitAspect::validate(const Kit *k) const
|
||||
|
||||
void McuDependenciesKitAspect::fix(Kit *k)
|
||||
{
|
||||
QTC_ASSERT(k, return);
|
||||
QTC_ASSERT(k, return );
|
||||
|
||||
const QVariant variant = k->value(McuDependenciesKitAspect::id());
|
||||
if (!variant.isNull() && !variant.canConvert(QVariant::List)) {
|
||||
@@ -115,18 +118,19 @@ Utils::Id McuDependenciesKitAspect::id()
|
||||
return "PE.Profile.McuDependencies";
|
||||
}
|
||||
|
||||
|
||||
Utils::NameValueItems McuDependenciesKitAspect::dependencies(const Kit *k)
|
||||
{
|
||||
if (k)
|
||||
return Utils::NameValueItem::fromStringList(k->value(McuDependenciesKitAspect::id()).toStringList());
|
||||
return Utils::NameValueItem::fromStringList(
|
||||
k->value(McuDependenciesKitAspect::id()).toStringList());
|
||||
return Utils::NameValueItems();
|
||||
}
|
||||
|
||||
void McuDependenciesKitAspect::setDependencies(Kit *k, const Utils::NameValueItems &dependencies)
|
||||
{
|
||||
if (k)
|
||||
k->setValue(McuDependenciesKitAspect::id(), Utils::NameValueItem::toStringList(dependencies));
|
||||
k->setValue(McuDependenciesKitAspect::id(),
|
||||
Utils::NameValueItem::toStringList(dependencies));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -44,15 +44,18 @@ namespace Internal {
|
||||
static bool automaticKitCreationFromSettings(QSettings::Scope scope = QSettings::UserScope)
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings(scope);
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
||||
QLatin1String(Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||
+ QLatin1String(Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||
bool automaticKitCreation = settings->value(key, true).toBool();
|
||||
return automaticKitCreation;
|
||||
}
|
||||
|
||||
McuPackage::McuPackage(const QString &label, const FilePath &defaultPath,
|
||||
const QString &detectionPath, const QString &settingsKey,
|
||||
const QString &envVarName, const QString &downloadUrl,
|
||||
McuPackage::McuPackage(const QString &label,
|
||||
const FilePath &defaultPath,
|
||||
const QString &detectionPath,
|
||||
const QString &settingsKey,
|
||||
const QString &envVarName,
|
||||
const QString &downloadUrl,
|
||||
const McuPackageVersionDetector *versionDetector)
|
||||
: m_label(label)
|
||||
, m_defaultPath(Sdk::packagePathFromSettings(settingsKey, QSettings::SystemScope, defaultPath))
|
||||
@@ -98,8 +101,7 @@ QWidget *McuPackage::widget()
|
||||
|
||||
m_widget = new QWidget;
|
||||
m_fileChooser = new PathChooser;
|
||||
m_fileChooser->lineEdit()->setButtonIcon(FancyLineEdit::Right,
|
||||
Icons::RESET.icon());
|
||||
m_fileChooser->lineEdit()->setButtonIcon(FancyLineEdit::Right, Icons::RESET.icon());
|
||||
m_fileChooser->lineEdit()->setButtonVisible(FancyLineEdit::Right, true);
|
||||
connect(m_fileChooser->lineEdit(), &FancyLineEdit::rightButtonClicked, this, [&] {
|
||||
m_fileChooser->setFilePath(m_defaultPath);
|
||||
@@ -124,9 +126,7 @@ QWidget *McuPackage::widget()
|
||||
|
||||
m_fileChooser->setFilePath(m_path);
|
||||
|
||||
QObject::connect(this, &McuPackage::statusChanged, this, [this] {
|
||||
updateStatusUi();
|
||||
});
|
||||
QObject::connect(this, &McuPackage::statusChanged, this, [this] { updateStatusUi(); });
|
||||
|
||||
QObject::connect(m_fileChooser, &PathChooser::pathChanged, this, [this] {
|
||||
updatePath();
|
||||
@@ -144,7 +144,8 @@ McuPackage::Status McuPackage::status() const
|
||||
|
||||
bool McuPackage::validStatus() const
|
||||
{
|
||||
return m_status == McuPackage::ValidPackage || m_status == McuPackage::ValidPackageMismatchedVersion;
|
||||
return m_status == McuPackage::ValidPackage
|
||||
|| m_status == McuPackage::ValidPackageMismatchedVersion;
|
||||
}
|
||||
|
||||
const QString &McuPackage::environmentVariableName() const
|
||||
@@ -164,17 +165,19 @@ bool McuPackage::addToPath() const
|
||||
|
||||
void McuPackage::writeGeneralSettings() const
|
||||
{
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
||||
QLatin1String(Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||
+ QLatin1String(Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->setValue(key, m_automaticKitCreation);
|
||||
}
|
||||
|
||||
bool McuPackage::writeToSettings() const
|
||||
{
|
||||
const FilePath savedPath = Sdk::packagePathFromSettings(m_settingsKey, QSettings::UserScope, m_defaultPath);
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
||||
QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey;
|
||||
const FilePath savedPath = Sdk::packagePathFromSettings(m_settingsKey,
|
||||
QSettings::UserScope,
|
||||
m_defaultPath);
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||
+ QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey;
|
||||
Core::ICore::settings()->setValueWithDefault(key, m_path.toString(), m_defaultPath.toString());
|
||||
|
||||
return savedPath != m_path;
|
||||
@@ -213,15 +216,16 @@ void McuPackage::updateStatus()
|
||||
const FilePath detectionPath = basePath() / m_detectionPath;
|
||||
const bool validPackage = m_detectionPath.isEmpty() || detectionPath.exists();
|
||||
m_detectedVersion = validPath && validPackage && m_versionDetector
|
||||
? m_versionDetector->parseVersion(basePath().toString()) : QString();
|
||||
const bool validVersion = m_detectedVersion.isEmpty() ||
|
||||
m_versions.isEmpty() || m_versions.contains(m_detectedVersion);
|
||||
? m_versionDetector->parseVersion(basePath().toString())
|
||||
: QString();
|
||||
const bool validVersion = m_detectedVersion.isEmpty() || m_versions.isEmpty()
|
||||
|| m_versions.contains(m_detectedVersion);
|
||||
|
||||
m_status = validPath ?
|
||||
( validPackage ?
|
||||
(validVersion ? ValidPackage : ValidPackageMismatchedVersion)
|
||||
: ValidPathInvalidPackage )
|
||||
: m_path.isEmpty() ? EmptyPath : InvalidPath;
|
||||
m_status = validPath
|
||||
? (validPackage ? (validVersion ? ValidPackage : ValidPackageMismatchedVersion)
|
||||
: ValidPathInvalidPackage)
|
||||
: m_path.isEmpty() ? EmptyPath
|
||||
: InvalidPath;
|
||||
|
||||
emit statusChanged();
|
||||
}
|
||||
@@ -229,9 +233,15 @@ void McuPackage::updateStatus()
|
||||
void McuPackage::updateStatusUi()
|
||||
{
|
||||
switch (m_status) {
|
||||
case ValidPackage: m_infoLabel->setType(InfoLabel::Ok); break;
|
||||
case ValidPackageMismatchedVersion: m_infoLabel->setType(InfoLabel::Warning); break;
|
||||
default: m_infoLabel->setType(InfoLabel::NotOk); break;
|
||||
case ValidPackage:
|
||||
m_infoLabel->setType(InfoLabel::Ok);
|
||||
break;
|
||||
case ValidPackageMismatchedVersion:
|
||||
m_infoLabel->setType(InfoLabel::Warning);
|
||||
break;
|
||||
default:
|
||||
m_infoLabel->setType(InfoLabel::NotOk);
|
||||
break;
|
||||
}
|
||||
m_infoLabel->setText(statusText());
|
||||
}
|
||||
@@ -241,28 +251,30 @@ QString McuPackage::statusText() const
|
||||
const QString displayPackagePath = m_path.toUserOutput();
|
||||
const QString displayVersions = m_versions.join(" or ");
|
||||
const QString outDetectionPath = FilePath::fromString(m_detectionPath).toUserOutput();
|
||||
const QString displayRequiredPath = m_versions.empty() ?
|
||||
outDetectionPath :
|
||||
QString("%1 %2").arg(outDetectionPath, displayVersions);
|
||||
const QString displayDetectedPath = m_versions.empty() ?
|
||||
outDetectionPath :
|
||||
QString("%1 %2").arg(outDetectionPath, m_detectedVersion);
|
||||
const QString displayRequiredPath = m_versions.empty() ? outDetectionPath
|
||||
: QString("%1 %2").arg(outDetectionPath,
|
||||
displayVersions);
|
||||
const QString displayDetectedPath = m_versions.empty()
|
||||
? outDetectionPath
|
||||
: QString("%1 %2").arg(outDetectionPath,
|
||||
m_detectedVersion);
|
||||
|
||||
QString response;
|
||||
switch (m_status) {
|
||||
case ValidPackage:
|
||||
response = m_detectionPath.isEmpty()
|
||||
? ( m_detectedVersion.isEmpty()
|
||||
? (m_detectedVersion.isEmpty()
|
||||
? tr("Path %1 exists.").arg(displayPackagePath)
|
||||
: tr("Path %1 exists. Version %2 was found.")
|
||||
.arg(displayPackagePath, m_detectedVersion) )
|
||||
.arg(displayPackagePath, m_detectedVersion))
|
||||
: tr("Path %1 is valid, %2 was found.")
|
||||
.arg(displayPackagePath, displayDetectedPath);
|
||||
break;
|
||||
case ValidPackageMismatchedVersion: {
|
||||
const QString versionWarning = m_versions.size() == 1 ?
|
||||
tr("but only version %1 is supported").arg(m_versions.first()) :
|
||||
tr("but only versions %1 are supported").arg(displayVersions);
|
||||
const QString versionWarning
|
||||
= m_versions.size() == 1
|
||||
? tr("but only version %1 is supported").arg(m_versions.first())
|
||||
: tr("but only versions %1 are supported").arg(displayVersions);
|
||||
response = tr("Path %1 is valid, %2 was found, %3.")
|
||||
.arg(displayPackagePath, displayDetectedPath, versionWarning);
|
||||
break;
|
||||
@@ -277,8 +289,7 @@ QString McuPackage::statusText() const
|
||||
case EmptyPath:
|
||||
response = m_detectionPath.isEmpty()
|
||||
? tr("Path is empty.")
|
||||
: tr("Path is empty, %1 not found.")
|
||||
.arg(displayRequiredPath);
|
||||
: tr("Path is empty, %1 not found.").arg(displayRequiredPath);
|
||||
break;
|
||||
}
|
||||
return response;
|
||||
@@ -288,12 +299,12 @@ McuToolChainPackage::McuToolChainPackage(const QString &label,
|
||||
const FilePath &defaultPath,
|
||||
const QString &detectionPath,
|
||||
const QString &settingsKey,
|
||||
McuToolChainPackage::Type type, const QString &envVarName,
|
||||
McuToolChainPackage::Type type,
|
||||
const QString &envVarName,
|
||||
const McuPackageVersionDetector *versionDetector)
|
||||
: McuPackage(label, defaultPath, detectionPath, settingsKey, envVarName, {}, versionDetector)
|
||||
, m_type(type)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
McuToolChainPackage::Type McuToolChainPackage::type() const
|
||||
{
|
||||
|
@@ -59,9 +59,12 @@ public:
|
||||
ValidPackage
|
||||
};
|
||||
|
||||
McuPackage(const QString &label, const Utils::FilePath &defaultPath,
|
||||
const QString &detectionPath, const QString &settingsKey,
|
||||
const QString &envVarName = {}, const QString &downloadUrl = {},
|
||||
McuPackage(const QString &label,
|
||||
const Utils::FilePath &defaultPath,
|
||||
const QString &detectionPath,
|
||||
const QString &settingsKey,
|
||||
const QString &envVarName = {},
|
||||
const QString &downloadUrl = {},
|
||||
const McuPackageVersionDetector *versionDetector = nullptr);
|
||||
virtual ~McuPackage() = default;
|
||||
|
||||
@@ -122,16 +125,7 @@ private:
|
||||
class McuToolChainPackage : public McuPackage
|
||||
{
|
||||
public:
|
||||
enum class Type {
|
||||
IAR,
|
||||
KEIL,
|
||||
MSVC,
|
||||
GCC,
|
||||
ArmGcc,
|
||||
GHS,
|
||||
GHSArm,
|
||||
Unsupported
|
||||
};
|
||||
enum class Type { IAR, KEIL, MSVC, GCC, ArmGcc, GHS, GHSArm, Unsupported };
|
||||
|
||||
McuToolChainPackage(const QString &label,
|
||||
const Utils::FilePath &defaultPath,
|
||||
@@ -139,8 +133,7 @@ public:
|
||||
const QString &settingsKey,
|
||||
Type type,
|
||||
const QString &envVarName = {},
|
||||
const McuPackageVersionDetector *versionDetector = nullptr
|
||||
);
|
||||
const McuPackageVersionDetector *versionDetector = nullptr);
|
||||
|
||||
Type type() const;
|
||||
bool isDesktopToolchain() const;
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include <QtGlobal>
|
||||
|
||||
#if defined(MCUSUPPORT_LIBRARY)
|
||||
# define MCUSUPPORTSHARED_EXPORT Q_DECL_EXPORT
|
||||
#define MCUSUPPORTSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define MCUSUPPORTSHARED_EXPORT Q_DECL_IMPORT
|
||||
#define MCUSUPPORTSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
@@ -31,15 +31,15 @@ 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"},
|
||||
{"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"},
|
||||
{"RGL_DIR", "QUL_BOARD_SDK_DIR"},
|
||||
{"TVII_GRAPHICS_DRIVER_DIR", "QUL_BOARD_SDK_DIR"},
|
||||
{"EK_RA6M3G_FSP_PATH", "QUL_BOARD_SDK_DIR"},
|
||||
@@ -47,12 +47,12 @@ static const QHash<QString, QString> &envVarToCMakeVarMapping()
|
||||
{"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"},
|
||||
{"IMXRT1050_FREERTOS_DIR","FREERTOS_DIR"},
|
||||
{"IMXRT1064_FREERTOS_DIR","FREERTOS_DIR"},
|
||||
{"IMXRT595_FREERTOS_DIR","FREERTOS_DIR"},
|
||||
{"EVK_MIMXRT1170_FREERTOS_PATH", "FREERTOS_DIR"},
|
||||
{"IMXRT1050_FREERTOS_DIR", "FREERTOS_DIR"},
|
||||
{"IMXRT1064_FREERTOS_DIR", "FREERTOS_DIR"},
|
||||
{"IMXRT595_FREERTOS_DIR", "FREERTOS_DIR"},
|
||||
{"STM32F7_FREERTOS_DIR", "FREERTOS_DIR"},
|
||||
{"eFlashLoad_PATH","eFlashLoad_PATH"},
|
||||
{"eFlashLoad_PATH", "eFlashLoad_PATH"},
|
||||
{"RenesasFlashProgrammer_PATH", "RENESAS_FLASH_PROGRAMMER_PATH"},
|
||||
{"MCUXpressoIDE_PATH", "MCUXPRESSO_IDE_PATH"},
|
||||
{"JLINK_PATH", "JLINK_PATH"},
|
||||
@@ -67,8 +67,10 @@ QList<CMakeProjectManager::CMakeConfigItem> McuSupport::Internal::mapEnvVarsToQu
|
||||
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());
|
||||
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) {
|
||||
|
@@ -46,5 +46,5 @@ const char SETTINGS_KEY_PACKAGE_PREFIX[] = "Package_";
|
||||
const char SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK[] = "QtForMCUsSdk"; // Key known by SDK installer
|
||||
const char SETTINGS_KEY_AUTOMATIC_KIT_CREATION[] = "AutomaticKitCreation";
|
||||
|
||||
} // namespace McuSupport
|
||||
} // namespace Constants
|
||||
} // namespace McuSupport
|
||||
|
@@ -23,8 +23,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mcusupportconstants.h"
|
||||
#include "mcusupportdevice.h"
|
||||
#include "mcusupportconstants.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/deviceprocess.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
|
@@ -23,39 +23,38 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mcusupportoptions.h"
|
||||
#include "mcukitinformation.h"
|
||||
#include "mcupackage.h"
|
||||
#include "mcusupportconstants.h"
|
||||
#include "mcusupportoptions.h"
|
||||
#include "mcusupportsdk.h"
|
||||
#include "mcusupportplugin.h"
|
||||
#include "mcusupportcmakemapper.h"
|
||||
#include "mcusupportconstants.h"
|
||||
#include "mcusupportplugin.h"
|
||||
#include "mcusupportsdk.h"
|
||||
|
||||
#include <baremetal/baremetalconstants.h>
|
||||
#include <cmakeprojectmanager/cmakekitinformation.h>
|
||||
#include <cmakeprojectmanager/cmaketoolmanager.h>
|
||||
#include <cmakeprojectmanager/cmakekitinformation.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <cmakeprojectmanager/cmakekitinformation.h>
|
||||
#include <debugger/debuggeritem.h>
|
||||
#include <debugger/debuggeritemmanager.h>
|
||||
#include <debugger/debuggerkitinformation.h>
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/infolabel.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
@@ -98,15 +97,14 @@ static void remapQul2xCmakeVars(Kit *kit, const EnvironmentItems &envItems)
|
||||
CMakeConfigurationKitAspect::setConfiguration(kit, config);
|
||||
}
|
||||
|
||||
|
||||
static ToolChain *msvcToolChain(Id language)
|
||||
{
|
||||
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
||||
const Abi abi = t->targetAbi();
|
||||
// TODO: Should Abi::WindowsMsvc2022Flavor be added too?
|
||||
return (abi.osFlavor() == Abi::WindowsMsvc2017Flavor || abi.osFlavor() == Abi::WindowsMsvc2019Flavor)
|
||||
&& abi.architecture() == Abi::X86Architecture
|
||||
&& abi.wordWidth() == 64
|
||||
return (abi.osFlavor() == Abi::WindowsMsvc2017Flavor
|
||||
|| abi.osFlavor() == Abi::WindowsMsvc2019Flavor)
|
||||
&& abi.architecture() == Abi::X86Architecture && abi.wordWidth() == 64
|
||||
&& t->language() == language;
|
||||
});
|
||||
return toolChain;
|
||||
@@ -116,26 +114,26 @@ static ToolChain *gccToolChain(Id language)
|
||||
{
|
||||
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
||||
const Abi abi = t->targetAbi();
|
||||
return abi.os() != Abi::WindowsOS
|
||||
&& abi.architecture() == Abi::X86Architecture
|
||||
&& abi.wordWidth() == 64
|
||||
&& t->language() == language;
|
||||
return abi.os() != Abi::WindowsOS && abi.architecture() == Abi::X86Architecture
|
||||
&& abi.wordWidth() == 64 && t->language() == language;
|
||||
});
|
||||
return toolChain;
|
||||
}
|
||||
|
||||
static ToolChain *armGccToolChain(const FilePath &path, Id language)
|
||||
{
|
||||
ToolChain *toolChain = ToolChainManager::toolChain([&path, language](const ToolChain *t){
|
||||
ToolChain *toolChain = ToolChainManager::toolChain([&path, language](const ToolChain *t) {
|
||||
return t->compilerCommand() == path && t->language() == language;
|
||||
});
|
||||
if (!toolChain) {
|
||||
ToolChainFactory *gccFactory =
|
||||
Utils::findOrDefault(ToolChainFactory::allToolChainFactories(), [](ToolChainFactory *f){
|
||||
return f->supportedToolChainType() == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID;
|
||||
ToolChainFactory *gccFactory
|
||||
= Utils::findOrDefault(ToolChainFactory::allToolChainFactories(),
|
||||
[](ToolChainFactory *f) {
|
||||
return f->supportedToolChainType()
|
||||
== ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID;
|
||||
});
|
||||
if (gccFactory) {
|
||||
const QList<ToolChain*> detected = gccFactory->detectForImport({path, language});
|
||||
const QList<ToolChain *> detected = gccFactory->detectForImport({path, language});
|
||||
if (!detected.isEmpty()) {
|
||||
toolChain = detected.first();
|
||||
toolChain->setDetection(ToolChain::ManualDetection);
|
||||
@@ -150,20 +148,22 @@ static ToolChain *armGccToolChain(const FilePath &path, Id language)
|
||||
|
||||
static ToolChain *iarToolChain(const FilePath &path, Id language)
|
||||
{
|
||||
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t){
|
||||
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
||||
return t->typeId() == BareMetal::Constants::IAREW_TOOLCHAIN_TYPEID
|
||||
&& t->language() == language;
|
||||
});
|
||||
if (!toolChain) {
|
||||
ToolChainFactory *iarFactory =
|
||||
Utils::findOrDefault(ToolChainFactory::allToolChainFactories(), [](ToolChainFactory *f){
|
||||
return f->supportedToolChainType() == BareMetal::Constants::IAREW_TOOLCHAIN_TYPEID;
|
||||
ToolChainFactory *iarFactory
|
||||
= Utils::findOrDefault(ToolChainFactory::allToolChainFactories(),
|
||||
[](ToolChainFactory *f) {
|
||||
return f->supportedToolChainType()
|
||||
== BareMetal::Constants::IAREW_TOOLCHAIN_TYPEID;
|
||||
});
|
||||
if (iarFactory) {
|
||||
Toolchains detected = iarFactory->autoDetect(ToolchainDetector({}, {}));
|
||||
if (detected.isEmpty())
|
||||
detected = iarFactory->detectForImport({path, language});
|
||||
for (auto tc: detected) {
|
||||
for (auto tc : detected) {
|
||||
if (tc->language() == language) {
|
||||
toolChain = tc;
|
||||
toolChain->setDetection(ToolChain::ManualDetection);
|
||||
@@ -210,12 +210,18 @@ ToolChain *McuToolChainPackage::toolChain(Id language) const
|
||||
QString McuToolChainPackage::toolChainName() const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::ArmGcc: return QLatin1String("armgcc");
|
||||
case Type::IAR: return QLatin1String("iar");
|
||||
case Type::KEIL: return QLatin1String("keil");
|
||||
case Type::GHS: return QLatin1String("ghs");
|
||||
case Type::GHSArm: return QLatin1String("ghs-arm");
|
||||
default: return QLatin1String("unsupported");
|
||||
case Type::ArmGcc:
|
||||
return QLatin1String("armgcc");
|
||||
case Type::IAR:
|
||||
return QLatin1String("iar");
|
||||
case Type::KEIL:
|
||||
return QLatin1String("keil");
|
||||
case Type::GHS:
|
||||
return QLatin1String("ghs");
|
||||
case Type::GHSArm:
|
||||
return QLatin1String("ghs-arm");
|
||||
default:
|
||||
return QLatin1String("unsupported");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,8 +284,7 @@ McuTarget::McuTarget(const QVersionNumber &qulVersion,
|
||||
, m_packages(packages)
|
||||
, m_toolChainPackage(toolChainPackage)
|
||||
, m_colorDepth(colorDepth)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
const QVector<McuPackage *> &McuTarget::packages() const
|
||||
{
|
||||
@@ -311,17 +316,17 @@ bool McuTarget::isValid() const
|
||||
|
||||
void McuTarget::printPackageProblems() const
|
||||
{
|
||||
for (auto package: packages()) {
|
||||
for (auto package : packages()) {
|
||||
package->updateStatus();
|
||||
if (!package->validStatus())
|
||||
printMessage(tr("Error creating kit for target %1, package %2: %3").arg(
|
||||
McuSupportOptions::kitName(this),
|
||||
printMessage(tr("Error creating kit for target %1, package %2: %3")
|
||||
.arg(McuSupportOptions::kitName(this),
|
||||
package->label(),
|
||||
package->statusText()),
|
||||
true);
|
||||
if (package->status() == McuPackage::ValidPackageMismatchedVersion)
|
||||
printMessage(tr("Warning creating kit for target %1, package %2: %3").arg(
|
||||
McuSupportOptions::kitName(this),
|
||||
printMessage(tr("Warning creating kit for target %1, package %2: %3")
|
||||
.arg(McuSupportOptions::kitName(this),
|
||||
package->label(),
|
||||
package->statusText()),
|
||||
false);
|
||||
@@ -350,8 +355,10 @@ McuSupportOptions::McuSupportOptions(QObject *parent)
|
||||
: QObject(parent)
|
||||
, qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage())
|
||||
{
|
||||
connect(qtForMCUsSdkPackage, &McuPackage::changed,
|
||||
this, &McuSupportOptions::populatePackagesAndTargets);
|
||||
connect(qtForMCUsSdkPackage,
|
||||
&McuPackage::changed,
|
||||
this,
|
||||
&McuSupportOptions::populatePackagesAndTargets);
|
||||
}
|
||||
|
||||
McuSupportOptions::~McuSupportOptions()
|
||||
@@ -382,9 +389,8 @@ void McuSupportOptions::registerQchFiles()
|
||||
|
||||
const QFileInfoList qchFiles = QDir(docsDir, "*.qch").entryInfoList();
|
||||
Core::HelpManager::registerDocumentation(
|
||||
Utils::transform<QStringList>(qchFiles, [](const QFileInfo &fi){
|
||||
return fi.absoluteFilePath();
|
||||
}));
|
||||
Utils::transform<QStringList>(qchFiles,
|
||||
[](const QFileInfo &fi) { return fi.absoluteFilePath(); }));
|
||||
}
|
||||
|
||||
void McuSupportOptions::registerExamples()
|
||||
@@ -393,17 +399,15 @@ void McuSupportOptions::registerExamples()
|
||||
if (docsDir.isEmpty())
|
||||
return;
|
||||
|
||||
auto examples = {
|
||||
std::make_pair(QStringLiteral("demos"), tr("Qt for MCUs Demos")),
|
||||
std::make_pair(QStringLiteral("examples"), tr("Qt for MCUs Examples"))
|
||||
};
|
||||
auto examples = {std::make_pair(QStringLiteral("demos"), tr("Qt for MCUs Demos")),
|
||||
std::make_pair(QStringLiteral("examples"), tr("Qt for MCUs Examples"))};
|
||||
for (const auto &dir : examples) {
|
||||
const FilePath examplesDir =
|
||||
McuSupportOptions::qulDirFromSettings().pathAppended(dir.first);
|
||||
const FilePath examplesDir = McuSupportOptions::qulDirFromSettings().pathAppended(dir.first);
|
||||
if (!examplesDir.exists())
|
||||
continue;
|
||||
|
||||
QtSupport::QtVersionManager::registerExampleSet(dir.second, docsDir.toString(),
|
||||
QtSupport::QtVersionManager::registerExampleSet(dir.second,
|
||||
docsDir.toString(),
|
||||
examplesDir.toString());
|
||||
}
|
||||
}
|
||||
@@ -432,7 +436,9 @@ FilePath McuSupportOptions::qulDirFromSettings()
|
||||
QSettings::UserScope);
|
||||
}
|
||||
|
||||
static void setKitProperties(const QString &kitName, Kit *k, const McuTarget *mcuTarget,
|
||||
static void setKitProperties(const QString &kitName,
|
||||
Kit *k,
|
||||
const McuTarget *mcuTarget,
|
||||
const FilePath &sdkPath)
|
||||
{
|
||||
using namespace Constants;
|
||||
@@ -521,7 +527,7 @@ static void setKitDebugger(Kit *k, const McuToolChainPackage *tcPackage)
|
||||
}
|
||||
}
|
||||
|
||||
static void setKitDevice(Kit *k, const McuTarget* mcuTarget)
|
||||
static void setKitDevice(Kit *k, const McuTarget *mcuTarget)
|
||||
{
|
||||
// "Device Type" Desktop is the default. We use that for the Qt for MCUs Desktop Kit
|
||||
if (mcuTarget->toolChainPackage()->isDesktopToolchain())
|
||||
@@ -532,10 +538,11 @@ static void setKitDevice(Kit *k, const McuTarget* mcuTarget)
|
||||
|
||||
static bool expectsCmakeVars(const McuTarget *mcuTarget)
|
||||
{
|
||||
return mcuTarget->qulVersion() >= QVersionNumber{2,0};
|
||||
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)
|
||||
{
|
||||
EnvironmentItems changes;
|
||||
@@ -559,7 +566,7 @@ static void setKitEnvironment(Kit *k, const McuTarget *mcuTarget,
|
||||
processPackage(qtForMCUsSdkPackage);
|
||||
|
||||
// Clang not needed in version 1.7+
|
||||
if (mcuTarget->qulVersion() < QVersionNumber{1,7}) {
|
||||
if (mcuTarget->qulVersion() < QVersionNumber{1, 7}) {
|
||||
const QString path = QLatin1String(HostOsInfo::isWindowsHost() ? "Path" : "PATH");
|
||||
pathAdditions.append("${" + path + "}");
|
||||
pathAdditions.append(Core::ICore::libexecPath("clang/bin").toUserOutput());
|
||||
@@ -577,7 +584,8 @@ static void setKitEnvironment(Kit *k, const McuTarget *mcuTarget,
|
||||
EnvironmentKitAspect::setEnvironmentChanges(k, changes);
|
||||
}
|
||||
|
||||
static void setKitDependencies(Kit *k, const McuTarget *mcuTarget,
|
||||
static void setKitDependencies(Kit *k,
|
||||
const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdkPackage)
|
||||
{
|
||||
NameValueItems dependencies;
|
||||
@@ -624,43 +632,44 @@ static void updateKitEnvironment(Kit *k, const McuTarget *mcuTarget)
|
||||
EnvironmentKitAspect::setEnvironmentChanges(k, changes);
|
||||
}
|
||||
|
||||
static void setKitCMakeOptions(Kit *k, const McuTarget* mcuTarget, const FilePath &qulDir)
|
||||
static void setKitCMakeOptions(Kit *k, const McuTarget *mcuTarget, const FilePath &qulDir)
|
||||
{
|
||||
using namespace CMakeProjectManager;
|
||||
|
||||
CMakeConfig config = CMakeConfigurationKitAspect::configuration(k);
|
||||
// CMake ToolChain file for ghs handles CMAKE_*_COMPILER autonomously
|
||||
if (mcuTarget->toolChainPackage()->type() != McuToolChainPackage::Type::GHS &&
|
||||
mcuTarget->toolChainPackage()->type() != McuToolChainPackage::Type::GHSArm) {
|
||||
if (mcuTarget->toolChainPackage()->type() != McuToolChainPackage::Type::GHS
|
||||
&& mcuTarget->toolChainPackage()->type() != McuToolChainPackage::Type::GHSArm) {
|
||||
config.append(CMakeConfigItem("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}"));
|
||||
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
|
||||
}
|
||||
|
||||
if (!mcuTarget->toolChainPackage()->isDesktopToolchain()) {
|
||||
const FilePath cMakeToolchainFile = qulDir.pathAppended("lib/cmake/Qul/toolchain/"
|
||||
+ mcuTarget->toolChainPackage()->cmakeToolChainFileName());
|
||||
const FilePath cMakeToolchainFile = qulDir.pathAppended(
|
||||
"lib/cmake/Qul/toolchain/" + mcuTarget->toolChainPackage()->cmakeToolChainFileName());
|
||||
|
||||
config.append(CMakeConfigItem(
|
||||
"CMAKE_TOOLCHAIN_FILE",
|
||||
cMakeToolchainFile.toString().toUtf8()));
|
||||
config.append(
|
||||
CMakeConfigItem("CMAKE_TOOLCHAIN_FILE", cMakeToolchainFile.toString().toUtf8()));
|
||||
if (!cMakeToolchainFile.exists()) {
|
||||
printMessage(McuTarget::tr("Warning for target %1: missing CMake toolchain file expected at %2.")
|
||||
.arg(McuSupportOptions::kitName(mcuTarget), cMakeToolchainFile.toUserOutput()), false);
|
||||
printMessage(McuTarget::tr(
|
||||
"Warning for target %1: missing CMake toolchain file expected at %2.")
|
||||
.arg(McuSupportOptions::kitName(mcuTarget),
|
||||
cMakeToolchainFile.toUserOutput()),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
const FilePath generatorsPath = qulDir.pathAppended("/lib/cmake/Qul/QulGenerators.cmake");
|
||||
config.append(CMakeConfigItem("QUL_GENERATORS",
|
||||
generatorsPath.toString().toUtf8()));
|
||||
config.append(CMakeConfigItem("QUL_GENERATORS", generatorsPath.toString().toUtf8()));
|
||||
if (!generatorsPath.exists()) {
|
||||
printMessage(McuTarget::tr("Warning for target %1: missing QulGenerators expected at %2.")
|
||||
.arg(McuSupportOptions::kitName(mcuTarget), generatorsPath.toUserOutput()), false);
|
||||
.arg(McuSupportOptions::kitName(mcuTarget), generatorsPath.toUserOutput()),
|
||||
false);
|
||||
}
|
||||
|
||||
config.append(CMakeConfigItem("QUL_PLATFORM",
|
||||
mcuTarget->platform().name.toUtf8()));
|
||||
config.append(CMakeConfigItem("QUL_PLATFORM", 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)
|
||||
config.append(CMakeConfigItem("OS", "FreeRTOS"));
|
||||
if (mcuTarget->colorDepth() != McuTarget::UnspecifiedColorDepth)
|
||||
@@ -690,13 +699,15 @@ static void setKitQtVersionOptions(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 McuToolChainPackage *tcPkg = mcuTarget->toolChainPackage();
|
||||
const QString compilerName = tcPkg && !tcPkg->isDesktopToolchain()
|
||||
? QString::fromLatin1(" (%1)").arg(tcPkg->toolChainName().toUpper())
|
||||
? QString::fromLatin1(" (%1)").arg(
|
||||
tcPkg->toolChainName().toUpper())
|
||||
: "";
|
||||
const QString colorDepth = mcuTarget->colorDepth() != McuTarget::UnspecifiedColorDepth
|
||||
? QString::fromLatin1(" %1bpp").arg(mcuTarget->colorDepth())
|
||||
@@ -718,26 +729,27 @@ QList<Kit *> McuSupportOptions::existingKits(const McuTarget *mcuTarget)
|
||||
using namespace Constants;
|
||||
return Utils::filtered(KitManager::kits(), [mcuTarget](Kit *kit) {
|
||||
return kit->value(KIT_MCUTARGET_KITVERSION_KEY) == KIT_VERSION
|
||||
&& (!mcuTarget || (
|
||||
kit->value(KIT_MCUTARGET_VENDOR_KEY) == mcuTarget->platform().vendor
|
||||
&& (!mcuTarget
|
||||
|| (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())
|
||||
&& kit->value(KIT_MCUTARGET_TOOCHAIN_KEY)
|
||||
== mcuTarget->toolChainPackage()->toolChainName()
|
||||
));
|
||||
== mcuTarget->toolChainPackage()->toolChainName()));
|
||||
});
|
||||
}
|
||||
|
||||
QList<Kit *> McuSupportOptions::matchingKits(const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdkPackage)
|
||||
QList<Kit *> McuSupportOptions::matchingKits(const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdkPackage)
|
||||
{
|
||||
return Utils::filtered(existingKits(mcuTarget), [mcuTarget, qtForMCUsSdkPackage](Kit *kit) {
|
||||
return kitUpToDate(kit, mcuTarget, qtForMCUsSdkPackage);
|
||||
});
|
||||
}
|
||||
|
||||
QList<Kit *> McuSupportOptions::upgradeableKits(const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdkPackage)
|
||||
QList<Kit *> McuSupportOptions::upgradeableKits(const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdkPackage)
|
||||
{
|
||||
return Utils::filtered(existingKits(mcuTarget), [mcuTarget, qtForMCUsSdkPackage](Kit *kit) {
|
||||
return !kitUpToDate(kit, mcuTarget, qtForMCUsSdkPackage);
|
||||
@@ -748,11 +760,11 @@ QList<Kit *> McuSupportOptions::kitsWithMismatchedDependencies(const McuTarget *
|
||||
{
|
||||
return Utils::filtered(existingKits(mcuTarget), [mcuTarget](Kit *kit) {
|
||||
const auto environment = Utils::NameValueDictionary(
|
||||
Utils::NameValueItem::toStringList(
|
||||
EnvironmentKitAspect::environmentChanges(kit)));
|
||||
Utils::NameValueItem::toStringList(EnvironmentKitAspect::environmentChanges(kit)));
|
||||
return Utils::anyOf(mcuTarget->packages(), [&environment](const McuPackage *package) {
|
||||
return !package->environmentVariableName().isEmpty() &&
|
||||
environment.value(package->environmentVariableName()) != package->path().toUserOutput();
|
||||
return !package->environmentVariableName().isEmpty()
|
||||
&& environment.value(package->environmentVariableName())
|
||||
!= package->path().toUserOutput();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -794,7 +806,8 @@ Kit *McuSupportOptions::newKit(const McuTarget *mcuTarget, const McuPackage *qtF
|
||||
|
||||
void printMessage(const QString &message, bool important)
|
||||
{
|
||||
const QString displayMessage = QCoreApplication::translate("QtForMCUs", "Qt for MCUs: %1").arg(message);
|
||||
const QString displayMessage = QCoreApplication::translate("QtForMCUs", "Qt for MCUs: %1")
|
||||
.arg(message);
|
||||
if (important)
|
||||
Core::MessageManager::writeFlashing(displayMessage);
|
||||
else
|
||||
@@ -804,8 +817,7 @@ void printMessage(const QString &message, bool important)
|
||||
QVersionNumber McuSupportOptions::kitQulVersion(const Kit *kit)
|
||||
{
|
||||
return QVersionNumber::fromString(
|
||||
kit->value(McuSupport::Constants::KIT_MCUTARGET_SDKVERSION_KEY)
|
||||
.toString());
|
||||
kit->value(McuSupport::Constants::KIT_MCUTARGET_SDKVERSION_KEY).toString());
|
||||
}
|
||||
|
||||
static FilePath kitDependencyPath(const Kit *kit, const QString &variableName)
|
||||
@@ -817,11 +829,13 @@ static FilePath kitDependencyPath(const Kit *kit, const QString &variableName)
|
||||
return FilePath();
|
||||
}
|
||||
|
||||
bool McuSupportOptions::kitUpToDate(const Kit *kit, const McuTarget *mcuTarget,
|
||||
bool McuSupportOptions::kitUpToDate(const Kit *kit,
|
||||
const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdkPackage)
|
||||
{
|
||||
return kitQulVersion(kit) == mcuTarget->qulVersion() &&
|
||||
kitDependencyPath(kit, qtForMCUsSdkPackage->environmentVariableName()).toUserOutput() == qtForMCUsSdkPackage->path().toUserOutput();
|
||||
return kitQulVersion(kit) == mcuTarget->qulVersion()
|
||||
&& kitDependencyPath(kit, qtForMCUsSdkPackage->environmentVariableName()).toUserOutput()
|
||||
== qtForMCUsSdkPackage->path().toUserOutput();
|
||||
}
|
||||
|
||||
void McuSupportOptions::deletePackagesAndTargets()
|
||||
@@ -833,8 +847,9 @@ McuSupportOptions::UpgradeOption McuSupportOptions::askForKitUpgrades()
|
||||
{
|
||||
QMessageBox upgradePopup(Core::ICore::dialogParent());
|
||||
upgradePopup.setStandardButtons(QMessageBox::Cancel);
|
||||
QPushButton *replaceButton = upgradePopup.addButton(tr("Replace Existing Kits"),QMessageBox::NoRole);
|
||||
QPushButton *keepButton = upgradePopup.addButton(tr("Create New Kits"),QMessageBox::NoRole);
|
||||
QPushButton *replaceButton = upgradePopup.addButton(tr("Replace Existing Kits"),
|
||||
QMessageBox::NoRole);
|
||||
QPushButton *keepButton = upgradePopup.addButton(tr("Create New Kits"), QMessageBox::NoRole);
|
||||
upgradePopup.setWindowTitle(tr("Qt for MCUs"));
|
||||
upgradePopup.setText(tr("New version of Qt for MCUs detected. Upgrade existing kits?"));
|
||||
|
||||
@@ -859,15 +874,16 @@ void McuSupportOptions::createAutomaticKits()
|
||||
if (!qtForMCUsPackage->validStatus()) {
|
||||
switch (qtForMCUsPackage->status()) {
|
||||
case McuPackage::ValidPathInvalidPackage: {
|
||||
const QString displayPath = FilePath::fromString(qtForMCUsPackage->detectionPath())
|
||||
.toUserOutput();
|
||||
const QString displayPath
|
||||
= FilePath::fromString(qtForMCUsPackage->detectionPath()).toUserOutput();
|
||||
printMessage(tr("Path %1 exists, but does not contain %2.")
|
||||
.arg(qtForMCUsPackage->path().toUserOutput(), displayPath),
|
||||
true);
|
||||
break;
|
||||
}
|
||||
case McuPackage::InvalidPath: {
|
||||
printMessage(tr("Path %1 does not exist. Add the path in Tools > Options > Devices > MCU.")
|
||||
printMessage(tr("Path %1 does not exist. Add the path in Tools > Options > "
|
||||
"Devices > MCU.")
|
||||
.arg(qtForMCUsPackage->path().toUserOutput()),
|
||||
true);
|
||||
break;
|
||||
@@ -878,13 +894,15 @@ void McuSupportOptions::createAutomaticKits()
|
||||
true);
|
||||
return;
|
||||
}
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (CMakeProjectManager::CMakeToolManager::cmakeTools().isEmpty()) {
|
||||
printMessage(tr("No CMake tool was detected. Add a CMake tool in Tools > Options > Kits > CMake."),
|
||||
printMessage(tr("No CMake tool was detected. Add a CMake tool in Tools > Options > "
|
||||
"Kits > CMake."),
|
||||
true);
|
||||
return;
|
||||
}
|
||||
@@ -894,7 +912,7 @@ void McuSupportOptions::createAutomaticKits()
|
||||
Sdk::targetsAndPackages(dir, &repo);
|
||||
|
||||
bool needsUpgrade = false;
|
||||
for (const auto &target: qAsConst(repo.mcuTargets)) {
|
||||
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
||||
// if kit already exists, skip
|
||||
if (!matchingKits(target, qtForMCUsPackage).empty())
|
||||
continue;
|
||||
@@ -926,8 +944,8 @@ void McuSupportOptions::checkUpgradeableKits()
|
||||
return;
|
||||
|
||||
if (Utils::anyOf(sdkRepository.mcuTargets, [this](const McuTarget *target) {
|
||||
return !upgradeableKits(target, this->qtForMCUsSdkPackage).empty() &&
|
||||
matchingKits(target, this->qtForMCUsSdkPackage).empty();
|
||||
return !upgradeableKits(target, this->qtForMCUsSdkPackage).empty()
|
||||
&& matchingKits(target, this->qtForMCUsSdkPackage).empty();
|
||||
}))
|
||||
upgradeKits(askForKitUpgrades());
|
||||
}
|
||||
@@ -943,7 +961,7 @@ void McuSupportOptions::upgradeKits(UpgradeOption upgradeOption)
|
||||
McuSdkRepository repo;
|
||||
Sdk::targetsAndPackages(dir, &repo);
|
||||
|
||||
for (const auto &target: qAsConst(repo.mcuTargets)) {
|
||||
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
||||
if (!matchingKits(target, qtForMCUsPackage).empty())
|
||||
// already up-to-date
|
||||
continue;
|
||||
@@ -964,7 +982,9 @@ void McuSupportOptions::upgradeKits(UpgradeOption upgradeOption)
|
||||
delete qtForMCUsPackage;
|
||||
}
|
||||
|
||||
void McuSupportOptions::upgradeKitInPlace(ProjectExplorer::Kit *kit, const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdk)
|
||||
void McuSupportOptions::upgradeKitInPlace(ProjectExplorer::Kit *kit,
|
||||
const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdk)
|
||||
{
|
||||
setKitProperties(kitName(mcuTarget), kit, mcuTarget, qtForMCUsSdk->path());
|
||||
setKitEnvironment(kit, mcuTarget, qtForMCUsSdk);
|
||||
@@ -978,7 +998,7 @@ void McuSupportOptions::fixKitsDependencies()
|
||||
FilePath dir = qtForMCUsPackage->path();
|
||||
McuSdkRepository repo;
|
||||
Sdk::targetsAndPackages(dir, &repo);
|
||||
for (const auto &target: qAsConst(repo.mcuTargets)) {
|
||||
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
||||
if (target->isValid()) {
|
||||
for (auto kit : kitsWithMismatchedDependencies(target)) {
|
||||
updateKitEnvironment(kit, target);
|
||||
@@ -996,7 +1016,7 @@ void McuSupportOptions::fixKitsDependencies()
|
||||
void McuSupportOptions::fixExistingKits()
|
||||
{
|
||||
for (Kit *kit : KitManager::kits()) {
|
||||
if (!kit->hasValue(Constants::KIT_MCUTARGET_KITVERSION_KEY) )
|
||||
if (!kit->hasValue(Constants::KIT_MCUTARGET_KITVERSION_KEY))
|
||||
continue;
|
||||
|
||||
if (kit->isAutoDetected()) {
|
||||
@@ -1052,8 +1072,8 @@ void McuSupportOptions::fixExistingKits()
|
||||
FilePath dir = qtForMCUsPackage->path();
|
||||
McuSdkRepository repo;
|
||||
Sdk::targetsAndPackages(dir, &repo);
|
||||
for (const auto &target: qAsConst(repo.mcuTargets))
|
||||
for (auto kit: existingKits(target)) {
|
||||
for (const auto &target : qAsConst(repo.mcuTargets))
|
||||
for (auto kit : existingKits(target)) {
|
||||
if (McuDependenciesKitAspect::dependencies(kit).isEmpty()) {
|
||||
setKitDependencies(kit, target, qtForMCUsPackage);
|
||||
}
|
||||
@@ -1064,5 +1084,5 @@ void McuSupportOptions::fixExistingKits()
|
||||
delete qtForMCUsPackage;
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // McuSupport
|
||||
} // namespace Internal
|
||||
} // namespace McuSupport
|
||||
|
@@ -38,12 +38,12 @@ namespace Utils {
|
||||
class FilePath;
|
||||
class PathChooser;
|
||||
class InfoLabel;
|
||||
}
|
||||
} // namespace Utils
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Kit;
|
||||
class ToolChain;
|
||||
}
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
namespace McuSupport {
|
||||
namespace Internal {
|
||||
@@ -58,13 +58,10 @@ class McuTarget : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class OS {
|
||||
Desktop,
|
||||
BareMetal,
|
||||
FreeRTOS
|
||||
};
|
||||
enum class OS { Desktop, BareMetal, FreeRTOS };
|
||||
|
||||
struct Platform {
|
||||
struct Platform
|
||||
{
|
||||
QString name;
|
||||
QString displayName;
|
||||
QString vendor;
|
||||
@@ -92,7 +89,7 @@ private:
|
||||
const QVersionNumber m_qulVersion;
|
||||
const Platform m_platform;
|
||||
const OS m_os;
|
||||
const QVector<McuPackage*> m_packages;
|
||||
const QVector<McuPackage *> m_packages;
|
||||
const McuToolChainPackage *m_toolChainPackage;
|
||||
const int m_colorDepth;
|
||||
};
|
||||
@@ -100,8 +97,8 @@ private:
|
||||
class McuSdkRepository
|
||||
{
|
||||
public:
|
||||
QVector<McuPackage*> packages;
|
||||
QVector<McuTarget*> mcuTargets;
|
||||
QVector<McuPackage *> packages;
|
||||
QVector<McuTarget *> mcuTargets;
|
||||
|
||||
void deletePackagesAndTargets();
|
||||
};
|
||||
@@ -111,11 +108,7 @@ class McuSupportOptions : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum UpgradeOption {
|
||||
Ignore,
|
||||
Keep,
|
||||
Replace
|
||||
};
|
||||
enum UpgradeOption { Ignore, Keep, Replace };
|
||||
|
||||
McuSupportOptions(QObject *parent = nullptr);
|
||||
~McuSupportOptions() override;
|
||||
@@ -126,11 +119,13 @@ public:
|
||||
void setQulDir(const Utils::FilePath &dir);
|
||||
static Utils::FilePath qulDirFromSettings();
|
||||
|
||||
static QString kitName(const McuTarget* mcuTarget);
|
||||
static QString kitName(const McuTarget *mcuTarget);
|
||||
|
||||
static QList<ProjectExplorer::Kit *> existingKits(const McuTarget *mcuTarget);
|
||||
static QList<ProjectExplorer::Kit *> matchingKits(const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdkPackage);
|
||||
static QList<ProjectExplorer::Kit *> upgradeableKits(const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdkPackage);
|
||||
static QList<ProjectExplorer::Kit *> matchingKits(const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdkPackage);
|
||||
static QList<ProjectExplorer::Kit *> upgradeableKits(const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdkPackage);
|
||||
static QList<ProjectExplorer::Kit *> kitsWithMismatchedDependencies(const McuTarget *mcuTarget);
|
||||
static QList<ProjectExplorer::Kit *> outdatedKits();
|
||||
static void removeOutdatedKits();
|
||||
@@ -138,7 +133,9 @@ public:
|
||||
static void createAutomaticKits();
|
||||
static UpgradeOption askForKitUpgrades();
|
||||
static void upgradeKits(UpgradeOption upgradeOption);
|
||||
static void upgradeKitInPlace(ProjectExplorer::Kit *kit, const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdk);
|
||||
static void upgradeKitInPlace(ProjectExplorer::Kit *kit,
|
||||
const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdk);
|
||||
static void fixKitsDependencies();
|
||||
void checkUpgradeableKits();
|
||||
static void fixExistingKits();
|
||||
@@ -149,7 +146,10 @@ public:
|
||||
static const QVersionNumber &minimalQulVersion();
|
||||
|
||||
static QVersionNumber kitQulVersion(const ProjectExplorer::Kit *kit);
|
||||
static bool kitUpToDate(const ProjectExplorer::Kit *kit, const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdkPackage);
|
||||
static bool kitUpToDate(const ProjectExplorer::Kit *kit,
|
||||
const McuTarget *mcuTarget,
|
||||
const McuPackage *qtForMCUsSdkPackage);
|
||||
|
||||
private:
|
||||
void deletePackagesAndTargets();
|
||||
|
||||
|
@@ -23,9 +23,9 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mcusupportoptionspage.h"
|
||||
#include "mcupackage.h"
|
||||
#include "mcusupportconstants.h"
|
||||
#include "mcusupportoptionspage.h"
|
||||
#include "mcusupportoptions.h"
|
||||
#include "mcusupportsdk.h"
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDir>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
@@ -71,8 +71,8 @@ private:
|
||||
|
||||
QString m_armGccPath;
|
||||
McuSupportOptions m_options;
|
||||
QMap <McuPackage*, QWidget*> m_packageWidgets;
|
||||
QMap <McuTarget*, QWidget*> m_mcuTargetPacketWidgets;
|
||||
QMap<McuPackage *, QWidget *> m_packageWidgets;
|
||||
QMap<McuTarget *, QWidget *> m_mcuTargetPacketWidgets;
|
||||
QFormLayout *m_packagesLayout = nullptr;
|
||||
QGroupBox *m_qtForMCUsSdkGroupBox = nullptr;
|
||||
QGroupBox *m_packagesGroupBox = nullptr;
|
||||
@@ -110,17 +110,21 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
|
||||
}
|
||||
|
||||
{
|
||||
m_mcuTargetsGroupBox = new QGroupBox(tr("Targets supported by the %1")
|
||||
.arg(m_qtForMCUsSdkGroupBox->title()));
|
||||
m_mcuTargetsGroupBox = new QGroupBox(
|
||||
tr("Targets supported by the %1").arg(m_qtForMCUsSdkGroupBox->title()));
|
||||
m_mcuTargetsGroupBox->setFlat(true);
|
||||
mainLayout->addWidget(m_mcuTargetsGroupBox);
|
||||
m_mcuTargetsComboBox = new QComboBox;
|
||||
auto layout = new QVBoxLayout(m_mcuTargetsGroupBox);
|
||||
layout->addWidget(m_mcuTargetsComboBox);
|
||||
connect(m_mcuTargetsComboBox, &QComboBox::currentTextChanged,
|
||||
this, &McuSupportOptionsWidget::showMcuTargetPackages);
|
||||
connect(m_options.qtForMCUsSdkPackage, &McuPackage::changed,
|
||||
this, &McuSupportOptionsWidget::populateMcuTargetsComboBox);
|
||||
connect(m_mcuTargetsComboBox,
|
||||
&QComboBox::currentTextChanged,
|
||||
this,
|
||||
&McuSupportOptionsWidget::showMcuTargetPackages);
|
||||
connect(m_options.qtForMCUsSdkPackage,
|
||||
&McuPackage::changed,
|
||||
this,
|
||||
&McuSupportOptionsWidget::populateMcuTargetsComboBox);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -137,9 +141,11 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
|
||||
}
|
||||
|
||||
{
|
||||
m_kitAutomaticCreationCheckBox = new QCheckBox(tr("Automatically create kits for all available targets on start"));
|
||||
connect(m_kitAutomaticCreationCheckBox, &QCheckBox::stateChanged, this, [this] (int state) {
|
||||
m_options.qtForMCUsSdkPackage->setAutomaticKitCreationEnabled(state == Qt::CheckState::Checked);
|
||||
m_kitAutomaticCreationCheckBox = new QCheckBox(
|
||||
tr("Automatically create kits for all available targets on start"));
|
||||
connect(m_kitAutomaticCreationCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
|
||||
m_options.qtForMCUsSdkPackage->setAutomaticKitCreationEnabled(
|
||||
state == Qt::CheckState::Checked);
|
||||
});
|
||||
mainLayout->addWidget(m_kitAutomaticCreationCheckBox);
|
||||
}
|
||||
@@ -161,7 +167,8 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
|
||||
m_kitUpdatePushButton = new QPushButton(tr("Update Kit"));
|
||||
m_kitUpdatePushButton->setSizePolicy(m_kitCreationPushButton->sizePolicy());
|
||||
connect(m_kitUpdatePushButton, &QPushButton::clicked, this, [this] {
|
||||
for (auto kit: McuSupportOptions::upgradeableKits(currentMcuTarget(), m_options.qtForMCUsSdkPackage))
|
||||
for (auto kit : McuSupportOptions::upgradeableKits(currentMcuTarget(),
|
||||
m_options.qtForMCUsSdkPackage))
|
||||
m_options.upgradeKitInPlace(kit, currentMcuTarget(), m_options.qtForMCUsSdkPackage);
|
||||
updateStatus();
|
||||
});
|
||||
@@ -185,8 +192,7 @@ void McuSupportOptionsWidget::updateStatus()
|
||||
// Page elements
|
||||
{
|
||||
m_qtForMCUsSdkGroupBox->setVisible(cMakeAvailable);
|
||||
const bool valid = cMakeAvailable &&
|
||||
m_options.qtForMCUsSdkPackage->validStatus();
|
||||
const bool valid = cMakeAvailable && m_options.qtForMCUsSdkPackage->validStatus();
|
||||
const bool ready = valid && mcuTarget;
|
||||
m_mcuTargetsGroupBox->setVisible(ready);
|
||||
m_packagesGroupBox->setVisible(ready && !mcuTarget->packages().isEmpty());
|
||||
@@ -210,24 +216,24 @@ void McuSupportOptionsWidget::updateStatus()
|
||||
m_kitCreationPushButton->setVisible(mcuTargetValid);
|
||||
m_kitUpdatePushButton->setVisible(mcuTargetValid);
|
||||
if (mcuTargetValid) {
|
||||
const bool hasMatchingKits = !McuSupportOptions::matchingKits(
|
||||
mcuTarget, m_options.qtForMCUsSdkPackage).isEmpty();
|
||||
const bool hasUpgradeableKits = !hasMatchingKits &&
|
||||
!McuSupportOptions::upgradeableKits(
|
||||
mcuTarget, m_options.qtForMCUsSdkPackage).isEmpty();
|
||||
const bool hasMatchingKits
|
||||
= !McuSupportOptions::matchingKits(mcuTarget, m_options.qtForMCUsSdkPackage)
|
||||
.isEmpty();
|
||||
const bool hasUpgradeableKits
|
||||
= !hasMatchingKits
|
||||
&& !McuSupportOptions::upgradeableKits(mcuTarget, m_options.qtForMCUsSdkPackage)
|
||||
.isEmpty();
|
||||
|
||||
m_kitCreationPushButton->setEnabled(!hasMatchingKits);
|
||||
m_kitUpdatePushButton->setEnabled(hasUpgradeableKits);
|
||||
|
||||
m_kitCreationInfoLabel->setType(!hasMatchingKits
|
||||
? Utils::InfoLabel::Information
|
||||
m_kitCreationInfoLabel->setType(!hasMatchingKits ? Utils::InfoLabel::Information
|
||||
: Utils::InfoLabel::Ok);
|
||||
|
||||
m_kitCreationInfoLabel->setText(
|
||||
hasMatchingKits ?
|
||||
tr("A kit for the selected target and SDK version already exists.")
|
||||
: hasUpgradeableKits ?
|
||||
tr("Kits for a different SDK version exist.")
|
||||
hasMatchingKits
|
||||
? tr("A kit for the selected target and SDK version already exists.")
|
||||
: hasUpgradeableKits ? tr("Kits for a different SDK version exist.")
|
||||
: tr("A kit for the selected target can be created."));
|
||||
} else {
|
||||
m_kitCreationInfoLabel->setType(Utils::InfoLabel::NotOk);
|
||||
@@ -237,7 +243,8 @@ void McuSupportOptionsWidget::updateStatus()
|
||||
}
|
||||
|
||||
// Automatic Kit creation
|
||||
m_kitAutomaticCreationCheckBox->setChecked(m_options.qtForMCUsSdkPackage->automaticKitCreationEnabled());
|
||||
m_kitAutomaticCreationCheckBox->setChecked(
|
||||
m_options.qtForMCUsSdkPackage->automaticKitCreationEnabled());
|
||||
|
||||
// Status label in the bottom
|
||||
{
|
||||
@@ -307,9 +314,8 @@ void McuSupportOptionsWidget::populateMcuTargetsComboBox()
|
||||
m_options.populatePackagesAndTargets();
|
||||
m_mcuTargetsComboBox->clear();
|
||||
m_mcuTargetsComboBox->addItems(
|
||||
Utils::transform<QStringList>(m_options.sdkRepository.mcuTargets, [](McuTarget *t) {
|
||||
return McuSupportOptions::kitName(t);
|
||||
}));
|
||||
Utils::transform<QStringList>(m_options.sdkRepository.mcuTargets,
|
||||
[](McuTarget *t) { return McuSupportOptions::kitName(t); }));
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
@@ -321,5 +327,5 @@ McuSupportOptionsPage::McuSupportOptionsPage()
|
||||
setWidgetCreator([] { return new McuSupportOptionsWidget; });
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // McuSupport
|
||||
} // namespace Internal
|
||||
} // namespace McuSupport
|
||||
|
@@ -23,8 +23,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mcukitinformation.h"
|
||||
#include "mcusupportplugin.h"
|
||||
#include "mcukitinformation.h"
|
||||
#include "mcusupportconstants.h"
|
||||
#include "mcusupportdevice.h"
|
||||
#include "mcusupportoptions.h"
|
||||
@@ -54,11 +54,9 @@ class McuSupportPluginPrivate
|
||||
public:
|
||||
McuSupportDeviceFactory deviceFactory;
|
||||
McuSupportRunConfigurationFactory runConfigurationFactory;
|
||||
RunWorkerFactory runWorkerFactory{
|
||||
makeFlashAndRunWorker(),
|
||||
RunWorkerFactory runWorkerFactory{makeFlashAndRunWorker(),
|
||||
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
|
||||
{Constants::RUNCONFIGURATION}
|
||||
};
|
||||
{Constants::RUNCONFIGURATION}};
|
||||
McuSupportOptionsPage optionsPage;
|
||||
McuDependenciesKitAspect environmentPathsKitAspect;
|
||||
};
|
||||
@@ -76,7 +74,7 @@ McuSupportPlugin::~McuSupportPlugin()
|
||||
dd = nullptr;
|
||||
}
|
||||
|
||||
bool McuSupportPlugin::initialize(const QStringList& arguments, QString* errorString)
|
||||
bool McuSupportPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
@@ -94,7 +92,7 @@ void McuSupportPlugin::extensionsInitialized()
|
||||
{
|
||||
ProjectExplorer::DeviceManager::instance()->addDevice(McuSupportDevice::create());
|
||||
|
||||
connect(KitManager::instance(), &KitManager::kitsLoaded, [](){
|
||||
connect(KitManager::instance(), &KitManager::kitsLoaded, []() {
|
||||
McuSupportOptions::removeOutdatedKits();
|
||||
McuSupportOptions::createAutomaticKits();
|
||||
McuSupportOptions::fixExistingKits();
|
||||
@@ -134,12 +132,11 @@ void McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade()
|
||||
Utils::InfoBarEntry::GlobalSuppression::Enabled);
|
||||
|
||||
static McuSupportOptions::UpgradeOption selectedOption;
|
||||
const QStringList options = { tr("Create new kits"), tr("Replace existing kits") };
|
||||
const QStringList options = {tr("Create new kits"), tr("Replace existing kits")};
|
||||
selectedOption = McuSupportOptions::UpgradeOption::Keep;
|
||||
info.setComboInfo(options, [options](const QString &selected) {
|
||||
selectedOption = options.indexOf(selected) == 0 ?
|
||||
McuSupportOptions::UpgradeOption::Keep :
|
||||
McuSupportOptions::UpgradeOption::Replace;
|
||||
selectedOption = options.indexOf(selected) == 0 ? McuSupportOptions::UpgradeOption::Keep
|
||||
: McuSupportOptions::UpgradeOption::Replace;
|
||||
});
|
||||
|
||||
info.addCustomButton(tr("Proceed"), [upgradeMcuSupportKits] {
|
||||
|
@@ -46,16 +46,18 @@ namespace Internal {
|
||||
|
||||
static FilePath cmakeFilePath(const Target *target)
|
||||
{
|
||||
const CMakeProjectManager::CMakeTool *tool =
|
||||
CMakeProjectManager::CMakeKitAspect::cmakeTool(target->kit());
|
||||
const CMakeProjectManager::CMakeTool *tool = CMakeProjectManager::CMakeKitAspect::cmakeTool(
|
||||
target->kit());
|
||||
return tool->filePath();
|
||||
}
|
||||
|
||||
static QStringList flashAndRunArgs(const RunConfiguration *rc, const Target *target)
|
||||
{
|
||||
// Use buildKey if provided, fallback to projectName
|
||||
const QString targetName = QLatin1String("flash_%1").arg(
|
||||
!rc->buildKey().isEmpty() ? rc->buildKey() : target->project()->displayName());
|
||||
const QString targetName = QLatin1String("flash_%1")
|
||||
.arg(!rc->buildKey().isEmpty()
|
||||
? rc->buildKey()
|
||||
: target->project()->displayName());
|
||||
|
||||
return {"--build", ".", "--target", targetName};
|
||||
}
|
||||
|
@@ -23,10 +23,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "mcusupportsdk.h"
|
||||
#include "mcupackage.h"
|
||||
#include "mcusupportconstants.h"
|
||||
#include "mcusupportoptions.h"
|
||||
#include "mcusupportsdk.h"
|
||||
#include "mcusupportversiondetection.h"
|
||||
|
||||
#include <baremetal/baremetalconstants.h>
|
||||
@@ -34,8 +34,8 @@
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
@@ -106,11 +106,10 @@ static McuToolChainPackage *createArmGccPackage()
|
||||
}
|
||||
|
||||
const QString detectionPath = Utils::HostOsInfo::withExecutableSuffix("bin/arm-none-eabi-g++");
|
||||
const auto versionDetector = new McuPackageExecutableVersionDetector(
|
||||
detectionPath,
|
||||
{ "--version" },
|
||||
"\\b(\\d+\\.\\d+\\.\\d+)\\b"
|
||||
);
|
||||
const auto versionDetector
|
||||
= new McuPackageExecutableVersionDetector(detectionPath,
|
||||
{"--version"},
|
||||
"\\b(\\d+\\.\\d+\\.\\d+)\\b");
|
||||
|
||||
return new McuToolChainPackage(McuPackage::tr("GNU Arm Embedded Toolchain"),
|
||||
defaultPath,
|
||||
@@ -127,11 +126,10 @@ static McuToolChainPackage *createGhsToolchainPackage()
|
||||
|
||||
const FilePath defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
|
||||
|
||||
const auto versionDetector = new McuPackageExecutableVersionDetector(
|
||||
Utils::HostOsInfo::withExecutableSuffix("as850"),
|
||||
const auto versionDetector
|
||||
= new McuPackageExecutableVersionDetector(Utils::HostOsInfo::withExecutableSuffix("as850"),
|
||||
{"-V"},
|
||||
"\\bv(\\d+\\.\\d+\\.\\d+)\\b"
|
||||
);
|
||||
"\\bv(\\d+\\.\\d+\\.\\d+)\\b");
|
||||
|
||||
return new McuToolChainPackage("Green Hills Compiler",
|
||||
defaultPath,
|
||||
@@ -149,11 +147,10 @@ static McuToolChainPackage *createGhsArmToolchainPackage()
|
||||
|
||||
const FilePath defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
|
||||
|
||||
const auto versionDetector = new McuPackageExecutableVersionDetector(
|
||||
Utils::HostOsInfo::withExecutableSuffix("asarm"),
|
||||
const auto versionDetector
|
||||
= new McuPackageExecutableVersionDetector(Utils::HostOsInfo::withExecutableSuffix("asarm"),
|
||||
{"-V"},
|
||||
"\\bv(\\d+\\.\\d+\\.\\d+)\\b"
|
||||
);
|
||||
"\\bv(\\d+\\.\\d+\\.\\d+)\\b");
|
||||
|
||||
return new McuToolChainPackage("Green Hills Compiler for ARM",
|
||||
defaultPath,
|
||||
@@ -172,8 +169,8 @@ static McuToolChainPackage *createIarToolChainPackage()
|
||||
if (qEnvironmentVariableIsSet(envVar))
|
||||
defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
|
||||
else {
|
||||
const ProjectExplorer::ToolChain *tc =
|
||||
ProjectExplorer::ToolChainManager::toolChain([](const ProjectExplorer::ToolChain *t) {
|
||||
const ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainManager::toolChain(
|
||||
[](const ProjectExplorer::ToolChain *t) {
|
||||
return t->typeId() == BareMetal::Constants::IAREW_TOOLCHAIN_TYPEID;
|
||||
});
|
||||
if (tc) {
|
||||
@@ -183,11 +180,10 @@ static McuToolChainPackage *createIarToolChainPackage()
|
||||
}
|
||||
|
||||
const QString detectionPath = Utils::HostOsInfo::withExecutableSuffix("bin/iccarm");
|
||||
const auto versionDetector = new McuPackageExecutableVersionDetector(
|
||||
detectionPath,
|
||||
const auto versionDetector
|
||||
= new McuPackageExecutableVersionDetector(detectionPath,
|
||||
{"--version"},
|
||||
"\\bV(\\d+\\.\\d+\\.\\d+)\\.\\d+\\b"
|
||||
);
|
||||
"\\bV(\\d+\\.\\d+\\.\\d+)\\.\\d+\\b");
|
||||
|
||||
return new McuToolChainPackage("IAR ARM Compiler",
|
||||
defaultPath,
|
||||
@@ -206,11 +202,12 @@ static McuPackage *createRGLPackage()
|
||||
if (qEnvironmentVariableIsSet(envVar)) {
|
||||
defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
|
||||
} else if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
const FilePath rglPath = FilePath::fromString(QDir::rootPath()) / "Renesas_Electronics/D1x_RGL";
|
||||
const FilePath rglPath = FilePath::fromString(QDir::rootPath())
|
||||
/ "Renesas_Electronics/D1x_RGL";
|
||||
if (rglPath.exists()) {
|
||||
defaultPath = rglPath;
|
||||
const FilePaths subDirs =
|
||||
defaultPath.dirEntries({{"rgl_ghs_D1Mx_*"}, QDir::Dirs | QDir::NoDotAndDotDot});
|
||||
const FilePaths subDirs = defaultPath.dirEntries(
|
||||
{{"rgl_ghs_D1Mx_*"}, QDir::Dirs | QDir::NoDotAndDotDot});
|
||||
if (subDirs.count() == 1)
|
||||
defaultPath = subDirs.first();
|
||||
}
|
||||
@@ -262,8 +259,8 @@ static McuPackage *createMcuXpressoIdePackage()
|
||||
if (programPath.exists()) {
|
||||
defaultPath = programPath;
|
||||
// If default dir has exactly one sub dir that could be the IDE path, pre-select that.
|
||||
const FilePaths subDirs =
|
||||
defaultPath.dirEntries({{"MCUXpressoIDE*"}, QDir::Dirs | QDir::NoDotAndDotDot});
|
||||
const FilePaths subDirs = defaultPath.dirEntries(
|
||||
{{"MCUXpressoIDE*"}, QDir::Dirs | QDir::NoDotAndDotDot});
|
||||
if (subDirs.count() == 1)
|
||||
defaultPath = subDirs.first();
|
||||
}
|
||||
@@ -300,8 +297,7 @@ static McuPackage *createCypressProgrammerPackage()
|
||||
}
|
||||
}
|
||||
|
||||
auto result = new McuPackage(
|
||||
"Cypress Auto Flash Utility",
|
||||
auto result = new McuPackage("Cypress Auto Flash Utility",
|
||||
defaultPath,
|
||||
Utils::HostOsInfo::withExecutableSuffix("/bin/openocd"),
|
||||
"CypressAutoFlashUtil",
|
||||
@@ -327,8 +323,7 @@ static McuPackage *createRenesasProgrammerPackage()
|
||||
}
|
||||
}
|
||||
|
||||
auto result = new McuPackage(
|
||||
"Renesas Flash Programmer",
|
||||
auto result = new McuPackage("Renesas Flash Programmer",
|
||||
defaultPath,
|
||||
Utils::HostOsInfo::withExecutableSuffix("rfp-cli"),
|
||||
"RenesasFlashProgrammer",
|
||||
@@ -338,43 +333,47 @@ static McuPackage *createRenesasProgrammerPackage()
|
||||
|
||||
struct McuTargetDescription
|
||||
{
|
||||
enum class TargetType {
|
||||
MCU,
|
||||
Desktop
|
||||
};
|
||||
enum class TargetType { MCU, Desktop };
|
||||
|
||||
QString qulVersion;
|
||||
QString compatVersion;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
QString id;
|
||||
QString name;
|
||||
QString vendor;
|
||||
QVector<int> colorDepths;
|
||||
TargetType type;
|
||||
} platform;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
QString id;
|
||||
QStringList versions;
|
||||
} toolchain;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
QString name;
|
||||
QString defaultPath;
|
||||
QString envVar;
|
||||
QStringList versions;
|
||||
} boardSdk;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
QString envVar;
|
||||
QString boardSdkSubDir;
|
||||
} freeRTOS;
|
||||
};
|
||||
|
||||
static McuPackageVersionDetector* generatePackageVersionDetector(QString envVar)
|
||||
static McuPackageVersionDetector *generatePackageVersionDetector(QString envVar)
|
||||
{
|
||||
if (envVar.startsWith("EVK"))
|
||||
return new McuPackageXmlVersionDetector("*_manifest_*.xml", "ksdk", "version", ".*");
|
||||
|
||||
if (envVar.startsWith("STM32"))
|
||||
return new McuPackageXmlVersionDetector("package.xml", "PackDescription", "Release", "\\b(\\d+\\.\\d+\\.\\d+)\\b");
|
||||
return new McuPackageXmlVersionDetector("package.xml",
|
||||
"PackDescription",
|
||||
"Release",
|
||||
"\\b(\\d+\\.\\d+\\.\\d+)\\b");
|
||||
|
||||
if (envVar.startsWith("RGL"))
|
||||
return new McuPackageDirectoryVersionDetector("rgl_*_obj_*", "\\d+\\.\\d+\\.\\w+", false);
|
||||
@@ -385,9 +384,9 @@ static McuPackageVersionDetector* generatePackageVersionDetector(QString envVar)
|
||||
/// Create the McuPackage by checking the "boardSdk" property in the JSON file for the board.
|
||||
/// The name of the environment variable pointing to the the SDK for the board will be defined in the "envVar" property
|
||||
/// inside the "boardSdk".
|
||||
static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
|
||||
static McuPackage *createBoardSdkPackage(const McuTargetDescription &desc)
|
||||
{
|
||||
const auto generateSdkName = [](const QString& envVar) {
|
||||
const auto generateSdkName = [](const QString &envVar) {
|
||||
auto postfixPos = envVar.indexOf("_SDK_PATH");
|
||||
if (postfixPos < 0) {
|
||||
postfixPos = envVar.indexOf("_DIR");
|
||||
@@ -395,14 +394,16 @@ static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
|
||||
auto sdkName = postfixPos > 0 ? envVar.left(postfixPos) : envVar;
|
||||
return QString::fromLatin1("MCU SDK (%1)").arg(sdkName);
|
||||
};
|
||||
const QString sdkName = desc.boardSdk.name.isEmpty() ? generateSdkName(desc.boardSdk.envVar) : desc.boardSdk.name;
|
||||
const QString sdkName = desc.boardSdk.name.isEmpty() ? generateSdkName(desc.boardSdk.envVar)
|
||||
: desc.boardSdk.name;
|
||||
|
||||
const FilePath defaultPath = [&] {
|
||||
const auto envVar = desc.boardSdk.envVar.toLatin1();
|
||||
if (qEnvironmentVariableIsSet(envVar))
|
||||
return FilePath::fromUserInput(qEnvironmentVariable(envVar));
|
||||
if (!desc.boardSdk.defaultPath.isEmpty()) {
|
||||
FilePath defaultPath = FilePath::fromUserInput(QDir::rootPath() + desc.boardSdk.defaultPath);
|
||||
FilePath defaultPath = FilePath::fromUserInput(QDir::rootPath()
|
||||
+ desc.boardSdk.defaultPath);
|
||||
if (defaultPath.exists())
|
||||
return defaultPath;
|
||||
}
|
||||
@@ -420,7 +421,8 @@ static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
|
||||
versionDetector);
|
||||
}
|
||||
|
||||
static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar, const FilePath &boardSdkDir,
|
||||
static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar,
|
||||
const FilePath &boardSdkDir,
|
||||
const QString &freeRTOSBoardSdkSubDir)
|
||||
{
|
||||
const QString envVarPrefix = envVar.chopped(int(strlen("_FREERTOS_DIR")));
|
||||
@@ -447,10 +449,10 @@ struct McuTargetFactory
|
||||
, vendorPkgs(vendorPkgs)
|
||||
{}
|
||||
|
||||
QVector<McuTarget *> createTargets(const McuTargetDescription& description)
|
||||
QVector<McuTarget *> createTargets(const McuTargetDescription &description)
|
||||
{
|
||||
auto qulVersion = QVersionNumber::fromString(description.qulVersion);
|
||||
if (qulVersion <= QVersionNumber({1,3})) {
|
||||
if (qulVersion <= QVersionNumber({1, 3})) {
|
||||
if (description.platform.type == McuTargetDescription::TargetType::Desktop)
|
||||
return createDesktopTargetsLegacy(description);
|
||||
|
||||
@@ -481,7 +483,7 @@ protected:
|
||||
tcPkg = createUnsupportedToolChainPackage();
|
||||
for (auto os : {McuTarget::OS::BareMetal, McuTarget::OS::FreeRTOS}) {
|
||||
for (int colorDepth : desc.platform.colorDepths) {
|
||||
QVector<McuPackage*> required3rdPartyPkgs = { tcPkg };
|
||||
QVector<McuPackage *> required3rdPartyPkgs = {tcPkg};
|
||||
if (vendorPkgs.contains(desc.platform.vendor))
|
||||
required3rdPartyPkgs.push_back(vendorPkgs.value(desc.platform.vendor));
|
||||
|
||||
@@ -502,15 +504,19 @@ protected:
|
||||
continue;
|
||||
} else {
|
||||
if (!freeRTOSPkgs.contains(desc.freeRTOS.envVar)) {
|
||||
freeRTOSPkgs.insert(desc.freeRTOS.envVar, createFreeRTOSSourcesPackage(
|
||||
desc.freeRTOS.envVar, boardSdkDefaultPath,
|
||||
freeRTOSPkgs
|
||||
.insert(desc.freeRTOS.envVar,
|
||||
createFreeRTOSSourcesPackage(desc.freeRTOS.envVar,
|
||||
boardSdkDefaultPath,
|
||||
desc.freeRTOS.boardSdkSubDir));
|
||||
}
|
||||
required3rdPartyPkgs.append(freeRTOSPkgs.value(desc.freeRTOS.envVar));
|
||||
}
|
||||
}
|
||||
|
||||
const auto platform = McuTarget::Platform{ desc.platform.id, desc.platform.name, desc.platform.vendor };
|
||||
const auto platform = McuTarget::Platform{desc.platform.id,
|
||||
desc.platform.name,
|
||||
desc.platform.vendor};
|
||||
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
||||
platform,
|
||||
os,
|
||||
@@ -525,18 +531,23 @@ protected:
|
||||
return mcuTargets;
|
||||
}
|
||||
|
||||
QVector<McuTarget *> createDesktopTargetsLegacy(const McuTargetDescription& desc)
|
||||
QVector<McuTarget *> createDesktopTargetsLegacy(const McuTargetDescription &desc)
|
||||
{
|
||||
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchain.id);
|
||||
if (!tcPkg)
|
||||
tcPkg = createUnsupportedToolChainPackage();
|
||||
const auto platform = McuTarget::Platform{ desc.platform.id, desc.platform.name, desc.platform.vendor };
|
||||
const auto platform = McuTarget::Platform{desc.platform.id,
|
||||
desc.platform.name,
|
||||
desc.platform.vendor};
|
||||
auto desktopTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
||||
platform, McuTarget::OS::Desktop, {}, tcPkg);
|
||||
return { desktopTarget };
|
||||
platform,
|
||||
McuTarget::OS::Desktop,
|
||||
{},
|
||||
tcPkg);
|
||||
return {desktopTarget};
|
||||
}
|
||||
|
||||
QVector<McuTarget *> createTargetsImpl(const McuTargetDescription& desc)
|
||||
QVector<McuTarget *> createTargetsImpl(const McuTargetDescription &desc)
|
||||
{
|
||||
// OS deduction
|
||||
const auto os = [&] {
|
||||
@@ -550,15 +561,14 @@ protected:
|
||||
QVector<McuTarget *> mcuTargets;
|
||||
McuToolChainPackage *tcPkg = tcPkgs.value(desc.toolchain.id);
|
||||
if (tcPkg) {
|
||||
if (QVersionNumber::fromString(desc.qulVersion) >= QVersionNumber({1,8}))
|
||||
if (QVersionNumber::fromString(desc.qulVersion) >= QVersionNumber({1, 8}))
|
||||
tcPkg->setVersions(desc.toolchain.versions);
|
||||
} else
|
||||
tcPkg = createUnsupportedToolChainPackage();
|
||||
for (int colorDepth : desc.platform.colorDepths) {
|
||||
QVector<McuPackage*> required3rdPartyPkgs;
|
||||
QVector<McuPackage *> required3rdPartyPkgs;
|
||||
// Desktop toolchains don't need any additional settings
|
||||
if (tcPkg
|
||||
&& !tcPkg->isDesktopToolchain()
|
||||
if (tcPkg && !tcPkg->isDesktopToolchain()
|
||||
&& tcPkg->type() != McuToolChainPackage::Type::Unsupported)
|
||||
required3rdPartyPkgs.append(tcPkg);
|
||||
|
||||
@@ -574,7 +584,7 @@ protected:
|
||||
boardSdkPkgs.insert(desc.boardSdk.envVar, boardSdkPkg);
|
||||
}
|
||||
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.boardSdk.versions);
|
||||
boardSdkDefaultPath = boardSdkPkg->defaultPath();
|
||||
required3rdPartyPkgs.append(boardSdkPkg);
|
||||
@@ -583,14 +593,16 @@ protected:
|
||||
// Free RTOS specific settings
|
||||
if (!desc.freeRTOS.envVar.isEmpty()) {
|
||||
if (!freeRTOSPkgs.contains(desc.freeRTOS.envVar)) {
|
||||
freeRTOSPkgs.insert(desc.freeRTOS.envVar, createFreeRTOSSourcesPackage(
|
||||
desc.freeRTOS.envVar, boardSdkDefaultPath,
|
||||
freeRTOSPkgs.insert(desc.freeRTOS.envVar,
|
||||
createFreeRTOSSourcesPackage(desc.freeRTOS.envVar,
|
||||
boardSdkDefaultPath,
|
||||
desc.freeRTOS.boardSdkSubDir));
|
||||
}
|
||||
required3rdPartyPkgs.append(freeRTOSPkgs.value(desc.freeRTOS.envVar));
|
||||
}
|
||||
|
||||
const McuTarget::Platform platform({ desc.platform.id, desc.platform.name, desc.platform.vendor });
|
||||
const McuTarget::Platform platform(
|
||||
{desc.platform.id, desc.platform.name, desc.platform.vendor});
|
||||
auto mcuTarget = new McuTarget(QVersionNumber::fromString(desc.qulVersion),
|
||||
platform,
|
||||
os,
|
||||
@@ -639,8 +651,9 @@ static QVector<McuTarget *> targetsFromDescriptions(const QList<McuTargetDescrip
|
||||
mcuTargets.append(newTargets);
|
||||
}
|
||||
|
||||
packages->append(Utils::transform<QVector<McuPackage *> >(
|
||||
tcPkgs.values(), [&](McuToolChainPackage *tcPkg) { return tcPkg; }));
|
||||
packages->append(
|
||||
Utils::transform<QVector<McuPackage *>>(tcPkgs.values(),
|
||||
[&](McuToolChainPackage *tcPkg) { return tcPkg; }));
|
||||
for (auto *package : vendorPkgs)
|
||||
packages->append(package);
|
||||
packages->append(targetFactory.getMcuPackages());
|
||||
@@ -659,7 +672,8 @@ static QFileInfoList targetDescriptionFiles(const Utils::FilePath &dir)
|
||||
return kitsDir.entryInfoList();
|
||||
}
|
||||
|
||||
static McuTargetDescription parseDescriptionJsonCommon(const QString &qulVersion, const QJsonObject &target)
|
||||
static McuTargetDescription parseDescriptionJsonCommon(const QString &qulVersion,
|
||||
const QJsonObject &target)
|
||||
{
|
||||
const QString compatVersion = target.value("compatVersion").toString();
|
||||
const QJsonObject toolchain = target.value("toolchain").toObject();
|
||||
@@ -667,14 +681,17 @@ static McuTargetDescription parseDescriptionJsonCommon(const QString &qulVersion
|
||||
const QJsonObject freeRTOS = target.value("freeRTOS").toObject();
|
||||
|
||||
const QVariantList toolchainVersions = toolchain.value("versions").toArray().toVariantList();
|
||||
const auto toolchainVersionsList = Utils::transform<QStringList>(
|
||||
toolchainVersions, [&](const QVariant &version) { return version.toString(); });
|
||||
const auto toolchainVersionsList = Utils::transform<QStringList>(toolchainVersions,
|
||||
[&](const QVariant &version) {
|
||||
return version.toString();
|
||||
});
|
||||
const QVariantList boardSdkVersions = boardSdk.value("versions").toArray().toVariantList();
|
||||
const auto boardSdkVersionsList = Utils::transform<QStringList>(
|
||||
boardSdkVersions, [&](const QVariant &version) { return version.toString(); });
|
||||
const auto boardSdkVersionsList = Utils::transform<QStringList>(boardSdkVersions,
|
||||
[&](const QVariant &version) {
|
||||
return version.toString();
|
||||
});
|
||||
|
||||
return {
|
||||
qulVersion,
|
||||
return {qulVersion,
|
||||
compatVersion,
|
||||
{},
|
||||
{
|
||||
@@ -690,35 +707,40 @@ static McuTargetDescription parseDescriptionJsonCommon(const QString &qulVersion
|
||||
{
|
||||
freeRTOS.value("envVar").toString(),
|
||||
freeRTOS.value("boardSdkSubDir").toString(),
|
||||
}
|
||||
};
|
||||
}};
|
||||
}
|
||||
|
||||
static McuTargetDescription parseDescriptionJsonV1x(const QString &qulVersion, const QJsonObject &target)
|
||||
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(); });
|
||||
const auto colorDepthsVector = Utils::transform<QVector<int>>(colorDepths,
|
||||
[&](const QVariant &colorDepth) {
|
||||
return colorDepth.toInt();
|
||||
});
|
||||
|
||||
description.platform = {
|
||||
target.value("platform").toString(),
|
||||
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
|
||||
};
|
||||
description.boardSdk.envVar.isEmpty()
|
||||
? McuTargetDescription::TargetType::Desktop
|
||||
: McuTargetDescription::TargetType::MCU};
|
||||
return description;
|
||||
}
|
||||
|
||||
static McuTargetDescription parseDescriptionJsonV2x(const QString &qulVersion, const QJsonObject &target)
|
||||
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 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 = {
|
||||
@@ -726,7 +748,8 @@ static McuTargetDescription parseDescriptionJsonV2x(const QString &qulVersion, c
|
||||
platformName,
|
||||
platform.value("vendor").toString(),
|
||||
colorDepthsVector,
|
||||
platformName == "Desktop" ? McuTargetDescription::TargetType::Desktop : McuTargetDescription::TargetType::MCU,
|
||||
platformName == "Desktop" ? McuTargetDescription::TargetType::Desktop
|
||||
: McuTargetDescription::TargetType::MCU,
|
||||
};
|
||||
|
||||
return description;
|
||||
@@ -740,9 +763,12 @@ static McuTargetDescription parseDescriptionJson(const QByteArray &data)
|
||||
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 };
|
||||
case 1:
|
||||
return parseDescriptionJsonV1x(qulVersion, target);
|
||||
case 2:
|
||||
return parseDescriptionJsonV2x(qulVersion, target);
|
||||
default:
|
||||
return {qulVersion};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,8 +787,8 @@ bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message)
|
||||
if (oldSdkQtcRequiredVersion.contains(sdkDetectedVersion)) {
|
||||
message = McuTarget::tr("Qt for MCUs SDK version %1 detected, "
|
||||
"only supported by Qt Creator version %2. "
|
||||
"This version of Qt Creator requires Qt for MCUs %3 or greater."
|
||||
).arg(sdkDetectedVersion,
|
||||
"This version of Qt Creator requires Qt for MCUs %3 or greater.")
|
||||
.arg(sdkDetectedVersion,
|
||||
oldSdkQtcRequiredVersion.value(sdkDetectedVersion),
|
||||
McuSupportOptions::minimalQulVersion().toString());
|
||||
return true;
|
||||
@@ -785,21 +811,20 @@ void targetsAndPackages(const Utils::FilePath &dir, McuSdkRepository *repo)
|
||||
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)),
|
||||
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()) {
|
||||
const QString qtcSupportText = oldSdkQtcRequiredVersion.contains(desc.qulVersion) ?
|
||||
McuTarget::tr("Detected version \"%1\", only supported by Qt Creator %2.")
|
||||
const QString qtcSupportText
|
||||
= oldSdkQtcRequiredVersion.contains(desc.qulVersion)
|
||||
? McuTarget::tr("Detected version \"%1\", only supported by Qt Creator %2.")
|
||||
.arg(desc.qulVersion, oldSdkQtcRequiredVersion.value(desc.qulVersion))
|
||||
: McuTarget::tr("Unsupported version \"%1\".")
|
||||
.arg(desc.qulVersion);
|
||||
: McuTarget::tr("Unsupported version \"%1\".").arg(desc.qulVersion);
|
||||
printMessage(McuTarget::tr("Skipped %1. %2 Qt for MCUs version >= %3 required.")
|
||||
.arg(
|
||||
QDir::toNativeSeparators(pth.fileNameWithPathComponents(1)),
|
||||
.arg(QDir::toNativeSeparators(pth.fileNameWithPathComponents(1)),
|
||||
qtcSupportText,
|
||||
McuSupportOptions::minimalQulVersion().toString()),
|
||||
false);
|
||||
@@ -812,7 +837,8 @@ void targetsAndPackages(const Utils::FilePath &dir, McuSdkRepository *repo)
|
||||
if (descriptions.empty()) {
|
||||
if (kitsPath(dir).exists()) {
|
||||
printMessage(McuTarget::tr("No valid kit descriptions found at %1.")
|
||||
.arg(kitsPath(dir).toUserOutput()), true);
|
||||
.arg(kitsPath(dir).toUserOutput()),
|
||||
true);
|
||||
return;
|
||||
} else {
|
||||
QString deprecationMessage;
|
||||
@@ -827,7 +853,8 @@ void targetsAndPackages(const Utils::FilePath &dir, McuSdkRepository *repo)
|
||||
// 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 = contains(descriptions, [](const McuTargetDescription &desc) {
|
||||
const bool hasDesktopDescription
|
||||
= contains(descriptions, [](const McuTargetDescription &desc) {
|
||||
return desc.platform.type == McuTargetDescription::TargetType::Desktop;
|
||||
});
|
||||
|
||||
@@ -835,36 +862,43 @@ void targetsAndPackages(const Utils::FilePath &dir, McuSdkRepository *repo)
|
||||
QVector<FilePath> desktopLibs;
|
||||
if (HostOsInfo::isWindowsHost()) {
|
||||
desktopLibs << dir / "lib/QulQuickUltralite_QT_32bpp_Windows_Release.lib"; // older versions of QUL (<1.5?)
|
||||
desktopLibs << dir / "lib/QulQuickUltralitePlatform_QT_32bpp_Windows_msvc_Release.lib"; // newer versions of QUL
|
||||
desktopLibs
|
||||
<< dir / "lib/QulQuickUltralitePlatform_QT_32bpp_Windows_msvc_Release.lib"; // newer versions of QUL
|
||||
} else {
|
||||
desktopLibs << dir / "lib/libQulQuickUltralite_QT_32bpp_Linux_Debug.a"; // older versions of QUL (<1.5?)
|
||||
desktopLibs << dir / "lib/libQulQuickUltralitePlatform_QT_32bpp_Linux_gnu_Debug.a"; // newer versions of QUL
|
||||
}
|
||||
|
||||
if (anyOf(desktopLibs, [](const FilePath &desktopLib) {
|
||||
return desktopLib.exists(); })
|
||||
) {
|
||||
if (anyOf(desktopLibs, [](const FilePath &desktopLib) { return desktopLib.exists(); })) {
|
||||
McuTargetDescription desktopDescription;
|
||||
desktopDescription.qulVersion = descriptions.empty() ?
|
||||
McuSupportOptions::minimalQulVersion().toString()
|
||||
desktopDescription.qulVersion
|
||||
= descriptions.empty() ? McuSupportOptions::minimalQulVersion().toString()
|
||||
: descriptions.first().qulVersion;
|
||||
desktopDescription.platform.id = "Qt";
|
||||
desktopDescription.platform.name = "Desktop";
|
||||
desktopDescription.platform.vendor = "Qt";
|
||||
desktopDescription.platform.colorDepths = {32};
|
||||
desktopDescription.toolchain.id = HostOsInfo::isWindowsHost() ? QString("msvc") : QString("gcc");
|
||||
desktopDescription.toolchain.id = HostOsInfo::isWindowsHost() ? QString("msvc")
|
||||
: QString("gcc");
|
||||
desktopDescription.platform.type = McuTargetDescription::TargetType::Desktop;
|
||||
descriptions.prepend(desktopDescription);
|
||||
} else {
|
||||
// show error only on 1.x SDKs, but skip on 2.x
|
||||
const FilePath desktopLibV2 = HostOsInfo::isWindowsHost() ?
|
||||
dir / "lib/QulPlatform_qt_32bpp_Windows_msvc_Release.lib"
|
||||
const FilePath desktopLibV2
|
||||
= HostOsInfo::isWindowsHost()
|
||||
? dir / "lib/QulPlatform_qt_32bpp_Windows_msvc_Release.lib"
|
||||
: dir / "lib/libQulPlatform_qt_32bpp_Linux_gnu_Release.a";
|
||||
if (dir.exists() && !desktopLibV2.exists())
|
||||
printMessage(McuTarget::tr("Skipped creating fallback desktop kit: Could not find any of %1.")
|
||||
.arg(transform(desktopLibs, [](const auto &path) {
|
||||
return QDir::toNativeSeparators(path.fileNameWithPathComponents(1));
|
||||
}).toList().join(" or ")),
|
||||
printMessage(
|
||||
McuTarget::tr(
|
||||
"Skipped creating fallback desktop kit: Could not find any of %1.")
|
||||
.arg(transform(desktopLibs,
|
||||
[](const auto &path) {
|
||||
return QDir::toNativeSeparators(
|
||||
path.fileNameWithPathComponents(1));
|
||||
})
|
||||
.toList()
|
||||
.join(" or ")),
|
||||
false);
|
||||
}
|
||||
}
|
||||
@@ -873,16 +907,20 @@ void targetsAndPackages(const Utils::FilePath &dir, McuSdkRepository *repo)
|
||||
repo->mcuTargets.append(targetsFromDescriptions(descriptions, &(repo->packages)));
|
||||
|
||||
// Keep targets sorted lexicographically
|
||||
std::sort(repo->mcuTargets.begin(), repo->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);
|
||||
});
|
||||
}
|
||||
|
||||
FilePath packagePathFromSettings(const QString &settingsKey, QSettings::Scope scope, const FilePath &defaultPath)
|
||||
FilePath packagePathFromSettings(const QString &settingsKey,
|
||||
QSettings::Scope scope,
|
||||
const FilePath &defaultPath)
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings(scope);
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
||||
QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + settingsKey;
|
||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||
+ QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + settingsKey;
|
||||
const QString path = settings->value(key, defaultPath.toString()).toString();
|
||||
return FilePath::fromUserInput(path);
|
||||
}
|
||||
|
@@ -43,20 +43,15 @@ QString matchRegExp(const QString &text, const QString ®Exp)
|
||||
return QString();
|
||||
}
|
||||
|
||||
McuPackageVersionDetector::McuPackageVersionDetector()
|
||||
{
|
||||
}
|
||||
McuPackageVersionDetector::McuPackageVersionDetector() {}
|
||||
|
||||
McuPackageExecutableVersionDetector::McuPackageExecutableVersionDetector(
|
||||
const QString &detectionPath,
|
||||
const QStringList &detectionArgs,
|
||||
const QString &detectionRegExp)
|
||||
const QString &detectionPath, const QStringList &detectionArgs, const QString &detectionRegExp)
|
||||
: McuPackageVersionDetector()
|
||||
, m_detectionPath(detectionPath)
|
||||
, m_detectionArgs(detectionArgs)
|
||||
, m_detectionRegExp(detectionRegExp)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
QString McuPackageExecutableVersionDetector::parseVersion(const QString &packagePath) const
|
||||
{
|
||||
@@ -76,8 +71,7 @@ QString McuPackageExecutableVersionDetector::parseVersion(const QString &package
|
||||
binaryProcess.waitForFinished(execTimeout);
|
||||
if (binaryProcess.exitStatus() == QProcess::NormalExit) {
|
||||
const QString processOutput = QString::fromUtf8(
|
||||
binaryProcess.readAllStandardOutput().append(
|
||||
binaryProcess.readAllStandardError()));
|
||||
binaryProcess.readAllStandardOutput().append(binaryProcess.readAllStandardError()));
|
||||
return matchRegExp(processOutput, m_detectionRegExp);
|
||||
}
|
||||
|
||||
@@ -89,23 +83,23 @@ McuPackageXmlVersionDetector::McuPackageXmlVersionDetector(const QString &filePa
|
||||
const QString &versionElement,
|
||||
const QString &versionAttribute,
|
||||
const QString &versionRegExp)
|
||||
: m_filePattern(filePattern),
|
||||
m_versionElement(versionElement),
|
||||
m_versionAttribute(versionAttribute),
|
||||
m_versionRegExp(versionRegExp)
|
||||
{
|
||||
}
|
||||
: m_filePattern(filePattern)
|
||||
, m_versionElement(versionElement)
|
||||
, m_versionAttribute(versionAttribute)
|
||||
, m_versionRegExp(versionRegExp)
|
||||
{}
|
||||
|
||||
QString McuPackageXmlVersionDetector::parseVersion(const QString &packagePath) const
|
||||
{
|
||||
const auto files = QDir(packagePath, m_filePattern).entryInfoList();
|
||||
for (const auto &xmlFile: files) {
|
||||
for (const auto &xmlFile : files) {
|
||||
QFile sdkXmlFile = QFile(xmlFile.absoluteFilePath());
|
||||
sdkXmlFile.open(QFile::OpenModeFlag::ReadOnly);
|
||||
QXmlStreamReader xmlReader(&sdkXmlFile);
|
||||
while (xmlReader.readNext()) {
|
||||
if (xmlReader.name() == m_versionElement) {
|
||||
const QString versionString = xmlReader.attributes().value(m_versionAttribute).toString();
|
||||
const QString versionString
|
||||
= xmlReader.attributes().value(m_versionAttribute).toString();
|
||||
const QString matched = matchRegExp(versionString, m_versionRegExp);
|
||||
return !matched.isEmpty() ? matched : versionString;
|
||||
}
|
||||
@@ -118,17 +112,16 @@ QString McuPackageXmlVersionDetector::parseVersion(const QString &packagePath) c
|
||||
McuPackageDirectoryVersionDetector::McuPackageDirectoryVersionDetector(const QString &filePattern,
|
||||
const QString &versionRegExp,
|
||||
const bool isFile)
|
||||
: m_filePattern(filePattern),
|
||||
m_versionRegExp(versionRegExp),
|
||||
m_isFile(isFile)
|
||||
{
|
||||
}
|
||||
: m_filePattern(filePattern)
|
||||
, m_versionRegExp(versionRegExp)
|
||||
, m_isFile(isFile)
|
||||
{}
|
||||
|
||||
QString McuPackageDirectoryVersionDetector::parseVersion(const QString &packagePath) const
|
||||
{
|
||||
const auto files = QDir(packagePath, m_filePattern)
|
||||
.entryInfoList(m_isFile ? QDir::Filter::Files : QDir::Filter::Dirs);
|
||||
for (const auto &entry: files) {
|
||||
for (const auto &entry : files) {
|
||||
const QString matched = matchRegExp(entry.fileName(), m_versionRegExp);
|
||||
if (!matched.isEmpty())
|
||||
return matched;
|
||||
@@ -138,8 +131,7 @@ QString McuPackageDirectoryVersionDetector::parseVersion(const QString &packageP
|
||||
|
||||
McuPackagePathVersionDetector::McuPackagePathVersionDetector(const QString &versionRegExp)
|
||||
: m_versionRegExp(versionRegExp)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
QString McuPackagePathVersionDetector::parseVersion(const QString &packagePath) const
|
||||
{
|
||||
@@ -148,5 +140,5 @@ QString McuPackagePathVersionDetector::parseVersion(const QString &packagePath)
|
||||
return matchRegExp(packagePath, m_versionRegExp);
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // McuSupport
|
||||
} // namespace Internal
|
||||
} // namespace McuSupport
|
||||
|
@@ -47,6 +47,7 @@ public:
|
||||
const QStringList &detectionArgs,
|
||||
const QString &detectionRegExp);
|
||||
QString parseVersion(const QString &packagePath) const final;
|
||||
|
||||
private:
|
||||
const QString m_detectionPath;
|
||||
const QStringList m_detectionArgs;
|
||||
@@ -62,6 +63,7 @@ public:
|
||||
const QString &versionAttribute,
|
||||
const QString &versionRegExp);
|
||||
QString parseVersion(const QString &packagePath) const final;
|
||||
|
||||
private:
|
||||
const QString m_filePattern;
|
||||
const QString m_versionElement;
|
||||
@@ -73,8 +75,11 @@ private:
|
||||
class McuPackageDirectoryVersionDetector : public McuPackageVersionDetector
|
||||
{
|
||||
public:
|
||||
McuPackageDirectoryVersionDetector(const QString &filePattern, const QString &versionRegExp, const bool isFile);
|
||||
McuPackageDirectoryVersionDetector(const QString &filePattern,
|
||||
const QString &versionRegExp,
|
||||
const bool isFile);
|
||||
QString parseVersion(const QString &packagePath) const final;
|
||||
|
||||
private:
|
||||
const QString m_filePattern;
|
||||
const QString m_versionRegExp;
|
||||
@@ -87,9 +92,10 @@ class McuPackagePathVersionDetector : public McuPackageVersionDetector
|
||||
public:
|
||||
McuPackagePathVersionDetector(const QString &versionRegExp);
|
||||
QString parseVersion(const QString &packagePath) const final;
|
||||
|
||||
private:
|
||||
const QString m_versionRegExp;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
} // McuSupport
|
||||
} // namespace Internal
|
||||
} // namespace McuSupport
|
||||
|
Reference in New Issue
Block a user