forked from qt-creator/qt-creator
McuSupport: update dependency paths of kits if changed
Task-number: QTCREATORBUG-25488 Change-Id: I529b6243b799e35db5e9804087e4ed20224cb024 Reviewed-by: Dawid Śliwa <dawid.sliwa@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
christiaan.janssen
parent
555dbac851
commit
af24cad00f
@@ -226,11 +226,14 @@ void McuPackage::writeGeneralSettings() const
|
|||||||
settings->setValue(key, m_automaticKitCreation);
|
settings->setValue(key, m_automaticKitCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuPackage::writeToSettings() const
|
bool McuPackage::writeToSettings() const
|
||||||
{
|
{
|
||||||
|
const QString savedPath = packagePathFromSettings(m_settingsKey, QSettings::UserScope, m_defaultPath);
|
||||||
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
||||||
QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey;
|
QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey;
|
||||||
Core::ICore::settings()->setValueWithDefault(key, m_path, m_defaultPath);
|
Core::ICore::settings()->setValueWithDefault(key, m_path, m_defaultPath);
|
||||||
|
|
||||||
|
return savedPath != m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuPackage::setRelativePathModifier(const QString &path)
|
void McuPackage::setRelativePathModifier(const QString &path)
|
||||||
@@ -790,6 +793,27 @@ static void setKitDependencies(Kit *k, const McuTarget *mcuTarget,
|
|||||||
k->setIrrelevantAspects(irrelevant);
|
k->setIrrelevantAspects(irrelevant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void updateKitEnvironment(Kit *k, const McuTarget *mcuTarget)
|
||||||
|
{
|
||||||
|
EnvironmentItems changes = EnvironmentKitAspect::environmentChanges(k);
|
||||||
|
for (auto package : mcuTarget->packages()) {
|
||||||
|
const QString varName = package->environmentVariableName();
|
||||||
|
if (!varName.isEmpty() && package->validStatus()) {
|
||||||
|
const int index = Utils::indexOf(changes, [varName](const EnvironmentItem &item) {
|
||||||
|
return item.name == varName;
|
||||||
|
});
|
||||||
|
const EnvironmentItem item = {package->environmentVariableName(),
|
||||||
|
QDir::toNativeSeparators(package->path())};
|
||||||
|
if (index != -1)
|
||||||
|
changes.replace(index, item);
|
||||||
|
else
|
||||||
|
changes.append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EnvironmentKitAspect::setEnvironmentChanges(k, changes);
|
||||||
|
}
|
||||||
|
|
||||||
static void setKitCMakeOptions(Kit *k, const McuTarget* mcuTarget, const QString &qulDir)
|
static void setKitCMakeOptions(Kit *k, const McuTarget* mcuTarget, const QString &qulDir)
|
||||||
{
|
{
|
||||||
using namespace CMakeProjectManager;
|
using namespace CMakeProjectManager;
|
||||||
@@ -887,6 +911,19 @@ QList<Kit *> McuSupportOptions::existingKits(const McuTarget *mcuTarget, bool au
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Kit *> McuSupportOptions::kitsWithMismatchedDependencies(const McuTarget *mcuTarget)
|
||||||
|
{
|
||||||
|
return Utils::filtered(existingKits(mcuTarget, false), [mcuTarget](Kit *kit) {
|
||||||
|
const auto environment = Utils::NameValueDictionary(
|
||||||
|
Utils::NameValueItem::toStringList(
|
||||||
|
EnvironmentKitAspect::environmentChanges(kit)));
|
||||||
|
return Utils::anyOf(mcuTarget->packages(), [&environment](const McuPackage *package) {
|
||||||
|
return !package->environmentVariableName().isEmpty() &&
|
||||||
|
environment.value(package->environmentVariableName()) != QDir::toNativeSeparators(package->path());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
QList<Kit *> McuSupportOptions::outdatedKits()
|
QList<Kit *> McuSupportOptions::outdatedKits()
|
||||||
{
|
{
|
||||||
return Utils::filtered(KitManager::kits(), [](Kit *kit) {
|
return Utils::filtered(KitManager::kits(), [](Kit *kit) {
|
||||||
@@ -1117,6 +1154,27 @@ void McuSupportOptions::upgradeKits(UpgradeOption upgradeOption)
|
|||||||
delete qtForMCUsPackage;
|
delete qtForMCUsPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void McuSupportOptions::fixKitsDependencies()
|
||||||
|
{
|
||||||
|
auto qtForMCUsPackage = Sdk::createQtForMCUsPackage();
|
||||||
|
|
||||||
|
auto dir = FilePath::fromUserInput(qtForMCUsPackage->path());
|
||||||
|
QVector<McuPackage*> packages;
|
||||||
|
QVector<McuTarget*> mcuTargets;
|
||||||
|
Sdk::targetsAndPackages(dir, &packages, &mcuTargets);
|
||||||
|
for (auto target: qAsConst(mcuTargets)) {
|
||||||
|
if (target->isValid()) {
|
||||||
|
for (auto kit : kitsWithMismatchedDependencies(target)) {
|
||||||
|
updateKitEnvironment(kit, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qDeleteAll(packages);
|
||||||
|
qDeleteAll(mcuTargets);
|
||||||
|
delete qtForMCUsPackage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fix/update existing kits if needed
|
* @brief Fix/update existing kits if needed
|
||||||
*/
|
*/
|
||||||
|
@@ -86,7 +86,7 @@ public:
|
|||||||
void setAddToPath(bool addToPath);
|
void setAddToPath(bool addToPath);
|
||||||
bool addToPath() const;
|
bool addToPath() const;
|
||||||
void writeGeneralSettings() const;
|
void writeGeneralSettings() const;
|
||||||
void writeToSettings() const;
|
bool writeToSettings() const;
|
||||||
void setRelativePathModifier(const QString &path);
|
void setRelativePathModifier(const QString &path);
|
||||||
void setVersions(const QVector<QString> &versions);
|
void setVersions(const QVector<QString> &versions);
|
||||||
|
|
||||||
@@ -223,12 +223,14 @@ public:
|
|||||||
static QString kitName(const McuTarget* mcuTarget);
|
static QString kitName(const McuTarget* mcuTarget);
|
||||||
|
|
||||||
static QList<ProjectExplorer::Kit *> existingKits(const McuTarget *mcuTarget, bool autoDetectedOnly = true);
|
static QList<ProjectExplorer::Kit *> existingKits(const McuTarget *mcuTarget, bool autoDetectedOnly = true);
|
||||||
|
static QList<ProjectExplorer::Kit *> kitsWithMismatchedDependencies(const McuTarget *mcuTarget);
|
||||||
static QList<ProjectExplorer::Kit *> outdatedKits();
|
static QList<ProjectExplorer::Kit *> outdatedKits();
|
||||||
static void removeOutdatedKits();
|
static void removeOutdatedKits();
|
||||||
static ProjectExplorer::Kit *newKit(const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdk);
|
static ProjectExplorer::Kit *newKit(const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdk);
|
||||||
static void createAutomaticKits();
|
static void createAutomaticKits();
|
||||||
static UpgradeOption askForKitUpgrades();
|
static UpgradeOption askForKitUpgrades();
|
||||||
static void upgradeKits(UpgradeOption upgradeOption);
|
static void upgradeKits(UpgradeOption upgradeOption);
|
||||||
|
static void fixKitsDependencies();
|
||||||
void checkUpgradeableKits();
|
void checkUpgradeableKits();
|
||||||
static void fixExistingKits();
|
static void fixExistingKits();
|
||||||
void populatePackagesAndTargets();
|
void populatePackagesAndTargets();
|
||||||
|
@@ -278,12 +278,17 @@ void McuSupportOptionsWidget::showEvent(QShowEvent *event)
|
|||||||
|
|
||||||
void McuSupportOptionsWidget::apply()
|
void McuSupportOptionsWidget::apply()
|
||||||
{
|
{
|
||||||
m_options.qtForMCUsSdkPackage->writeGeneralSettings();
|
bool pathsChanged = false;
|
||||||
m_options.qtForMCUsSdkPackage->writeToSettings();
|
|
||||||
for (auto package : qAsConst(m_options.packages))
|
|
||||||
package->writeToSettings();
|
|
||||||
|
|
||||||
|
m_options.qtForMCUsSdkPackage->writeGeneralSettings();
|
||||||
|
pathsChanged |= m_options.qtForMCUsSdkPackage->writeToSettings();
|
||||||
|
for (auto package : qAsConst(m_options.packages))
|
||||||
|
pathsChanged |= package->writeToSettings();
|
||||||
|
|
||||||
|
if (pathsChanged) {
|
||||||
m_options.checkUpgradeableKits();
|
m_options.checkUpgradeableKits();
|
||||||
|
m_options.fixKitsDependencies();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuSupportOptionsWidget::populateMcuTargetsComboBox()
|
void McuSupportOptionsWidget::populateMcuTargetsComboBox()
|
||||||
|
Reference in New Issue
Block a user