forked from qt-creator/qt-creator
McuSupport: Extract settings handling to a class
Change-Id: I671098f14d7bc13255dc130a4de1ab97d5bdab94 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -20,6 +20,7 @@ add_qtc_plugin(McuSupport
|
|||||||
mcusupportversiondetection.cpp mcusupportversiondetection.h
|
mcusupportversiondetection.cpp mcusupportversiondetection.h
|
||||||
mcutargetdescription.h
|
mcutargetdescription.h
|
||||||
mcuhelpers.cpp mcuhelpers.h
|
mcuhelpers.cpp mcuhelpers.h
|
||||||
|
settingshandler.cpp settingshandler.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
@@ -447,11 +447,11 @@ QList<Kit *> outdatedKits()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maintenance
|
// Maintenance
|
||||||
void createAutomaticKits()
|
void createAutomaticKits(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage()};
|
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage(settingsHandler)};
|
||||||
|
|
||||||
const auto createKits = [qtForMCUsPackage]() {
|
const auto createKits = [qtForMCUsPackage, settingsHandler]() {
|
||||||
if (McuSupportOptions::automaticKitCreationFromSettings()) {
|
if (McuSupportOptions::automaticKitCreationFromSettings()) {
|
||||||
qtForMCUsPackage->updateStatus();
|
qtForMCUsPackage->updateStatus();
|
||||||
if (!qtForMCUsPackage->isValidStatus()) {
|
if (!qtForMCUsPackage->isValidStatus()) {
|
||||||
@@ -494,7 +494,7 @@ void createAutomaticKits()
|
|||||||
}
|
}
|
||||||
|
|
||||||
FilePath dir = qtForMCUsPackage->path();
|
FilePath dir = qtForMCUsPackage->path();
|
||||||
McuSdkRepository repo{Sdk::targetsAndPackages(dir)};
|
McuSdkRepository repo{Sdk::targetsAndPackages(dir, settingsHandler)};
|
||||||
|
|
||||||
bool needsUpgrade = false;
|
bool needsUpgrade = false;
|
||||||
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
||||||
@@ -512,7 +512,7 @@ void createAutomaticKits()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needsUpgrade)
|
if (needsUpgrade)
|
||||||
McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade();
|
McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade(settingsHandler);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -524,15 +524,16 @@ void createAutomaticKits()
|
|||||||
// to upgrade, create new kits with current data, for the targets
|
// to upgrade, create new kits with current data, for the targets
|
||||||
// for which kits already existed
|
// for which kits already existed
|
||||||
// function parameter is option to keep the old ones or delete them
|
// function parameter is option to keep the old ones or delete them
|
||||||
void upgradeKitsByCreatingNewPackage(UpgradeOption upgradeOption)
|
void upgradeKitsByCreatingNewPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
|
UpgradeOption upgradeOption)
|
||||||
{
|
{
|
||||||
if (upgradeOption == UpgradeOption::Ignore)
|
if (upgradeOption == UpgradeOption::Ignore)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage()};
|
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage(settingsHandler)};
|
||||||
|
|
||||||
auto dir = qtForMCUsPackage->path();
|
auto dir = qtForMCUsPackage->path();
|
||||||
McuSdkRepository repo{Sdk::targetsAndPackages(dir)};
|
McuSdkRepository repo{Sdk::targetsAndPackages(dir, settingsHandler)};
|
||||||
|
|
||||||
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
||||||
if (!matchingKits(target.get(), qtForMCUsPackage).empty())
|
if (!matchingKits(target.get(), qtForMCUsPackage).empty())
|
||||||
@@ -569,12 +570,12 @@ void upgradeKitInPlace(ProjectExplorer::Kit *kit,
|
|||||||
// Maintenance
|
// Maintenance
|
||||||
// If the user changed a path in the McuSupport plugin's UI
|
// If the user changed a path in the McuSupport plugin's UI
|
||||||
// update the corresponding cmake variables in all existing kits
|
// update the corresponding cmake variables in all existing kits
|
||||||
void updatePathsInExistingKits()
|
void updatePathsInExistingKits(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage()};
|
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage(settingsHandler)};
|
||||||
|
|
||||||
FilePath dir = qtForMCUsPackage->path();
|
FilePath dir = qtForMCUsPackage->path();
|
||||||
McuSdkRepository repo{Sdk::targetsAndPackages(dir)};
|
McuSdkRepository repo{Sdk::targetsAndPackages(dir, settingsHandler)};
|
||||||
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
for (const auto &target : qAsConst(repo.mcuTargets)) {
|
||||||
if (target->isValid()) {
|
if (target->isValid()) {
|
||||||
for (auto *kit : kitsWithMismatchedDependencies(target.get())) {
|
for (auto *kit : kitsWithMismatchedDependencies(target.get())) {
|
||||||
@@ -603,7 +604,7 @@ void updatePathsInExistingKits()
|
|||||||
// Maintenance
|
// Maintenance
|
||||||
// if we changed minor details in the kits across versions of QtCreator
|
// if we changed minor details in the kits across versions of QtCreator
|
||||||
// this function updates those details in existing older kits
|
// this function updates those details in existing older kits
|
||||||
void fixExistingKits()
|
void fixExistingKits(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
for (Kit *kit : KitManager::kits()) {
|
for (Kit *kit : KitManager::kits()) {
|
||||||
if (!kit->hasValue(Constants::KIT_MCUTARGET_KITVERSION_KEY))
|
if (!kit->hasValue(Constants::KIT_MCUTARGET_KITVERSION_KEY))
|
||||||
@@ -656,11 +657,11 @@ void fixExistingKits()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fix kit dependencies for known targets
|
// Fix kit dependencies for known targets
|
||||||
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage()};
|
McuPackagePtr qtForMCUsPackage{Sdk::createQtForMCUsPackage(settingsHandler)};
|
||||||
qtForMCUsPackage->updateStatus();
|
qtForMCUsPackage->updateStatus();
|
||||||
if (qtForMCUsPackage->isValidStatus()) {
|
if (qtForMCUsPackage->isValidStatus()) {
|
||||||
FilePath dir = qtForMCUsPackage->path();
|
FilePath dir = qtForMCUsPackage->path();
|
||||||
McuSdkRepository repo{Sdk::targetsAndPackages(dir)};
|
McuSdkRepository repo{Sdk::targetsAndPackages(dir, settingsHandler)};
|
||||||
for (const auto &target : qAsConst(repo.mcuTargets))
|
for (const auto &target : qAsConst(repo.mcuTargets))
|
||||||
for (auto kit : existingKits(target.get())) {
|
for (auto kit : existingKits(target.get())) {
|
||||||
if (McuDependenciesKitAspect::dependencies(kit).isEmpty()) {
|
if (McuDependenciesKitAspect::dependencies(kit).isEmpty()) {
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "mcusupport_global.h"
|
#include "mcusupport_global.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <utils/environmentfwd.h>
|
#include <utils/environmentfwd.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@@ -63,15 +65,15 @@ QList<ProjectExplorer::Kit *> kitsWithMismatchedDependencies(const McuTarget *mc
|
|||||||
QList<ProjectExplorer::Kit *> outdatedKits();
|
QList<ProjectExplorer::Kit *> outdatedKits();
|
||||||
|
|
||||||
// Maintenance
|
// Maintenance
|
||||||
void createAutomaticKits();
|
void createAutomaticKits(const SettingsHandler::Ptr &);
|
||||||
void upgradeKitsByCreatingNewPackage(UpgradeOption upgradeOption);
|
void upgradeKitsByCreatingNewPackage(const SettingsHandler::Ptr &, UpgradeOption upgradeOption);
|
||||||
void upgradeKitInPlace(ProjectExplorer::Kit *kit,
|
void upgradeKitInPlace(ProjectExplorer::Kit *kit,
|
||||||
const McuTarget *mcuTarget,
|
const McuTarget *mcuTarget,
|
||||||
const McuPackagePtr &qtForMCUsSdk);
|
const McuPackagePtr &qtForMCUsSdk);
|
||||||
|
|
||||||
// Fixing kits:
|
// Fixing kits:
|
||||||
void updatePathsInExistingKits();
|
void updatePathsInExistingKits(const SettingsHandler::Ptr &);
|
||||||
void fixExistingKits();
|
void fixExistingKits(const SettingsHandler::Ptr &);
|
||||||
|
|
||||||
// Outdated kits:
|
// Outdated kits:
|
||||||
void removeOutdatedKits();
|
void removeOutdatedKits();
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "mcusupportconstants.h"
|
#include "mcusupportconstants.h"
|
||||||
#include "mcusupportsdk.h"
|
#include "mcusupportsdk.h"
|
||||||
#include "mcusupportversiondetection.h"
|
#include "mcusupportversiondetection.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <baremetal/baremetalconstants.h>
|
#include <baremetal/baremetalconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -49,7 +50,8 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace McuSupport::Internal {
|
namespace McuSupport::Internal {
|
||||||
|
|
||||||
McuPackage::McuPackage(const QString &label,
|
McuPackage::McuPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
|
const QString &label,
|
||||||
const FilePath &defaultPath,
|
const FilePath &defaultPath,
|
||||||
const FilePath &detectionPath,
|
const FilePath &detectionPath,
|
||||||
const QString &settingsKey,
|
const QString &settingsKey,
|
||||||
@@ -59,8 +61,9 @@ McuPackage::McuPackage(const QString &label,
|
|||||||
const McuPackageVersionDetector *versionDetector,
|
const McuPackageVersionDetector *versionDetector,
|
||||||
const bool addToSystemPath,
|
const bool addToSystemPath,
|
||||||
const FilePath &relativePathModifier)
|
const FilePath &relativePathModifier)
|
||||||
: m_label(label)
|
: settingsHandler(settingsHandler)
|
||||||
, m_defaultPath(Sdk::packagePathFromSettings(settingsKey, QSettings::SystemScope, defaultPath))
|
, m_label(label)
|
||||||
|
, m_defaultPath(settingsHandler->getPath(settingsKey, QSettings::SystemScope, defaultPath))
|
||||||
, m_detectionPath(detectionPath)
|
, m_detectionPath(detectionPath)
|
||||||
, m_settingsKey(settingsKey)
|
, m_settingsKey(settingsKey)
|
||||||
, m_versionDetector(versionDetector)
|
, m_versionDetector(versionDetector)
|
||||||
@@ -70,7 +73,7 @@ McuPackage::McuPackage(const QString &label,
|
|||||||
, m_downloadUrl(downloadUrl)
|
, m_downloadUrl(downloadUrl)
|
||||||
, m_addToSystemPath(addToSystemPath)
|
, m_addToSystemPath(addToSystemPath)
|
||||||
{
|
{
|
||||||
m_path = Sdk::packagePathFromSettings(settingsKey, QSettings::UserScope, m_defaultPath);
|
m_path = this->settingsHandler->getPath(settingsKey, QSettings::UserScope, m_defaultPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString McuPackage::label() const
|
QString McuPackage::label() const
|
||||||
@@ -227,14 +230,7 @@ QString McuPackage::statusText() const
|
|||||||
|
|
||||||
bool McuPackage::writeToSettings() const
|
bool McuPackage::writeToSettings() const
|
||||||
{
|
{
|
||||||
const FilePath savedPath = Sdk::packagePathFromSettings(m_settingsKey,
|
return settingsHandler->write(m_settingsKey, m_path, m_defaultPath);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *McuPackage::widget()
|
QWidget *McuPackage::widget()
|
||||||
@@ -277,7 +273,8 @@ QWidget *McuPackage::widget()
|
|||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage::McuToolChainPackage(const QString &label,
|
McuToolChainPackage::McuToolChainPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
|
const QString &label,
|
||||||
const FilePath &defaultPath,
|
const FilePath &defaultPath,
|
||||||
const FilePath &detectionPath,
|
const FilePath &detectionPath,
|
||||||
const QString &settingsKey,
|
const QString &settingsKey,
|
||||||
@@ -285,7 +282,8 @@ McuToolChainPackage::McuToolChainPackage(const QString &label,
|
|||||||
const QString &cmakeVarName,
|
const QString &cmakeVarName,
|
||||||
const QString &envVarName,
|
const QString &envVarName,
|
||||||
const McuPackageVersionDetector *versionDetector)
|
const McuPackageVersionDetector *versionDetector)
|
||||||
: McuPackage(label,
|
: McuPackage(settingsHandler,
|
||||||
|
label,
|
||||||
defaultPath,
|
defaultPath,
|
||||||
detectionPath,
|
detectionPath,
|
||||||
settingsKey,
|
settingsKey,
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "mcuabstractpackage.h"
|
#include "mcuabstractpackage.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
@@ -53,7 +54,8 @@ class McuPackage : public McuAbstractPackage
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
McuPackage(const QString &label,
|
McuPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
|
const QString &label,
|
||||||
const Utils::FilePath &defaultPath,
|
const Utils::FilePath &defaultPath,
|
||||||
const Utils::FilePath &detectionPath,
|
const Utils::FilePath &detectionPath,
|
||||||
const QString &settingsKey,
|
const QString &settingsKey,
|
||||||
@@ -91,6 +93,8 @@ private:
|
|||||||
void updatePath();
|
void updatePath();
|
||||||
void updateStatusUi();
|
void updateStatusUi();
|
||||||
|
|
||||||
|
SettingsHandler::Ptr settingsHandler;
|
||||||
|
|
||||||
Utils::PathChooser *m_fileChooser = nullptr;
|
Utils::PathChooser *m_fileChooser = nullptr;
|
||||||
Utils::InfoLabel *m_infoLabel = nullptr;
|
Utils::InfoLabel *m_infoLabel = nullptr;
|
||||||
|
|
||||||
@@ -118,7 +122,8 @@ class McuToolChainPackage : public McuPackage
|
|||||||
public:
|
public:
|
||||||
enum class ToolChainType { IAR, KEIL, MSVC, GCC, ArmGcc, GHS, GHSArm, Unsupported };
|
enum class ToolChainType { IAR, KEIL, MSVC, GCC, ArmGcc, GHS, GHSArm, Unsupported };
|
||||||
|
|
||||||
McuToolChainPackage(const QString &label,
|
McuToolChainPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
|
const QString &label,
|
||||||
const Utils::FilePath &defaultPath,
|
const Utils::FilePath &defaultPath,
|
||||||
const Utils::FilePath &detectionPath,
|
const Utils::FilePath &detectionPath,
|
||||||
const QString &settingsKey,
|
const QString &settingsKey,
|
||||||
|
@@ -51,6 +51,8 @@ QtcPlugin {
|
|||||||
"mcukitinformation.h",
|
"mcukitinformation.h",
|
||||||
"mcuhelpers.cpp",
|
"mcuhelpers.cpp",
|
||||||
"mcuhelpers.h",
|
"mcuhelpers.h",
|
||||||
|
"settingshandler.h",
|
||||||
|
"settingshandler.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
@@ -59,6 +61,7 @@ QtcPlugin {
|
|||||||
prefix: "test/"
|
prefix: "test/"
|
||||||
files: [
|
files: [
|
||||||
"packagemock.h",
|
"packagemock.h",
|
||||||
|
"settingshandlermock.h",
|
||||||
"unittest.cpp", "unittest.h"
|
"unittest.cpp", "unittest.h"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "mcusupportplugin.h"
|
#include "mcusupportplugin.h"
|
||||||
#include "mcusupportsdk.h"
|
#include "mcusupportsdk.h"
|
||||||
#include "mcutarget.h"
|
#include "mcutarget.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <cmakeprojectmanager/cmakekitinformation.h>
|
#include <cmakeprojectmanager/cmakekitinformation.h>
|
||||||
#include <cmakeprojectmanager/cmaketoolmanager.h>
|
#include <cmakeprojectmanager/cmaketoolmanager.h>
|
||||||
@@ -56,9 +57,10 @@ const QString automaticKitCreationSettingsKey = QLatin1String(Constants::SETTING
|
|||||||
Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
Constants::SETTINGS_KEY_AUTOMATIC_KIT_CREATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
McuSupportOptions::McuSupportOptions(QObject *parent)
|
McuSupportOptions::McuSupportOptions(const SettingsHandler::Ptr &settingsHandler, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage())
|
, qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage(settingsHandler))
|
||||||
|
, settingsHandler(settingsHandler)
|
||||||
{
|
{
|
||||||
connect(qtForMCUsSdkPackage.get(),
|
connect(qtForMCUsSdkPackage.get(),
|
||||||
&McuAbstractPackage::changed,
|
&McuAbstractPackage::changed,
|
||||||
@@ -72,9 +74,9 @@ void McuSupportOptions::populatePackagesAndTargets()
|
|||||||
setQulDir(qtForMCUsSdkPackage->path());
|
setQulDir(qtForMCUsSdkPackage->path());
|
||||||
}
|
}
|
||||||
|
|
||||||
static FilePath qulDocsDir()
|
FilePath McuSupportOptions::qulDocsDir() const
|
||||||
{
|
{
|
||||||
const FilePath qulDir = McuSupportOptions::qulDirFromSettings();
|
const FilePath qulDir = qulDirFromSettings();
|
||||||
if (qulDir.isEmpty() || !qulDir.exists())
|
if (qulDir.isEmpty() || !qulDir.exists())
|
||||||
return {};
|
return {};
|
||||||
const FilePath docsDir = qulDir / "docs";
|
const FilePath docsDir = qulDir / "docs";
|
||||||
@@ -102,7 +104,7 @@ void McuSupportOptions::registerExamples()
|
|||||||
auto examples = {std::make_pair(QStringLiteral("demos"), tr("Qt for MCUs Demos")),
|
auto examples = {std::make_pair(QStringLiteral("demos"), tr("Qt for MCUs Demos")),
|
||||||
std::make_pair(QStringLiteral("examples"), tr("Qt for MCUs Examples"))};
|
std::make_pair(QStringLiteral("examples"), tr("Qt for MCUs Examples"))};
|
||||||
for (const auto &dir : examples) {
|
for (const auto &dir : examples) {
|
||||||
const FilePath examplesDir = McuSupportOptions::qulDirFromSettings().pathAppended(dir.first);
|
const FilePath examplesDir = qulDirFromSettings() / dir.first;
|
||||||
if (!examplesDir.exists())
|
if (!examplesDir.exists())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -126,7 +128,7 @@ void McuSupportOptions::setQulDir(const FilePath &dir)
|
|||||||
{
|
{
|
||||||
qtForMCUsSdkPackage->updateStatus();
|
qtForMCUsSdkPackage->updateStatus();
|
||||||
if (qtForMCUsSdkPackage->isValidStatus())
|
if (qtForMCUsSdkPackage->isValidStatus())
|
||||||
sdkRepository = Sdk::targetsAndPackages(dir);
|
sdkRepository = Sdk::targetsAndPackages(dir, settingsHandler);
|
||||||
else
|
else
|
||||||
sdkRepository = McuSdkRepository{};
|
sdkRepository = McuSdkRepository{};
|
||||||
for (const auto &package : qAsConst(sdkRepository.packages))
|
for (const auto &package : qAsConst(sdkRepository.packages))
|
||||||
@@ -138,11 +140,11 @@ void McuSupportOptions::setQulDir(const FilePath &dir)
|
|||||||
emit packagesChanged();
|
emit packagesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath McuSupportOptions::qulDirFromSettings()
|
FilePath McuSupportOptions::qulDirFromSettings() const
|
||||||
{
|
{
|
||||||
return Sdk::packagePathFromSettings(Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK,
|
return settingsHandler->getPath(Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK,
|
||||||
QSettings::UserScope,
|
QSettings::UserScope,
|
||||||
{});
|
{});
|
||||||
}
|
}
|
||||||
|
|
||||||
McuKitManager::UpgradeOption McuSupportOptions::askForKitUpgrades()
|
McuKitManager::UpgradeOption McuSupportOptions::askForKitUpgrades()
|
||||||
@@ -175,7 +177,7 @@ void McuSupportOptions::checkUpgradeableKits()
|
|||||||
return !McuKitManager::upgradeableKits(target.get(), this->qtForMCUsSdkPackage).empty()
|
return !McuKitManager::upgradeableKits(target.get(), this->qtForMCUsSdkPackage).empty()
|
||||||
&& McuKitManager::matchingKits(target.get(), this->qtForMCUsSdkPackage).empty();
|
&& McuKitManager::matchingKits(target.get(), this->qtForMCUsSdkPackage).empty();
|
||||||
}))
|
}))
|
||||||
McuKitManager::upgradeKitsByCreatingNewPackage(askForKitUpgrades());
|
McuKitManager::upgradeKitsByCreatingNewPackage(settingsHandler, askForKitUpgrades());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool McuSupportOptions::kitsNeedQtVersion()
|
bool McuSupportOptions::kitsNeedQtVersion()
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "mcukitmanager.h"
|
#include "mcukitmanager.h"
|
||||||
#include "mcusupport_global.h"
|
#include "mcusupport_global.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <utils/environmentfwd.h>
|
#include <utils/environmentfwd.h>
|
||||||
|
|
||||||
@@ -63,17 +64,18 @@ class McuSupportOptions final : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit McuSupportOptions(QObject *parent = nullptr);
|
explicit McuSupportOptions(const SettingsHandler::Ptr &, QObject *parent = nullptr);
|
||||||
|
|
||||||
McuPackagePtr qtForMCUsSdkPackage{nullptr};
|
McuPackagePtr qtForMCUsSdkPackage{nullptr};
|
||||||
McuSdkRepository sdkRepository;
|
McuSdkRepository sdkRepository;
|
||||||
|
|
||||||
void setQulDir(const Utils::FilePath &dir);
|
void setQulDir(const Utils::FilePath &dir);
|
||||||
static Utils::FilePath qulDirFromSettings();
|
Utils::FilePath qulDirFromSettings() const;
|
||||||
|
Utils::FilePath qulDocsDir() const;
|
||||||
static McuKitManager::UpgradeOption askForKitUpgrades();
|
static McuKitManager::UpgradeOption askForKitUpgrades();
|
||||||
|
|
||||||
static void registerQchFiles();
|
void registerQchFiles();
|
||||||
static void registerExamples();
|
void registerExamples();
|
||||||
|
|
||||||
static const QVersionNumber &minimalQulVersion();
|
static const QVersionNumber &minimalQulVersion();
|
||||||
static bool isLegacyVersion(const QVersionNumber &version);
|
static bool isLegacyVersion(const QVersionNumber &version);
|
||||||
@@ -89,6 +91,8 @@ public:
|
|||||||
static bool automaticKitCreationFromSettings();
|
static bool automaticKitCreationFromSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SettingsHandler::Ptr settingsHandler;
|
||||||
|
|
||||||
bool m_automaticKitCreation = true;
|
bool m_automaticKitCreation = true;
|
||||||
signals:
|
signals:
|
||||||
void packagesChanged();
|
void packagesChanged();
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "mcusupportoptions.h"
|
#include "mcusupportoptions.h"
|
||||||
#include "mcusupportsdk.h"
|
#include "mcusupportsdk.h"
|
||||||
#include "mcutarget.h"
|
#include "mcutarget.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||||
#include <cmakeprojectmanager/cmaketoolmanager.h>
|
#include <cmakeprojectmanager/cmaketoolmanager.h>
|
||||||
@@ -58,7 +59,7 @@ class McuSupportOptionsWidget : public Core::IOptionsPageWidget
|
|||||||
Q_DECLARE_TR_FUNCTIONS(McuSupport::Internal::McuSupportOptionsWidget)
|
Q_DECLARE_TR_FUNCTIONS(McuSupport::Internal::McuSupportOptionsWidget)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
McuSupportOptionsWidget();
|
McuSupportOptionsWidget(McuSupportOptions &, const SettingsHandler::Ptr &);
|
||||||
|
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
void showMcuTargetPackages();
|
void showMcuTargetPackages();
|
||||||
@@ -71,7 +72,8 @@ private:
|
|||||||
void showEvent(QShowEvent *event) final;
|
void showEvent(QShowEvent *event) final;
|
||||||
|
|
||||||
QString m_armGccPath;
|
QString m_armGccPath;
|
||||||
McuSupportOptions m_options;
|
McuSupportOptions &m_options;
|
||||||
|
SettingsHandler::Ptr m_settingsHandler;
|
||||||
QMap<McuPackagePtr, QWidget *> m_packageWidgets;
|
QMap<McuPackagePtr, QWidget *> m_packageWidgets;
|
||||||
QMap<McuTargetPtr, QWidget *> m_mcuTargetPacketWidgets;
|
QMap<McuTargetPtr, QWidget *> m_mcuTargetPacketWidgets;
|
||||||
QFormLayout *m_packagesLayout = nullptr;
|
QFormLayout *m_packagesLayout = nullptr;
|
||||||
@@ -88,7 +90,10 @@ private:
|
|||||||
QPushButton *m_kitUpdatePushButton = nullptr;
|
QPushButton *m_kitUpdatePushButton = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
McuSupportOptionsWidget::McuSupportOptionsWidget()
|
McuSupportOptionsWidget::McuSupportOptionsWidget(McuSupportOptions &options,
|
||||||
|
const SettingsHandler::Ptr &settingsHandler)
|
||||||
|
: m_options{options}
|
||||||
|
, m_settingsHandler(settingsHandler)
|
||||||
{
|
{
|
||||||
auto mainLayout = new QVBoxLayout(this);
|
auto mainLayout = new QVBoxLayout(this);
|
||||||
|
|
||||||
@@ -161,7 +166,7 @@ McuSupportOptionsWidget::McuSupportOptionsWidget()
|
|||||||
m_kitCreationPushButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
m_kitCreationPushButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||||
connect(m_kitCreationPushButton, &QPushButton::clicked, this, [this] {
|
connect(m_kitCreationPushButton, &QPushButton::clicked, this, [this] {
|
||||||
McuKitManager::newKit(currentMcuTarget().get(), m_options.qtForMCUsSdkPackage);
|
McuKitManager::newKit(currentMcuTarget().get(), m_options.qtForMCUsSdkPackage);
|
||||||
McuSupportOptions::registerQchFiles();
|
m_options.registerQchFiles();
|
||||||
updateStatus();
|
updateStatus();
|
||||||
});
|
});
|
||||||
m_kitUpdatePushButton = new QPushButton(tr("Update Kit"));
|
m_kitUpdatePushButton = new QPushButton(tr("Update Kit"));
|
||||||
@@ -311,7 +316,7 @@ void McuSupportOptionsWidget::apply()
|
|||||||
|
|
||||||
if (pathsChanged) {
|
if (pathsChanged) {
|
||||||
m_options.checkUpgradeableKits();
|
m_options.checkUpgradeableKits();
|
||||||
McuKitManager::updatePathsInExistingKits();
|
McuKitManager::updatePathsInExistingKits(m_settingsHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,12 +331,15 @@ void McuSupportOptionsWidget::populateMcuTargetsComboBox()
|
|||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
McuSupportOptionsPage::McuSupportOptionsPage()
|
McuSupportOptionsPage::McuSupportOptionsPage(McuSupportOptions &options,
|
||||||
|
const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
setId(Utils::Id(Constants::SETTINGS_ID));
|
setId(Utils::Id(Constants::SETTINGS_ID));
|
||||||
setDisplayName(McuSupportOptionsWidget::tr("MCU"));
|
setDisplayName(McuSupportOptionsWidget::tr("MCU"));
|
||||||
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
|
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
|
||||||
setWidgetCreator([] { return new McuSupportOptionsWidget; });
|
setWidgetCreator([&options, &settingsHandler] {
|
||||||
|
return new McuSupportOptionsWidget(options, settingsHandler);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace McuSupport::Internal
|
} // namespace McuSupport::Internal
|
||||||
|
@@ -25,15 +25,19 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
namespace McuSupport {
|
namespace McuSupport {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class McuSupportOptions;
|
||||||
|
|
||||||
class McuSupportOptionsPage final : public Core::IOptionsPage
|
class McuSupportOptionsPage final : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
McuSupportOptionsPage();
|
McuSupportOptionsPage(McuSupportOptions &, const SettingsHandler::Ptr &);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -72,12 +72,17 @@ void printMessage(const QString &message, bool important)
|
|||||||
class McuSupportPluginPrivate
|
class McuSupportPluginPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
explicit McuSupportPluginPrivate(const SettingsHandler::Ptr &settingsHandler)
|
||||||
|
: m_settingsHandler(settingsHandler)
|
||||||
|
{}
|
||||||
McuSupportDeviceFactory deviceFactory;
|
McuSupportDeviceFactory deviceFactory;
|
||||||
McuSupportRunConfigurationFactory runConfigurationFactory;
|
McuSupportRunConfigurationFactory runConfigurationFactory;
|
||||||
RunWorkerFactory runWorkerFactory{makeFlashAndRunWorker(),
|
RunWorkerFactory runWorkerFactory{makeFlashAndRunWorker(),
|
||||||
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
|
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
|
||||||
{Constants::RUNCONFIGURATION}};
|
{Constants::RUNCONFIGURATION}};
|
||||||
McuSupportOptionsPage optionsPage;
|
SettingsHandler::Ptr m_settingsHandler;
|
||||||
|
McuSupportOptions m_options{m_settingsHandler};
|
||||||
|
McuSupportOptionsPage optionsPage{m_options, m_settingsHandler};
|
||||||
McuDependenciesKitAspect environmentPathsKitAspect;
|
McuDependenciesKitAspect environmentPathsKitAspect;
|
||||||
}; // class McuSupportPluginPrivate
|
}; // class McuSupportPluginPrivate
|
||||||
|
|
||||||
@@ -95,10 +100,10 @@ bool McuSupportPlugin::initialize(const QStringList &arguments, QString *errorSt
|
|||||||
Q_UNUSED(errorString)
|
Q_UNUSED(errorString)
|
||||||
|
|
||||||
setObjectName("McuSupportPlugin");
|
setObjectName("McuSupportPlugin");
|
||||||
dd = new McuSupportPluginPrivate;
|
dd = new McuSupportPluginPrivate(m_settingsHandler);
|
||||||
|
|
||||||
McuSupportOptions::registerQchFiles();
|
dd->m_options.registerQchFiles();
|
||||||
McuSupportOptions::registerExamples();
|
dd->m_options.registerExamples();
|
||||||
ProjectExplorer::JsonWizardFactory::addWizardPath(":/mcusupport/wizards/");
|
ProjectExplorer::JsonWizardFactory::addWizardPath(":/mcusupport/wizards/");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -108,18 +113,18 @@ void McuSupportPlugin::extensionsInitialized()
|
|||||||
{
|
{
|
||||||
ProjectExplorer::DeviceManager::instance()->addDevice(McuSupportDevice::create());
|
ProjectExplorer::DeviceManager::instance()->addDevice(McuSupportDevice::create());
|
||||||
|
|
||||||
connect(KitManager::instance(), &KitManager::kitsLoaded, []() {
|
connect(KitManager::instance(), &KitManager::kitsLoaded, [this]() {
|
||||||
McuKitManager::removeOutdatedKits();
|
McuKitManager::removeOutdatedKits();
|
||||||
McuKitManager::createAutomaticKits();
|
McuKitManager::createAutomaticKits(m_settingsHandler);
|
||||||
McuKitManager::fixExistingKits();
|
McuKitManager::fixExistingKits(m_settingsHandler);
|
||||||
McuSupportPlugin::askUserAboutMcuSupportKitsSetup();
|
askUserAboutMcuSupportKitsSetup();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportPlugin::askUserAboutMcuSupportKitsSetup()
|
void McuSupportPlugin::askUserAboutMcuSupportKitsSetup()
|
||||||
{
|
{
|
||||||
if (!ICore::infoBar()->canInfoBeAdded(setupMcuSupportKits)
|
if (!ICore::infoBar()->canInfoBeAdded(setupMcuSupportKits)
|
||||||
|| McuSupportOptions::qulDirFromSettings().isEmpty()
|
|| dd->m_options.qulDirFromSettings().isEmpty()
|
||||||
|| !McuKitManager::existingKits(nullptr).isEmpty())
|
|| !McuKitManager::existingKits(nullptr).isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -135,7 +140,7 @@ void McuSupportPlugin::askUserAboutMcuSupportKitsSetup()
|
|||||||
ICore::infoBar()->addInfo(info);
|
ICore::infoBar()->addInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade()
|
void McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
const char upgradeMcuSupportKits[] = "UpgradeMcuSupportKits";
|
const char upgradeMcuSupportKits[] = "UpgradeMcuSupportKits";
|
||||||
|
|
||||||
@@ -156,10 +161,10 @@ void McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade()
|
|||||||
selectedOption = selected.data.value<UpgradeOption>();
|
selectedOption = selected.data.value<UpgradeOption>();
|
||||||
});
|
});
|
||||||
|
|
||||||
info.addCustomButton(tr("Proceed"), [upgradeMcuSupportKits] {
|
info.addCustomButton(tr("Proceed"), [upgradeMcuSupportKits, settingsHandler] {
|
||||||
ICore::infoBar()->removeInfo(upgradeMcuSupportKits);
|
ICore::infoBar()->removeInfo(upgradeMcuSupportKits);
|
||||||
QTimer::singleShot(0, []() {
|
QTimer::singleShot(0, [settingsHandler]() {
|
||||||
McuKitManager::upgradeKitsByCreatingNewPackage(selectedOption);
|
McuKitManager::upgradeKitsByCreatingNewPackage(settingsHandler, selectedOption);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "mcusupport_global.h"
|
#include "mcusupport_global.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
@@ -44,11 +45,12 @@ public:
|
|||||||
bool initialize(const QStringList &arguments, QString *errorString) final;
|
bool initialize(const QStringList &arguments, QString *errorString) final;
|
||||||
void extensionsInitialized() final;
|
void extensionsInitialized() final;
|
||||||
|
|
||||||
static void askUserAboutMcuSupportKitsSetup();
|
void askUserAboutMcuSupportKitsSetup();
|
||||||
static void askUserAboutMcuSupportKitsUpgrade();
|
static void askUserAboutMcuSupportKitsUpgrade(const SettingsHandler::Ptr &settingsHandler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<QObject *> createTestObjects() const final;
|
QVector<QObject *> createTestObjects() const final;
|
||||||
|
SettingsHandler::Ptr m_settingsHandler{new SettingsHandler};
|
||||||
|
|
||||||
}; // class McuSupportPlugin
|
}; // class McuSupportPlugin
|
||||||
|
|
||||||
|
@@ -76,14 +76,16 @@ static FilePath findInProgramFiles(const QString &folder)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuAbstractPackage *createQtForMCUsPackage()
|
McuPackagePtr createQtForMCUsPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
return new McuPackage(McuPackage::tr("Qt for MCUs SDK"),
|
return McuPackagePtr{
|
||||||
FileUtils::homePath(), // defaultPath
|
new McuPackage(settingsHandler,
|
||||||
FilePath("bin/qmltocpp").withExecutableSuffix(), // detectionPath
|
McuPackage::tr("Qt for MCUs SDK"),
|
||||||
Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK, // settingsKey
|
FileUtils::homePath(), // defaultPath
|
||||||
QStringLiteral("Qul_ROOT"), // cmakeVarName
|
FilePath("bin/qmltocpp").withExecutableSuffix(), // detectionPath
|
||||||
QStringLiteral("Qul_DIR")); // envVarName
|
Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK, // settingsKey
|
||||||
|
QStringLiteral("Qul_ROOT"), // cmakeVarName
|
||||||
|
QStringLiteral("Qul_DIR"))}; // envVarName
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackageVersionDetector *generatePackageVersionDetector(const QString &envVar)
|
static McuPackageVersionDetector *generatePackageVersionDetector(const QString &envVar)
|
||||||
@@ -106,7 +108,8 @@ static McuPackageVersionDetector *generatePackageVersionDetector(const QString &
|
|||||||
/// Create the McuPackage by checking the "boardSdk" property in the JSON file for the board.
|
/// 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
|
/// The name of the environment variable pointing to the the SDK for the board will be defined in the "envVar" property
|
||||||
/// inside the "boardSdk".
|
/// inside the "boardSdk".
|
||||||
McuAbstractPackage *createBoardSdkPackage(const McuTargetDescription &desc)
|
McuPackagePtr createBoardSdkPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
|
const McuTargetDescription &desc)
|
||||||
{
|
{
|
||||||
const auto generateSdkName = [](const QString &envVar) {
|
const auto generateSdkName = [](const QString &envVar) {
|
||||||
qsizetype postfixPos = envVar.indexOf("_SDK_PATH");
|
qsizetype postfixPos = envVar.indexOf("_SDK_PATH");
|
||||||
@@ -134,19 +137,21 @@ McuAbstractPackage *createBoardSdkPackage(const McuTargetDescription &desc)
|
|||||||
|
|
||||||
const auto versionDetector = generatePackageVersionDetector(desc.boardSdk.envVar);
|
const auto versionDetector = generatePackageVersionDetector(desc.boardSdk.envVar);
|
||||||
|
|
||||||
return new McuPackage(sdkName,
|
return McuPackagePtr{new McuPackage(settingsHandler,
|
||||||
defaultPath,
|
sdkName,
|
||||||
{}, // detection path
|
defaultPath,
|
||||||
desc.boardSdk.envVar, // settings key
|
{}, // detection path
|
||||||
"QUL_BOARD_SDK_DIR", // cmake var
|
desc.boardSdk.envVar, // settings key
|
||||||
desc.boardSdk.envVar, // env var
|
"QUL_BOARD_SDK_DIR", // cmake var
|
||||||
{}, // download URL
|
desc.boardSdk.envVar, // env var
|
||||||
versionDetector);
|
{}, // download URL
|
||||||
|
versionDetector)};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuAbstractPackage *createFreeRTOSSourcesPackage(const QString &envVar,
|
McuPackagePtr createFreeRTOSSourcesPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
const FilePath &boardSdkDir,
|
const QString &envVar,
|
||||||
const FilePath &freeRTOSBoardSdkSubDir)
|
const FilePath &boardSdkDir,
|
||||||
|
const FilePath &freeRTOSBoardSdkSubDir)
|
||||||
{
|
{
|
||||||
const QString envVarPrefix = removeRtosSuffix(envVar);
|
const QString envVarPrefix = removeRtosSuffix(envVar);
|
||||||
|
|
||||||
@@ -156,31 +161,50 @@ McuAbstractPackage *createFreeRTOSSourcesPackage(const QString &envVar,
|
|||||||
else if (!boardSdkDir.isEmpty() && !freeRTOSBoardSdkSubDir.isEmpty())
|
else if (!boardSdkDir.isEmpty() && !freeRTOSBoardSdkSubDir.isEmpty())
|
||||||
defaultPath = boardSdkDir / freeRTOSBoardSdkSubDir.toString();
|
defaultPath = boardSdkDir / freeRTOSBoardSdkSubDir.toString();
|
||||||
|
|
||||||
return new McuPackage(QString::fromLatin1("FreeRTOS Sources (%1)").arg(envVarPrefix),
|
return McuPackagePtr{
|
||||||
defaultPath,
|
new McuPackage(settingsHandler,
|
||||||
{}, // detection path
|
QString::fromLatin1("FreeRTOS Sources (%1)").arg(envVarPrefix),
|
||||||
QString{Constants::SETTINGS_KEY_FREERTOS_PREFIX}.append(envVarPrefix),
|
defaultPath,
|
||||||
"FREERTOS_DIR", // cmake var
|
{}, // detection path
|
||||||
envVar, // env var
|
QString{Constants::SETTINGS_KEY_FREERTOS_PREFIX}.append(envVarPrefix),
|
||||||
"https://freertos.org"); // download url
|
"FREERTOS_DIR", // cmake var
|
||||||
|
envVar, // env var
|
||||||
|
"https://freertos.org")}; // download url
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage *createUnsupportedToolChainPackage()
|
McuPackagePtr createUnsupportedToolChainFilePackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::ToolChainType::Unsupported);
|
return McuPackagePtr{
|
||||||
|
new McuPackage(settingsHandler, {}, {}, {}, {}, Constants::TOOLCHAIN_FILE_CMAKE_VARIABLE, {})};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage *createMsvcToolChainPackage()
|
McuToolChainPackagePtr createUnsupportedToolChainPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::ToolChainType::MSVC);
|
return McuToolChainPackagePtr{new McuToolChainPackage(
|
||||||
|
settingsHandler, {}, {}, {}, {}, McuToolChainPackage::ToolChainType::Unsupported)};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage *createGccToolChainPackage()
|
McuToolChainPackagePtr createMsvcToolChainPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::ToolChainType::GCC);
|
return McuToolChainPackagePtr{new McuToolChainPackage(settingsHandler,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
McuToolChainPackage::ToolChainType::MSVC)};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage *createArmGccToolchainPackage()
|
McuToolChainPackagePtr createGccToolChainPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
|
{
|
||||||
|
return McuToolChainPackagePtr{new McuToolChainPackage(settingsHandler,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
McuToolChainPackage::ToolChainType::GCC)};
|
||||||
|
}
|
||||||
|
|
||||||
|
McuToolChainPackagePtr createArmGccToolchainPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
const char envVar[] = "ARMGCC_DIR";
|
const char envVar[] = "ARMGCC_DIR";
|
||||||
|
|
||||||
@@ -204,17 +228,19 @@ McuToolChainPackage *createArmGccToolchainPackage()
|
|||||||
{"--version"},
|
{"--version"},
|
||||||
"\\b(\\d+\\.\\d+\\.\\d+)\\b");
|
"\\b(\\d+\\.\\d+\\.\\d+)\\b");
|
||||||
|
|
||||||
return new McuToolChainPackage(McuPackage::tr("GNU Arm Embedded Toolchain"),
|
return McuToolChainPackagePtr{
|
||||||
defaultPath,
|
new McuToolChainPackage(settingsHandler,
|
||||||
detectionPath,
|
McuPackage::tr("GNU Arm Embedded Toolchain"),
|
||||||
"GNUArmEmbeddedToolchain", // settingsKey
|
defaultPath,
|
||||||
McuToolChainPackage::ToolChainType::ArmGcc, // toolchainType
|
detectionPath,
|
||||||
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE, // cmake var
|
"GNUArmEmbeddedToolchain", // settingsKey
|
||||||
envVar, // env var
|
McuToolChainPackage::ToolChainType::ArmGcc, // toolchainType
|
||||||
versionDetector);
|
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE, // cmake var
|
||||||
|
envVar, // env var
|
||||||
|
versionDetector)};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage *createGhsToolchainPackage()
|
McuToolChainPackagePtr createGhsToolchainPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
const char envVar[] = "GHS_COMPILER_DIR";
|
const char envVar[] = "GHS_COMPILER_DIR";
|
||||||
|
|
||||||
@@ -225,17 +251,19 @@ McuToolChainPackage *createGhsToolchainPackage()
|
|||||||
{"-V"},
|
{"-V"},
|
||||||
"\\bv(\\d+\\.\\d+\\.\\d+)\\b");
|
"\\bv(\\d+\\.\\d+\\.\\d+)\\b");
|
||||||
|
|
||||||
return new McuToolChainPackage("Green Hills Compiler",
|
return McuToolChainPackagePtr{
|
||||||
defaultPath,
|
new McuToolChainPackage(settingsHandler,
|
||||||
FilePath("ccv850").withExecutableSuffix(), // detectionPath
|
"Green Hills Compiler",
|
||||||
"GHSToolchain", // settingsKey
|
defaultPath,
|
||||||
McuToolChainPackage::ToolChainType::GHS, // toolchainType
|
FilePath("ccv850").withExecutableSuffix(), // detectionPath
|
||||||
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE, // cmake var
|
"GHSToolchain", // settingsKey
|
||||||
envVar, // env var
|
McuToolChainPackage::ToolChainType::GHS, // toolchainType
|
||||||
versionDetector);
|
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE, // cmake var
|
||||||
|
envVar, // env var
|
||||||
|
versionDetector)};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage *createGhsArmToolchainPackage()
|
McuToolChainPackagePtr createGhsArmToolchainPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
const char envVar[] = "GHS_ARM_COMPILER_DIR";
|
const char envVar[] = "GHS_ARM_COMPILER_DIR";
|
||||||
|
|
||||||
@@ -246,17 +274,19 @@ McuToolChainPackage *createGhsArmToolchainPackage()
|
|||||||
{"-V"},
|
{"-V"},
|
||||||
"\\bv(\\d+\\.\\d+\\.\\d+)\\b");
|
"\\bv(\\d+\\.\\d+\\.\\d+)\\b");
|
||||||
|
|
||||||
return new McuToolChainPackage("Green Hills Compiler for ARM",
|
return McuToolChainPackagePtr{
|
||||||
defaultPath,
|
new McuToolChainPackage(settingsHandler,
|
||||||
FilePath("cxarm").withExecutableSuffix(), // detectionPath
|
"Green Hills Compiler for ARM",
|
||||||
"GHSArmToolchain", // settingsKey
|
defaultPath,
|
||||||
McuToolChainPackage::ToolChainType::GHSArm, // toolchainType
|
FilePath("cxarm").withExecutableSuffix(), // detectionPath
|
||||||
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE, // cmake var
|
"GHSArmToolchain", // settingsKey
|
||||||
envVar, // env var
|
McuToolChainPackage::ToolChainType::GHSArm, // toolchainType
|
||||||
versionDetector);
|
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE, // cmake var
|
||||||
|
envVar, // env var
|
||||||
|
versionDetector)};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackage *createIarToolChainPackage()
|
McuToolChainPackagePtr createIarToolChainPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
const char envVar[] = "IAR_ARM_COMPILER_DIR";
|
const char envVar[] = "IAR_ARM_COMPILER_DIR";
|
||||||
|
|
||||||
@@ -280,17 +310,19 @@ McuToolChainPackage *createIarToolChainPackage()
|
|||||||
{"--version"},
|
{"--version"},
|
||||||
"\\bV(\\d+\\.\\d+\\.\\d+)\\.\\d+\\b");
|
"\\bV(\\d+\\.\\d+\\.\\d+)\\.\\d+\\b");
|
||||||
|
|
||||||
return new McuToolChainPackage("IAR ARM Compiler",
|
return McuToolChainPackagePtr{
|
||||||
defaultPath,
|
new McuToolChainPackage(settingsHandler,
|
||||||
detectionPath,
|
"IAR ARM Compiler",
|
||||||
"IARToolchain", // settings key
|
defaultPath,
|
||||||
McuToolChainPackage::ToolChainType::IAR, // toolchainType
|
detectionPath,
|
||||||
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE, // cmake var
|
"IARToolchain", // settings key
|
||||||
envVar, // env var
|
McuToolChainPackage::ToolChainType::IAR, // toolchainType
|
||||||
versionDetector);
|
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE, // cmake var
|
||||||
|
envVar, // env var
|
||||||
|
versionDetector)};
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackage *createStm32CubeProgrammerPackage()
|
static McuPackagePtr createStm32CubeProgrammerPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
FilePath defaultPath;
|
FilePath defaultPath;
|
||||||
const QString cubePath = "STMicroelectronics/STM32Cube/STM32CubeProgrammer";
|
const QString cubePath = "STMicroelectronics/STM32Cube/STM32CubeProgrammer";
|
||||||
@@ -308,22 +340,22 @@ static McuPackage *createStm32CubeProgrammerPackage()
|
|||||||
QLatin1String(Utils::HostOsInfo::isWindowsHost() ? "/bin/STM32_Programmer_CLI.exe"
|
QLatin1String(Utils::HostOsInfo::isWindowsHost() ? "/bin/STM32_Programmer_CLI.exe"
|
||||||
: "/bin/STM32_Programmer.sh"));
|
: "/bin/STM32_Programmer.sh"));
|
||||||
|
|
||||||
auto result
|
return McuPackagePtr{
|
||||||
= new McuPackage(McuPackage::tr("STM32CubeProgrammer"),
|
new McuPackage(settingsHandler,
|
||||||
defaultPath,
|
McuPackage::tr("STM32CubeProgrammer"),
|
||||||
detectionPath,
|
defaultPath,
|
||||||
"Stm32CubeProgrammer",
|
detectionPath,
|
||||||
{}, // cmake var
|
"Stm32CubeProgrammer",
|
||||||
{}, // env var
|
{}, // cmake var
|
||||||
"https://www.st.com/en/development-tools/stm32cubeprog.html", // download url
|
{}, // env var
|
||||||
nullptr, // version detector
|
"https://www.st.com/en/development-tools/stm32cubeprog.html", // download url
|
||||||
true, // add to path
|
nullptr, // version detector
|
||||||
"/bin" // relative path modifier
|
true, // add to path
|
||||||
);
|
"/bin" // relative path modifier
|
||||||
return result;
|
)};
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackage *createMcuXpressoIdePackage()
|
static McuPackagePtr createMcuXpressoIdePackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
const char envVar[] = "MCUXpressoIDE_PATH";
|
const char envVar[] = "MCUXpressoIDE_PATH";
|
||||||
|
|
||||||
@@ -346,17 +378,18 @@ static McuPackage *createMcuXpressoIdePackage()
|
|||||||
defaultPath = programPath;
|
defaultPath = programPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new McuPackage("MCUXpresso IDE",
|
return McuPackagePtr{new McuPackage(settingsHandler,
|
||||||
defaultPath,
|
"MCUXpresso IDE",
|
||||||
FilePath("ide/binaries/crt_emu_cm_redlink")
|
defaultPath,
|
||||||
.withExecutableSuffix(), // detection path
|
FilePath("ide/binaries/crt_emu_cm_redlink")
|
||||||
"MCUXpressoIDE", // settings key
|
.withExecutableSuffix(), // detection path
|
||||||
"MCUXPRESSO_IDE_PATH", // cmake var
|
"MCUXpressoIDE", // settings key
|
||||||
envVar,
|
"MCUXPRESSO_IDE_PATH", // cmake var
|
||||||
"https://www.nxp.com/mcuxpresso/ide"); // download url
|
envVar,
|
||||||
|
"https://www.nxp.com/mcuxpresso/ide")}; // download url
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackage *createCypressProgrammerPackage()
|
static McuPackagePtr createCypressProgrammerPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
const char envVar[] = "CYPRESS_AUTO_FLASH_UTILITY_DIR";
|
const char envVar[] = "CYPRESS_AUTO_FLASH_UTILITY_DIR";
|
||||||
|
|
||||||
@@ -374,16 +407,16 @@ static McuPackage *createCypressProgrammerPackage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = new McuPackage("Cypress Auto Flash Utility",
|
return McuPackagePtr{new McuPackage(settingsHandler,
|
||||||
defaultPath,
|
"Cypress Auto Flash Utility",
|
||||||
FilePath("/bin/openocd").withExecutableSuffix(),
|
defaultPath,
|
||||||
"CypressAutoFlashUtil", // settings key
|
FilePath("/bin/openocd").withExecutableSuffix(),
|
||||||
"INFINEON_AUTO_FLASH_UTILITY_DIR", // cmake var
|
"CypressAutoFlashUtil", // settings key
|
||||||
envVar); // env var
|
"INFINEON_AUTO_FLASH_UTILITY_DIR", // cmake var
|
||||||
return result;
|
envVar)}; // env var
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackage *createRenesasProgrammerPackage()
|
static McuPackagePtr createRenesasProgrammerPackage(const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
const char envVar[] = "RenesasFlashProgrammer_PATH";
|
const char envVar[] = "RenesasFlashProgrammer_PATH";
|
||||||
|
|
||||||
@@ -401,51 +434,56 @@ static McuPackage *createRenesasProgrammerPackage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = new McuPackage("Renesas Flash Programmer",
|
return McuPackagePtr{new McuPackage(settingsHandler,
|
||||||
defaultPath,
|
"Renesas Flash Programmer",
|
||||||
FilePath("rfp-cli").withExecutableSuffix(),
|
defaultPath,
|
||||||
"RenesasFlashProgrammer", // settings key
|
FilePath("rfp-cli").withExecutableSuffix(),
|
||||||
"RENESAS_FLASH_PROGRAMMER_PATH", // cmake var
|
"RenesasFlashProgrammer", // settings key
|
||||||
envVar); // env var
|
"RENESAS_FLASH_PROGRAMMER_PATH", // cmake var
|
||||||
return result;
|
envVar)}; // env var
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuAbstractTargetFactory::Ptr createFactory(bool isLegacy)
|
static McuAbstractTargetFactory::Ptr createFactory(bool isLegacy,
|
||||||
|
const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
McuAbstractTargetFactory::Ptr result;
|
McuAbstractTargetFactory::Ptr result;
|
||||||
if (isLegacy) {
|
if (isLegacy) {
|
||||||
static const QHash<QString, McuToolChainPackagePtr> tcPkgs = {
|
static const QHash<QString, McuToolChainPackagePtr> toolchainCompilers = {
|
||||||
{{"armgcc"}, McuToolChainPackagePtr{createArmGccToolchainPackage()}},
|
{{"armgcc"}, McuToolChainPackagePtr{createArmGccToolchainPackage(settingsHandler)}},
|
||||||
{{"greenhills"}, McuToolChainPackagePtr{createGhsToolchainPackage()}},
|
{{"greenhills"}, McuToolChainPackagePtr{createGhsToolchainPackage(settingsHandler)}},
|
||||||
{{"iar"}, McuToolChainPackagePtr{createIarToolChainPackage()}},
|
{{"iar"}, McuToolChainPackagePtr{createIarToolChainPackage(settingsHandler)}},
|
||||||
{{"msvc"}, McuToolChainPackagePtr{createMsvcToolChainPackage()}},
|
{{"msvc"}, McuToolChainPackagePtr{createMsvcToolChainPackage(settingsHandler)}},
|
||||||
{{"gcc"}, McuToolChainPackagePtr{createGccToolChainPackage()}},
|
{{"gcc"}, McuToolChainPackagePtr{createGccToolChainPackage(settingsHandler)}},
|
||||||
{{"arm-greenhills"}, McuToolChainPackagePtr{createGhsArmToolchainPackage()}},
|
{{"arm-greenhills"},
|
||||||
|
McuToolChainPackagePtr{createGhsArmToolchainPackage(settingsHandler)}},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note: the vendor name (the key of the hash) is case-sensitive. It has to match the "platformVendor" key in the
|
// Note: the vendor name (the key of the hash) is case-sensitive. It has to match the "platformVendor" key in the
|
||||||
// json file.
|
// json file.
|
||||||
static const QHash<QString, McuPackagePtr> vendorPkgs = {
|
static const QHash<QString, McuPackagePtr> vendorPkgs = {
|
||||||
{{"ST"}, McuPackagePtr{createStm32CubeProgrammerPackage()}},
|
{{"ST"}, McuPackagePtr{createStm32CubeProgrammerPackage(settingsHandler)}},
|
||||||
{{"NXP"}, McuPackagePtr{createMcuXpressoIdePackage()}},
|
{{"NXP"}, McuPackagePtr{createMcuXpressoIdePackage(settingsHandler)}},
|
||||||
{{"CYPRESS"}, McuPackagePtr{createCypressProgrammerPackage()}},
|
{{"CYPRESS"}, McuPackagePtr{createCypressProgrammerPackage(settingsHandler)}},
|
||||||
{{"RENESAS"}, McuPackagePtr{createRenesasProgrammerPackage()}},
|
{{"RENESAS"}, McuPackagePtr{createRenesasProgrammerPackage(settingsHandler)}},
|
||||||
};
|
};
|
||||||
|
|
||||||
result = std::make_unique<McuTargetFactoryLegacy>(tcPkgs, vendorPkgs);
|
result = std::make_unique<McuTargetFactoryLegacy>(toolchainCompilers,
|
||||||
|
vendorPkgs,
|
||||||
|
settingsHandler);
|
||||||
} else {
|
} else {
|
||||||
result = std::make_unique<McuTargetFactory>();
|
result = std::make_unique<McuTargetFactory>(settingsHandler);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
McuSdkRepository targetsFromDescriptions(const QList<McuTargetDescription> &descriptions,
|
McuSdkRepository targetsFromDescriptions(const QList<McuTargetDescription> &descriptions,
|
||||||
|
const SettingsHandler::Ptr &settingsHandler,
|
||||||
bool isLegacy)
|
bool isLegacy)
|
||||||
{
|
{
|
||||||
Targets mcuTargets;
|
Targets mcuTargets;
|
||||||
Packages mcuPackages;
|
Packages mcuPackages;
|
||||||
|
|
||||||
McuAbstractTargetFactory::Ptr targetFactory = createFactory(isLegacy);
|
McuAbstractTargetFactory::Ptr targetFactory = createFactory(isLegacy, settingsHandler);
|
||||||
for (const McuTargetDescription &desc : descriptions) {
|
for (const McuTargetDescription &desc : descriptions) {
|
||||||
auto [targets, packages] = targetFactory->createTargets(desc);
|
auto [targets, packages] = targetFactory->createTargets(desc);
|
||||||
mcuTargets.append(targets);
|
mcuTargets.append(targets);
|
||||||
@@ -587,12 +625,13 @@ bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
McuSdkRepository targetsAndPackages(const Utils::FilePath &dir)
|
McuSdkRepository targetsAndPackages(const Utils::FilePath &qtForMCUSdkPath,
|
||||||
|
const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
QList<McuTargetDescription> descriptions;
|
QList<McuTargetDescription> descriptions;
|
||||||
bool isLegacy{false};
|
bool isLegacy{false};
|
||||||
|
|
||||||
auto descriptionFiles = targetDescriptionFiles(dir);
|
auto descriptionFiles = targetDescriptionFiles(qtForMCUSdkPath);
|
||||||
for (const QFileInfo &fileInfo : descriptionFiles) {
|
for (const QFileInfo &fileInfo : descriptionFiles) {
|
||||||
QFile file(fileInfo.absoluteFilePath());
|
QFile file(fileInfo.absoluteFilePath());
|
||||||
if (!file.open(QFile::ReadOnly))
|
if (!file.open(QFile::ReadOnly))
|
||||||
@@ -631,20 +670,20 @@ McuSdkRepository targetsAndPackages(const Utils::FilePath &dir)
|
|||||||
|
|
||||||
// No valid description means invalid or old SDK installation.
|
// No valid description means invalid or old SDK installation.
|
||||||
if (descriptions.empty()) {
|
if (descriptions.empty()) {
|
||||||
if (kitsPath(dir).exists()) {
|
if (kitsPath(qtForMCUSdkPath).exists()) {
|
||||||
printMessage(McuTarget::tr("No valid kit descriptions found at %1.")
|
printMessage(McuTarget::tr("No valid kit descriptions found at %1.")
|
||||||
.arg(kitsPath(dir).toUserOutput()),
|
.arg(kitsPath(qtForMCUSdkPath).toUserOutput()),
|
||||||
true);
|
true);
|
||||||
return McuSdkRepository{};
|
return McuSdkRepository{};
|
||||||
} else {
|
} else {
|
||||||
QString deprecationMessage;
|
QString deprecationMessage;
|
||||||
if (checkDeprecatedSdkError(dir, deprecationMessage)) {
|
if (checkDeprecatedSdkError(qtForMCUSdkPath, deprecationMessage)) {
|
||||||
printMessage(deprecationMessage, true);
|
printMessage(deprecationMessage, true);
|
||||||
return McuSdkRepository{};
|
return McuSdkRepository{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
McuSdkRepository repo = targetsFromDescriptions(descriptions, isLegacy);
|
McuSdkRepository repo = targetsFromDescriptions(descriptions, settingsHandler, isLegacy);
|
||||||
|
|
||||||
// Keep targets sorted lexicographically
|
// Keep targets sorted lexicographically
|
||||||
Utils::sort(repo.mcuTargets, [](const McuTargetPtr &lhs, const McuTargetPtr &rhs) {
|
Utils::sort(repo.mcuTargets, [](const McuTargetPtr &lhs, const McuTargetPtr &rhs) {
|
||||||
@@ -654,17 +693,6 @@ McuSdkRepository targetsAndPackages(const Utils::FilePath &dir)
|
|||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 path = settings->value(key, defaultPath.toString()).toString();
|
|
||||||
return FilePath::fromUserInput(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Sdk
|
} // namespace Sdk
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace McuSupport
|
} // namespace McuSupport
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "mcusupport_global.h"
|
#include "mcusupport_global.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
@@ -44,33 +45,33 @@ namespace Sdk {
|
|||||||
|
|
||||||
struct McuTargetDescription;
|
struct McuTargetDescription;
|
||||||
|
|
||||||
McuAbstractPackage *createQtForMCUsPackage();
|
McuPackagePtr createQtForMCUsPackage(const SettingsHandler::Ptr &);
|
||||||
|
|
||||||
bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message);
|
bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message);
|
||||||
|
|
||||||
McuSdkRepository targetsAndPackages(const Utils::FilePath &qulDir);
|
McuSdkRepository targetsAndPackages(const Utils::FilePath &qulDir, const SettingsHandler::Ptr &);
|
||||||
|
|
||||||
McuTargetDescription parseDescriptionJson(const QByteArray &);
|
McuTargetDescription parseDescriptionJson(const QByteArray &);
|
||||||
McuSdkRepository targetsFromDescriptions(const QList<McuTargetDescription> &, bool isLegacy);
|
McuSdkRepository targetsFromDescriptions(const QList<McuTargetDescription> &,
|
||||||
|
const SettingsHandler::Ptr &,
|
||||||
|
bool isLegacy);
|
||||||
|
|
||||||
Utils::FilePath kitsPath(const Utils::FilePath &dir);
|
Utils::FilePath kitsPath(const Utils::FilePath &dir);
|
||||||
|
|
||||||
Utils::FilePath packagePathFromSettings(const QString &settingsKey,
|
McuPackagePtr createUnsupportedToolChainFilePackage(const SettingsHandler::Ptr &);
|
||||||
QSettings::Scope scope,
|
McuToolChainPackagePtr createUnsupportedToolChainPackage(const SettingsHandler::Ptr &);
|
||||||
const Utils::FilePath &defaultPath);
|
McuToolChainPackagePtr createIarToolChainPackage(const SettingsHandler::Ptr &);
|
||||||
|
McuToolChainPackagePtr createGccToolChainPackage(const SettingsHandler::Ptr &);
|
||||||
|
McuToolChainPackagePtr createArmGccToolchainPackage(const SettingsHandler::Ptr &);
|
||||||
|
McuToolChainPackagePtr createMsvcToolChainPackage(const SettingsHandler::Ptr &);
|
||||||
|
McuToolChainPackagePtr createGhsToolchainPackage(const SettingsHandler::Ptr &);
|
||||||
|
McuToolChainPackagePtr createGhsArmToolchainPackage(const SettingsHandler::Ptr &);
|
||||||
|
|
||||||
McuToolChainPackage *createUnsupportedToolChainPackage();
|
McuPackagePtr createBoardSdkPackage(const SettingsHandler::Ptr &, const McuTargetDescription &);
|
||||||
McuToolChainPackage *createIarToolChainPackage();
|
McuPackagePtr createFreeRTOSSourcesPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
McuToolChainPackage *createGccToolChainPackage();
|
const QString &envVar,
|
||||||
McuToolChainPackage *createArmGccToolchainPackage();
|
const Utils::FilePath &boardSdkDir,
|
||||||
McuToolChainPackage *createMsvcToolChainPackage();
|
const Utils::FilePath &freeRTOSBoardSdkSubDir);
|
||||||
McuToolChainPackage *createGhsToolchainPackage();
|
|
||||||
McuToolChainPackage *createGhsArmToolchainPackage();
|
|
||||||
|
|
||||||
McuAbstractPackage *createBoardSdkPackage(const McuTargetDescription &desc);
|
|
||||||
McuAbstractPackage *createFreeRTOSSourcesPackage(const QString &envVar,
|
|
||||||
const Utils::FilePath &boardSdkDir,
|
|
||||||
const Utils::FilePath &freeRTOSBoardSdkSubDir);
|
|
||||||
|
|
||||||
} // namespace Sdk
|
} // namespace Sdk
|
||||||
} // namespace McuSupport::Internal
|
} // namespace McuSupport::Internal
|
||||||
|
@@ -61,6 +61,10 @@ const static QMap<QString, McuToolChainPackage::ToolChainType> toolchainTypeMapp
|
|||||||
{"ghsarm", McuToolChainPackage::ToolChainType::GHSArm},
|
{"ghsarm", McuToolChainPackage::ToolChainType::GHSArm},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
McuTargetFactory::McuTargetFactory(const SettingsHandler::Ptr &settingsHandler)
|
||||||
|
: settingsHandler{settingsHandler}
|
||||||
|
{}
|
||||||
|
|
||||||
QPair<Targets, Packages> McuTargetFactory::createTargets(const McuTargetDescription &desc)
|
QPair<Targets, Packages> McuTargetFactory::createTargets(const McuTargetDescription &desc)
|
||||||
{
|
{
|
||||||
Targets mcuTargets;
|
Targets mcuTargets;
|
||||||
@@ -109,6 +113,7 @@ Packages McuTargetFactory::createPackages(const McuTargetDescription &desc)
|
|||||||
McuPackagePtr McuTargetFactory::createPackage(const PackageDescription &pkgDesc)
|
McuPackagePtr McuTargetFactory::createPackage(const PackageDescription &pkgDesc)
|
||||||
{
|
{
|
||||||
return McuPackagePtr{new McuPackage{
|
return McuPackagePtr{new McuPackage{
|
||||||
|
settingsHandler,
|
||||||
pkgDesc.label,
|
pkgDesc.label,
|
||||||
pkgDesc.defaultPath,
|
pkgDesc.defaultPath,
|
||||||
pkgDesc.validationPath,
|
pkgDesc.validationPath,
|
||||||
@@ -130,11 +135,12 @@ McuToolChainPackage *McuTargetFactory::createToolchain(
|
|||||||
= toolchainTypeMapping.value(toolchain.id, McuToolChainPackage::ToolChainType::Unsupported);
|
= toolchainTypeMapping.value(toolchain.id, McuToolChainPackage::ToolChainType::Unsupported);
|
||||||
|
|
||||||
if (isDesktopToolchain(toolchainType))
|
if (isDesktopToolchain(toolchainType))
|
||||||
return new McuToolChainPackage{{}, {}, {}, {}, toolchainType};
|
return new McuToolChainPackage{settingsHandler, {}, {}, {}, {}, toolchainType};
|
||||||
else if (!isToolchainDescriptionValid(toolchain))
|
else if (!isToolchainDescriptionValid(toolchain))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return new McuToolChainPackage{
|
return new McuToolChainPackage{
|
||||||
|
settingsHandler,
|
||||||
compilerDescription.label,
|
compilerDescription.label,
|
||||||
compilerDescription.defaultPath,
|
compilerDescription.defaultPath,
|
||||||
compilerDescription.validationPath,
|
compilerDescription.validationPath,
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "mcuabstracttargetfactory.h"
|
#include "mcuabstracttargetfactory.h"
|
||||||
#include "mcutargetdescription.h"
|
#include "mcutargetdescription.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
namespace McuSupport::Internal::Sdk {
|
namespace McuSupport::Internal::Sdk {
|
||||||
|
|
||||||
@@ -35,10 +36,14 @@ struct PackageDescription;
|
|||||||
class McuTargetFactory : public McuAbstractTargetFactory
|
class McuTargetFactory : public McuAbstractTargetFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QPair<Targets, Packages> createTargets(const McuTargetDescription &) override;
|
explicit McuTargetFactory(const SettingsHandler::Ptr &);
|
||||||
Packages createPackages(const McuTargetDescription &);
|
QPair<Targets, Packages> createTargets(const Sdk::McuTargetDescription &) override;
|
||||||
McuToolChainPackage *createToolchain(const McuTargetDescription::Toolchain &);
|
Packages createPackages(const Sdk::McuTargetDescription &);
|
||||||
McuPackagePtr createPackage(const PackageDescription &);
|
McuToolChainPackage *createToolchain(const Sdk::McuTargetDescription::Toolchain &);
|
||||||
|
McuPackagePtr createPackage(const Sdk::PackageDescription &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
SettingsHandler::Ptr settingsHandler;
|
||||||
}; // struct McuTargetFactory
|
}; // struct McuTargetFactory
|
||||||
|
|
||||||
} // namespace McuSupport::Internal::Sdk
|
} // namespace McuSupport::Internal::Sdk
|
||||||
|
@@ -36,6 +36,14 @@
|
|||||||
|
|
||||||
namespace McuSupport::Internal::Sdk {
|
namespace McuSupport::Internal::Sdk {
|
||||||
|
|
||||||
|
McuTargetFactoryLegacy::McuTargetFactoryLegacy(const QHash<QString, McuToolChainPackagePtr> &tcPkgs,
|
||||||
|
const QHash<QString, McuPackagePtr> &vendorPkgs,
|
||||||
|
const SettingsHandler::Ptr &settingsHandler)
|
||||||
|
: tcPkgs(tcPkgs)
|
||||||
|
, vendorPkgs(vendorPkgs)
|
||||||
|
, settingsHandler(settingsHandler)
|
||||||
|
{}
|
||||||
|
|
||||||
QPair<Targets, Packages> McuTargetFactoryLegacy::createTargets(const McuTargetDescription &desc)
|
QPair<Targets, Packages> McuTargetFactoryLegacy::createTargets(const McuTargetDescription &desc)
|
||||||
{
|
{
|
||||||
QHash<QString, McuPackagePtr> boardSdkPkgs;
|
QHash<QString, McuPackagePtr> boardSdkPkgs;
|
||||||
@@ -46,7 +54,7 @@ QPair<Targets, Packages> McuTargetFactoryLegacy::createTargets(const McuTargetDe
|
|||||||
if (tcPkg) {
|
if (tcPkg) {
|
||||||
tcPkg->setVersions(desc.toolchain.versions);
|
tcPkg->setVersions(desc.toolchain.versions);
|
||||||
} else {
|
} else {
|
||||||
tcPkg.reset(createUnsupportedToolChainPackage());
|
tcPkg = createUnsupportedToolChainPackage(settingsHandler);
|
||||||
}
|
}
|
||||||
for (int colorDepth : desc.platform.colorDepths) {
|
for (int colorDepth : desc.platform.colorDepths) {
|
||||||
Packages required3rdPartyPkgs;
|
Packages required3rdPartyPkgs;
|
||||||
@@ -65,7 +73,7 @@ QPair<Targets, Packages> McuTargetFactoryLegacy::createTargets(const McuTargetDe
|
|||||||
Utils::FilePath boardSdkDefaultPath;
|
Utils::FilePath boardSdkDefaultPath;
|
||||||
if (!desc.boardSdk.envVar.isEmpty()) {
|
if (!desc.boardSdk.envVar.isEmpty()) {
|
||||||
if (!boardSdkPkgs.contains(desc.boardSdk.envVar)) {
|
if (!boardSdkPkgs.contains(desc.boardSdk.envVar)) {
|
||||||
McuPackagePtr boardSdkPkg{createBoardSdkPackage(desc)};
|
McuPackagePtr boardSdkPkg{createBoardSdkPackage(settingsHandler, desc)};
|
||||||
boardSdkPkgs.insert(desc.boardSdk.envVar, boardSdkPkg);
|
boardSdkPkgs.insert(desc.boardSdk.envVar, boardSdkPkg);
|
||||||
}
|
}
|
||||||
McuPackagePtr boardSdkPkg{boardSdkPkgs.value(desc.boardSdk.envVar)};
|
McuPackagePtr boardSdkPkg{boardSdkPkgs.value(desc.boardSdk.envVar)};
|
||||||
@@ -77,11 +85,13 @@ QPair<Targets, Packages> McuTargetFactoryLegacy::createTargets(const McuTargetDe
|
|||||||
// Free RTOS specific settings.
|
// Free RTOS specific settings.
|
||||||
if (!desc.freeRTOS.envVar.isEmpty()) {
|
if (!desc.freeRTOS.envVar.isEmpty()) {
|
||||||
if (!freeRTOSPkgs.contains(desc.freeRTOS.envVar)) {
|
if (!freeRTOSPkgs.contains(desc.freeRTOS.envVar)) {
|
||||||
freeRTOSPkgs.insert(desc.freeRTOS.envVar,
|
freeRTOSPkgs
|
||||||
McuPackagePtr{
|
.insert(desc.freeRTOS.envVar,
|
||||||
createFreeRTOSSourcesPackage(desc.freeRTOS.envVar,
|
McuPackagePtr{
|
||||||
boardSdkDefaultPath,
|
Sdk::createFreeRTOSSourcesPackage(settingsHandler,
|
||||||
desc.freeRTOS.boardSdkSubDir)});
|
desc.freeRTOS.envVar,
|
||||||
|
boardSdkDefaultPath,
|
||||||
|
desc.freeRTOS.boardSdkSubDir)});
|
||||||
}
|
}
|
||||||
required3rdPartyPkgs.insert(freeRTOSPkgs.value(desc.freeRTOS.envVar));
|
required3rdPartyPkgs.insert(freeRTOSPkgs.value(desc.freeRTOS.envVar));
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "mcuabstracttargetfactory.h"
|
#include "mcuabstracttargetfactory.h"
|
||||||
|
#include "mcutargetdescription.h"
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
@@ -36,10 +38,8 @@ class McuTargetFactoryLegacy : public McuAbstractTargetFactory
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
McuTargetFactoryLegacy(const QHash<QString, McuToolChainPackagePtr> &tcPkgs,
|
McuTargetFactoryLegacy(const QHash<QString, McuToolChainPackagePtr> &tcPkgs,
|
||||||
const QHash<QString, McuPackagePtr> &vendorPkgs)
|
const QHash<QString, McuPackagePtr> &vendorPkgs,
|
||||||
: tcPkgs(tcPkgs)
|
const SettingsHandler::Ptr &);
|
||||||
, vendorPkgs(vendorPkgs)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QPair<Targets, Packages> createTargets(const McuTargetDescription &) override;
|
QPair<Targets, Packages> createTargets(const McuTargetDescription &) override;
|
||||||
AdditionalPackages getAdditionalPackages() const override;
|
AdditionalPackages getAdditionalPackages() const override;
|
||||||
@@ -47,6 +47,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
const QHash<QString, McuToolChainPackagePtr> tcPkgs;
|
const QHash<QString, McuToolChainPackagePtr> tcPkgs;
|
||||||
const QHash<QString, McuPackagePtr> vendorPkgs;
|
const QHash<QString, McuPackagePtr> vendorPkgs;
|
||||||
|
|
||||||
|
SettingsHandler::Ptr settingsHandler;
|
||||||
}; // struct McuTargetFactoryLegacy
|
}; // struct McuTargetFactoryLegacy
|
||||||
|
|
||||||
} // namespace McuSupport::Internal::Sdk
|
} // namespace McuSupport::Internal::Sdk
|
||||||
|
70
src/plugins/mcusupport/settingshandler.cpp
Normal file
70
src/plugins/mcusupport/settingshandler.cpp
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
|
#include "mcusupportconstants.h"
|
||||||
|
#include "mcusupportsdk.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
|
namespace McuSupport::Internal {
|
||||||
|
|
||||||
|
using Utils::FilePath;
|
||||||
|
|
||||||
|
static FilePath packagePathFromSettings(const QString &settingsKey,
|
||||||
|
QSettings &settings,
|
||||||
|
const FilePath &defaultPath)
|
||||||
|
{
|
||||||
|
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||||
|
+ QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + settingsKey;
|
||||||
|
const QString path = settings.value(key, defaultPath.toUserOutput()).toString();
|
||||||
|
return FilePath::fromUserInput(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
FilePath SettingsHandler::getPath(const QString &settingsKey,
|
||||||
|
QSettings::Scope scope,
|
||||||
|
const Utils::FilePath &defaultPath) const
|
||||||
|
{
|
||||||
|
return packagePathFromSettings(settingsKey, *Core::ICore::settings(scope), defaultPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SettingsHandler::write(const QString &settingsKey,
|
||||||
|
const Utils::FilePath &path,
|
||||||
|
const Utils::FilePath &defaultPath) const
|
||||||
|
{
|
||||||
|
const FilePath savedPath = packagePathFromSettings(settingsKey,
|
||||||
|
*Core::ICore::settings(QSettings::UserScope),
|
||||||
|
defaultPath);
|
||||||
|
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/'
|
||||||
|
+ QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + settingsKey;
|
||||||
|
Core::ICore::settings()->setValueWithDefault(key,
|
||||||
|
path.toUserOutput(),
|
||||||
|
defaultPath.toUserOutput());
|
||||||
|
|
||||||
|
return savedPath != path;
|
||||||
|
}
|
||||||
|
} // namespace McuSupport::Internal
|
50
src/plugins/mcusupport/settingshandler.h
Normal file
50
src/plugins/mcusupport/settingshandler.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
class FilePath;
|
||||||
|
} //namespace Utils
|
||||||
|
|
||||||
|
namespace McuSupport::Internal {
|
||||||
|
|
||||||
|
class SettingsHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Ptr = QSharedPointer<SettingsHandler>;
|
||||||
|
virtual ~SettingsHandler() = default;
|
||||||
|
virtual Utils::FilePath getPath(const QString &settingsKey,
|
||||||
|
QSettings::Scope scope,
|
||||||
|
const Utils::FilePath &m_defaultPath) const;
|
||||||
|
|
||||||
|
virtual bool write(const QString &settingsKey,
|
||||||
|
const Utils::FilePath &path,
|
||||||
|
const Utils::FilePath &defaultPath) const;
|
||||||
|
}; //class SettingsHandler
|
||||||
|
} // namespace McuSupport::Internal
|
@@ -6,7 +6,7 @@ if(TARGET Googletest)
|
|||||||
CONDITION WITH_TESTS
|
CONDITION WITH_TESTS
|
||||||
DEPENDS Googletest
|
DEPENDS Googletest
|
||||||
SOURCES
|
SOURCES
|
||||||
unittest.h unittest.cpp packagemock.h
|
unittest.h unittest.cpp packagemock.h settingshandlermock.h
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
message("Googletest target is missing")
|
message("Googletest target is missing")
|
||||||
|
48
src/plugins/mcusupport/test/settingshandlermock.h
Normal file
48
src/plugins/mcusupport/test/settingshandlermock.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "settingshandler.h"
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
|
namespace McuSupport::Internal {
|
||||||
|
|
||||||
|
class SettingsHandlerMock : public SettingsHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SettingsHandlerMock() = default;
|
||||||
|
~SettingsHandlerMock() override = default;
|
||||||
|
MOCK_METHOD(Utils::FilePath,
|
||||||
|
getPath,
|
||||||
|
(const QString &, QSettings::Scope, const Utils::FilePath &),
|
||||||
|
(const));
|
||||||
|
MOCK_METHOD(bool,
|
||||||
|
write,
|
||||||
|
(const QString &, const Utils::FilePath &, const Utils::FilePath &),
|
||||||
|
(const));
|
||||||
|
}; //class SettingsHandler
|
||||||
|
} // namespace McuSupport::Internal
|
@@ -143,6 +143,19 @@ void verifyGccToolchain(const McuToolChainPackage *gccPackage)
|
|||||||
QCOMPARE(gccPackage->toolchainType(), McuToolChainPackage::ToolChainType::GCC);
|
QCOMPARE(gccPackage->toolchainType(), McuToolChainPackage::ToolChainType::GCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
McuSupportTest::McuSupportTest()
|
||||||
|
: targetFactory{settingsMockPtr}
|
||||||
|
, toolchainPackagePtr{
|
||||||
|
new McuToolChainPackage{settingsMockPtr,
|
||||||
|
{}, // label
|
||||||
|
{}, // defaultPath
|
||||||
|
{}, // detectionPath
|
||||||
|
{}, // settingsKey
|
||||||
|
McuToolChainPackage::ToolChainType::Unsupported, // toolchain type
|
||||||
|
{}, // cmake var name
|
||||||
|
{}}} // env var name
|
||||||
|
{}
|
||||||
|
|
||||||
void McuSupportTest::initTestCase()
|
void McuSupportTest::initTestCase()
|
||||||
{
|
{
|
||||||
targetDescription = Sdk::McuTargetDescription{
|
targetDescription = Sdk::McuTargetDescription{
|
||||||
@@ -269,8 +282,8 @@ void McuSupportTest::test_addFreeRtosCmakeVarToKit()
|
|||||||
|
|
||||||
void McuSupportTest::test_legacy_createIarToolchain()
|
void McuSupportTest::test_legacy_createIarToolchain()
|
||||||
{
|
{
|
||||||
McuToolChainPackage *iarToolchainPackage = Sdk::createIarToolChainPackage();
|
McuToolChainPackagePtr iarToolchainPackage = Sdk::createIarToolChainPackage(settingsMockPtr);
|
||||||
verifyIarToolchain(iarToolchainPackage);
|
verifyIarToolchain(iarToolchainPackage.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportTest::test_createIarToolchain()
|
void McuSupportTest::test_createIarToolchain()
|
||||||
@@ -283,8 +296,8 @@ void McuSupportTest::test_createIarToolchain()
|
|||||||
|
|
||||||
void McuSupportTest::test_legacy_createDesktopGccToolchain()
|
void McuSupportTest::test_legacy_createDesktopGccToolchain()
|
||||||
{
|
{
|
||||||
McuToolChainPackage *gccPackage = Sdk::createGccToolChainPackage();
|
McuToolChainPackagePtr gccPackage = Sdk::createGccToolChainPackage(settingsMockPtr);
|
||||||
verifyGccToolchain(gccPackage);
|
verifyGccToolchain(gccPackage.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportTest::test_createDesktopGccToolchain()
|
void McuSupportTest::test_createDesktopGccToolchain()
|
||||||
@@ -384,7 +397,8 @@ void McuSupportTest::test_createPackagesWithCorrespondingSettings()
|
|||||||
{
|
{
|
||||||
QFETCH(QString, json);
|
QFETCH(QString, json);
|
||||||
const Sdk::McuTargetDescription description = Sdk::parseDescriptionJson(json.toLocal8Bit());
|
const Sdk::McuTargetDescription description = Sdk::parseDescriptionJson(json.toLocal8Bit());
|
||||||
const auto [targets, packages]{Sdk::targetsFromDescriptions({description}, runLegacy)};
|
const auto [targets,
|
||||||
|
packages]{Sdk::targetsFromDescriptions({description}, settingsMockPtr, runLegacy)};
|
||||||
Q_UNUSED(targets);
|
Q_UNUSED(targets);
|
||||||
|
|
||||||
QSet<QString> settings = Utils::transform<QSet<QString>>(packages, [](const auto &package) {
|
QSet<QString> settings = Utils::transform<QSet<QString>>(packages, [](const auto &package) {
|
||||||
@@ -414,7 +428,8 @@ void McuSupportTest::test_createFreeRtosPackageWithCorrectSetting()
|
|||||||
QFETCH(QString, freeRtosEnvVar);
|
QFETCH(QString, freeRtosEnvVar);
|
||||||
QFETCH(QString, expectedSettingsKey);
|
QFETCH(QString, expectedSettingsKey);
|
||||||
|
|
||||||
auto *package{Sdk::createFreeRTOSSourcesPackage(freeRtosEnvVar, FilePath{}, FilePath{})};
|
McuPackagePtr package{
|
||||||
|
Sdk::createFreeRTOSSourcesPackage(settingsMockPtr, freeRtosEnvVar, FilePath{}, FilePath{})};
|
||||||
QVERIFY(package != nullptr);
|
QVERIFY(package != nullptr);
|
||||||
|
|
||||||
QCOMPARE(package->settingsKey(), expectedSettingsKey);
|
QCOMPARE(package->settingsKey(), expectedSettingsKey);
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "mcutarget.h"
|
#include "mcutarget.h"
|
||||||
#include "mcutargetfactory.h"
|
#include "mcutargetfactory.h"
|
||||||
#include "packagemock.h"
|
#include "packagemock.h"
|
||||||
|
#include "settingshandlermock.h"
|
||||||
|
|
||||||
#include <projectexplorer/kit.h>
|
#include <projectexplorer/kit.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
@@ -47,6 +48,8 @@ namespace McuSupport::Internal::Test {
|
|||||||
class McuSupportTest : public QObject
|
class McuSupportTest : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
McuSupportTest();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
@@ -82,16 +85,12 @@ private:
|
|||||||
PackageMock *sdkPackage{new PackageMock};
|
PackageMock *sdkPackage{new PackageMock};
|
||||||
McuPackagePtr freeRtosPackagePtr{freeRtosPackage};
|
McuPackagePtr freeRtosPackagePtr{freeRtosPackage};
|
||||||
McuPackagePtr sdkPackagePtr{sdkPackage};
|
McuPackagePtr sdkPackagePtr{sdkPackage};
|
||||||
|
|
||||||
|
SettingsHandlerMock *settingsMock{new SettingsHandlerMock};
|
||||||
|
QSharedPointer<SettingsHandlerMock> settingsMockPtr{settingsMock};
|
||||||
Sdk::McuTargetFactory targetFactory;
|
Sdk::McuTargetFactory targetFactory;
|
||||||
Sdk::McuTargetDescription targetDescription;
|
Sdk::McuTargetDescription targetDescription;
|
||||||
McuToolChainPackagePtr toolchainPackagePtr{
|
McuToolChainPackagePtr toolchainPackagePtr;
|
||||||
new McuToolChainPackage{{}, // label
|
|
||||||
{}, // defaultPath
|
|
||||||
{}, // detectionPath
|
|
||||||
{}, // settingsKey
|
|
||||||
McuToolChainPackage::ToolChainType::Unsupported, // toolchain type
|
|
||||||
{}, // cmake var name
|
|
||||||
{}}}; // env var name
|
|
||||||
}; // class McuSupportTest
|
}; // class McuSupportTest
|
||||||
|
|
||||||
} // namespace McuSupport::Internal::Test
|
} // namespace McuSupport::Internal::Test
|
||||||
|
Reference in New Issue
Block a user