forked from qt-creator/qt-creator
McuSupport: Better management of older Qt for Mcu SDKs
Task-number: QTCREATORBUG-25337 Change-Id: Ib0b2f6c75a41a2a897c128455c7b6f761832f5d4 Reviewed-by: Dawid Śliwa <dawid.sliwa@qt.io> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
christiaan.janssen
parent
e3d95ac094
commit
65215b01e8
@@ -193,8 +193,13 @@ void McuSupportOptionsWidget::updateStatus()
|
|||||||
m_mcuTargetsInfoLabel->setVisible(valid && m_options.mcuTargets.isEmpty());
|
m_mcuTargetsInfoLabel->setVisible(valid && m_options.mcuTargets.isEmpty());
|
||||||
if (m_mcuTargetsInfoLabel->isVisible()) {
|
if (m_mcuTargetsInfoLabel->isVisible()) {
|
||||||
m_mcuTargetsInfoLabel->setType(Utils::InfoLabel::NotOk);
|
m_mcuTargetsInfoLabel->setType(Utils::InfoLabel::NotOk);
|
||||||
auto displayKitsPath = Sdk::kitsPath(Utils::FilePath::fromString(m_options.qtForMCUsSdkPackage->basePath())).toUserOutput();
|
const auto sdkPath = Utils::FilePath::fromString(m_options.qtForMCUsSdkPackage->basePath());
|
||||||
m_mcuTargetsInfoLabel->setText(tr("No valid kit descriptions found at %1.").arg(displayKitsPath));
|
QString deprecationMessage;
|
||||||
|
if (Sdk::checkDeprecatedSdkError(sdkPath, deprecationMessage))
|
||||||
|
m_mcuTargetsInfoLabel->setText(deprecationMessage);
|
||||||
|
else
|
||||||
|
m_mcuTargetsInfoLabel->setText(tr("No valid kit descriptions found at %1.")
|
||||||
|
.arg(Sdk::kitsPath(sdkPath).toUserOutput()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,8 +63,7 @@ static QString findInProgramFiles(const QString &folder)
|
|||||||
McuPackage *createQtForMCUsPackage()
|
McuPackage *createQtForMCUsPackage()
|
||||||
{
|
{
|
||||||
auto result = new McuPackage(
|
auto result = new McuPackage(
|
||||||
McuPackage::tr("Qt for MCUs %1+ SDK").arg(
|
McuPackage::tr("Qt for MCUs SDK"),
|
||||||
McuSupportOptions::minimalQulVersion().toString()),
|
|
||||||
QDir::homePath(),
|
QDir::homePath(),
|
||||||
Utils::HostOsInfo::withExecutableSuffix("bin/qmltocpp"),
|
Utils::HostOsInfo::withExecutableSuffix("bin/qmltocpp"),
|
||||||
Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK);
|
Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK);
|
||||||
@@ -497,7 +496,8 @@ protected:
|
|||||||
boardSdkPkgs.insert(desc.boardSdkEnvVar, boardSdkPkg);
|
boardSdkPkgs.insert(desc.boardSdkEnvVar, boardSdkPkg);
|
||||||
}
|
}
|
||||||
auto boardSdkPkg = boardSdkPkgs.value(desc.boardSdkEnvVar);
|
auto boardSdkPkg = boardSdkPkgs.value(desc.boardSdkEnvVar);
|
||||||
boardSdkPkg->setVersions(desc.boardSdkVersions);
|
if (QVersionNumber::fromString(desc.qulVersion) >= QVersionNumber({1,8}))
|
||||||
|
boardSdkPkg->setVersions(desc.boardSdkVersions);
|
||||||
boardSdkDefaultPath = boardSdkPkg->defaultPath();
|
boardSdkDefaultPath = boardSdkPkg->defaultPath();
|
||||||
required3rdPartyPkgs.append(boardSdkPkg);
|
required3rdPartyPkgs.append(boardSdkPkg);
|
||||||
}
|
}
|
||||||
@@ -609,6 +609,30 @@ static McuTargetDescription parseDescriptionJson(const QByteArray &data)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QHash<QString, QString> oldSdkQtcRequiredVersion = {
|
||||||
|
{{"1.0"}, {"4.11.x"}},
|
||||||
|
{{"1.1"}, {"4.12.0 or 4.12.1"}},
|
||||||
|
{{"1.2"}, {"4.12.2 or 4.12.3"}},
|
||||||
|
};
|
||||||
|
|
||||||
|
bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message)
|
||||||
|
{
|
||||||
|
const McuPackagePathVersionDetector versionDetector("(?<=\\bQtMCUs.)(\\d+\\.\\d+)");
|
||||||
|
const QString sdkDetectedVersion = versionDetector.parseVersion(qulDir.toString());
|
||||||
|
|
||||||
|
if (oldSdkQtcRequiredVersion.contains(sdkDetectedVersion)) {
|
||||||
|
message = McuTarget::tr("Qt for MCUs SDK version %1 detected, "
|
||||||
|
"only supported by QtCreator version %2. "
|
||||||
|
"SDK version %3 or greater required."
|
||||||
|
).arg(sdkDetectedVersion,
|
||||||
|
oldSdkQtcRequiredVersion.value(sdkDetectedVersion),
|
||||||
|
McuSupportOptions::minimalQulVersion().toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packages,
|
void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packages,
|
||||||
QVector<McuTarget *> *mcuTargets)
|
QVector<McuTarget *> *mcuTargets)
|
||||||
{
|
{
|
||||||
@@ -621,11 +645,16 @@ void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packa
|
|||||||
continue;
|
continue;
|
||||||
const McuTargetDescription desc = parseDescriptionJson(file.readAll());
|
const McuTargetDescription desc = parseDescriptionJson(file.readAll());
|
||||||
if (QVersionNumber::fromString(desc.qulVersion) < McuSupportOptions::minimalQulVersion()) {
|
if (QVersionNumber::fromString(desc.qulVersion) < McuSupportOptions::minimalQulVersion()) {
|
||||||
auto pth = Utils::FilePath::fromString(fileInfo.filePath());
|
const auto pth = Utils::FilePath::fromString(fileInfo.filePath());
|
||||||
printMessage(McuTarget::tr("Skipped %1 - Unsupported version \"%2\" (should be >= %3)")
|
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);
|
||||||
|
printMessage(McuTarget::tr("Skipped %1. %2 Qt for MCUs version >= %3 required.")
|
||||||
.arg(
|
.arg(
|
||||||
QDir::toNativeSeparators(pth.fileNameWithPathComponents(1)),
|
QDir::toNativeSeparators(pth.fileNameWithPathComponents(1)),
|
||||||
desc.qulVersion,
|
qtcSupportText,
|
||||||
McuSupportOptions::minimalQulVersion().toString()),
|
McuSupportOptions::minimalQulVersion().toString()),
|
||||||
false);
|
false);
|
||||||
continue;
|
continue;
|
||||||
@@ -633,10 +662,19 @@ void targetsAndPackages(const Utils::FilePath &dir, QVector<McuPackage *> *packa
|
|||||||
descriptions.append(desc);
|
descriptions.append(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No valid description means invalid SDK installation.
|
// No valid description means invalid or old SDK installation.
|
||||||
if (descriptions.empty() && kitsPath(dir).exists()) {
|
if (descriptions.empty()) {
|
||||||
printMessage(McuTarget::tr("No valid kit descriptions found at %1.").arg(kitsPath(dir).toUserOutput()), true);
|
if (kitsPath(dir).exists()) {
|
||||||
return;
|
printMessage(McuTarget::tr("No valid kit descriptions found at %1.")
|
||||||
|
.arg(kitsPath(dir).toUserOutput()), true);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
QString deprecationMessage;
|
||||||
|
if (checkDeprecatedSdkError(dir, deprecationMessage)) {
|
||||||
|
printMessage(deprecationMessage, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround for missing JSON file for Desktop target.
|
// Workaround for missing JSON file for Desktop target.
|
||||||
|
@@ -40,6 +40,8 @@ namespace Sdk {
|
|||||||
|
|
||||||
McuPackage *createQtForMCUsPackage();
|
McuPackage *createQtForMCUsPackage();
|
||||||
|
|
||||||
|
bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message);
|
||||||
|
|
||||||
void targetsAndPackages(const Utils::FilePath &qulDir,
|
void targetsAndPackages(const Utils::FilePath &qulDir,
|
||||||
QVector<McuPackage*> *packages, QVector<McuTarget*> *mcuTargets);
|
QVector<McuPackage*> *packages, QVector<McuTarget*> *mcuTargets);
|
||||||
|
|
||||||
|
@@ -33,6 +33,15 @@
|
|||||||
namespace McuSupport {
|
namespace McuSupport {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
QString matchRegExp(const QString &text, const QString ®Exp)
|
||||||
|
{
|
||||||
|
const QRegularExpression regularExpression(regExp);
|
||||||
|
const QRegularExpressionMatch match = regularExpression.match(text);
|
||||||
|
if (match.hasMatch())
|
||||||
|
return match.captured(regularExpression.captureCount());
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
McuPackageVersionDetector::McuPackageVersionDetector()
|
McuPackageVersionDetector::McuPackageVersionDetector()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -57,7 +66,6 @@ QString McuPackageExecutableVersionDetector::parseVersion(const QString &package
|
|||||||
if (!Utils::FilePath::fromString(binaryPath).exists())
|
if (!Utils::FilePath::fromString(binaryPath).exists())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
const QRegularExpression regExp(m_detectionRegExp);
|
|
||||||
|
|
||||||
const int execTimeout = 3000; // usually runs below 1s, but we want to be on the safe side
|
const int execTimeout = 3000; // usually runs below 1s, but we want to be on the safe side
|
||||||
QProcess binaryProcess;
|
QProcess binaryProcess;
|
||||||
@@ -69,12 +77,10 @@ QString McuPackageExecutableVersionDetector::parseVersion(const QString &package
|
|||||||
const QString processOutput = QString::fromUtf8(
|
const QString processOutput = QString::fromUtf8(
|
||||||
binaryProcess.readAllStandardOutput().append(
|
binaryProcess.readAllStandardOutput().append(
|
||||||
binaryProcess.readAllStandardError()));
|
binaryProcess.readAllStandardError()));
|
||||||
const QRegularExpressionMatch match = regExp.match(processOutput);
|
return matchRegExp(processOutput, m_detectionRegExp);
|
||||||
if (match.hasMatch())
|
|
||||||
return match.captured(regExp.captureCount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail gracefully: return empty string if execution failed or regexp did not match
|
// Fail gracefully: return empty string if execution failed
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +97,6 @@ McuPackageXmlVersionDetector::McuPackageXmlVersionDetector(const QString &filePa
|
|||||||
|
|
||||||
QString McuPackageXmlVersionDetector::parseVersion(const QString &packagePath) const
|
QString McuPackageXmlVersionDetector::parseVersion(const QString &packagePath) const
|
||||||
{
|
{
|
||||||
const QRegularExpression regExp(m_versionRegExp);
|
|
||||||
const auto files = QDir(packagePath, m_filePattern).entryInfoList();
|
const auto files = QDir(packagePath, m_filePattern).entryInfoList();
|
||||||
for (const auto &xmlFile: files) {
|
for (const auto &xmlFile: files) {
|
||||||
QFile sdkXmlFile = QFile(xmlFile.absoluteFilePath());
|
QFile sdkXmlFile = QFile(xmlFile.absoluteFilePath());
|
||||||
@@ -100,8 +105,8 @@ QString McuPackageXmlVersionDetector::parseVersion(const QString &packagePath) c
|
|||||||
while (xmlReader.readNext()) {
|
while (xmlReader.readNext()) {
|
||||||
if (xmlReader.name() == m_versionElement) {
|
if (xmlReader.name() == m_versionElement) {
|
||||||
const QString versionString = xmlReader.attributes().value(m_versionAttribute).toString();
|
const QString versionString = xmlReader.attributes().value(m_versionAttribute).toString();
|
||||||
const QRegularExpressionMatch match = regExp.match(versionString);
|
const QString matched = matchRegExp(versionString, m_versionRegExp);
|
||||||
return match.hasMatch() ? match.captured(regExp.captureCount()) : versionString;
|
return !matched.isEmpty() ? matched : versionString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,13 +128,24 @@ QString McuPackageDirectoryVersionDetector::parseVersion(const QString &packageP
|
|||||||
const auto files = QDir(packagePath, m_filePattern)
|
const auto files = QDir(packagePath, m_filePattern)
|
||||||
.entryInfoList(m_isFile ? QDir::Filter::Files : QDir::Filter::Dirs);
|
.entryInfoList(m_isFile ? QDir::Filter::Files : QDir::Filter::Dirs);
|
||||||
for (const auto &entry: files) {
|
for (const auto &entry: files) {
|
||||||
const QRegularExpression regExp(m_versionRegExp);
|
const QString matched = matchRegExp(entry.fileName(), m_versionRegExp);
|
||||||
const QRegularExpressionMatch match = regExp.match(entry.fileName());
|
if (!matched.isEmpty())
|
||||||
if (match.hasMatch())
|
return matched;
|
||||||
return match.captured(regExp.captureCount());
|
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
McuPackagePathVersionDetector::McuPackagePathVersionDetector(const QString &versionRegExp)
|
||||||
|
: m_versionRegExp(versionRegExp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString McuPackagePathVersionDetector::parseVersion(const QString &packagePath) const
|
||||||
|
{
|
||||||
|
if (!Utils::FilePath::fromString(packagePath).exists())
|
||||||
|
return QString();
|
||||||
|
return matchRegExp(packagePath, m_versionRegExp);
|
||||||
|
}
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
} // McuSupport
|
} // McuSupport
|
||||||
|
@@ -78,6 +78,15 @@ private:
|
|||||||
const bool m_isFile;
|
const bool m_isFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get version from the path of the package itself
|
||||||
|
class McuPackagePathVersionDetector : public McuPackageVersionDetector {
|
||||||
|
public:
|
||||||
|
McuPackagePathVersionDetector(const QString &versionRegExp);
|
||||||
|
QString parseVersion(const QString &packagePath) const;
|
||||||
|
private:
|
||||||
|
const QString m_versionRegExp;
|
||||||
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
} // McuSupport
|
} // McuSupport
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user