forked from qt-creator/qt-creator
McuSupport: Use FilePath instead of QFile/QDir when parsing config JSONs
Change-Id: If150fcf73953a4bdeae8a0b50586d1dcf89b42a6 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -627,10 +627,9 @@ FilePath kitsPath(const FilePath &qtMcuSdkPath)
|
|||||||
return qtMcuSdkPath / "kits/";
|
return qtMcuSdkPath / "kits/";
|
||||||
}
|
}
|
||||||
|
|
||||||
static QFileInfoList targetDescriptionFiles(const FilePath &dir)
|
static FilePaths targetDescriptionFiles(const FilePath &dir)
|
||||||
{
|
{
|
||||||
const QDir kitsDir(kitsPath(dir).toString(), "*.json");
|
return kitsPath(dir).dirEntries(Utils::FileFilter({"*.json"}, QDir::Files));
|
||||||
return kitsDir.entryInfoList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionDetection parseVersionDetection(const QJsonObject &packageEntry)
|
VersionDetection parseVersionDetection(const QJsonObject &packageEntry)
|
||||||
@@ -773,18 +772,16 @@ McuSdkRepository targetsAndPackages(const FilePath &qtForMCUSdkPath,
|
|||||||
QList<McuTargetDescription> descriptions;
|
QList<McuTargetDescription> descriptions;
|
||||||
bool isLegacy{false};
|
bool isLegacy{false};
|
||||||
|
|
||||||
auto descriptionFiles = targetDescriptionFiles(qtForMCUSdkPath);
|
const FilePaths descriptionFiles = targetDescriptionFiles(qtForMCUSdkPath);
|
||||||
for (const QFileInfo &fileInfo : descriptionFiles) {
|
for (const FilePath &filePath : descriptionFiles) {
|
||||||
QFile file(fileInfo.absoluteFilePath());
|
if (!filePath.isReadableFile())
|
||||||
if (!file.open(QFile::ReadOnly))
|
|
||||||
continue;
|
continue;
|
||||||
const McuTargetDescription desc = parseDescriptionJson(file.readAll());
|
const McuTargetDescription desc = parseDescriptionJson(filePath.fileContents());
|
||||||
const auto pth = FilePath::fromUserInput(fileInfo.filePath());
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const int compatVersion = desc.compatVersion.toInt(&ok);
|
const int compatVersion = desc.compatVersion.toInt(&ok);
|
||||||
if (!desc.compatVersion.isEmpty() && ok && compatVersion > MAX_COMPATIBILITY_VERSION) {
|
if (!desc.compatVersion.isEmpty() && ok && compatVersion > MAX_COMPATIBILITY_VERSION) {
|
||||||
printMessage(McuTarget::tr("Skipped %1. Unsupported version \"%2\".")
|
printMessage(McuTarget::tr("Skipped %1. Unsupported version \"%2\".")
|
||||||
.arg(QDir::toNativeSeparators(pth.fileNameWithPathComponents(1)),
|
.arg(QDir::toNativeSeparators(filePath.fileNameWithPathComponents(1)),
|
||||||
desc.qulVersion),
|
desc.qulVersion),
|
||||||
false);
|
false);
|
||||||
continue;
|
continue;
|
||||||
@@ -801,7 +798,7 @@ McuSdkRepository targetsAndPackages(const FilePath &qtForMCUSdkPath,
|
|||||||
.arg(desc.qulVersion, legacyVersion)
|
.arg(desc.qulVersion, legacyVersion)
|
||||||
: McuTarget::tr("Unsupported version \"%1\".").arg(desc.qulVersion);
|
: McuTarget::tr("Unsupported version \"%1\".").arg(desc.qulVersion);
|
||||||
printMessage(McuTarget::tr("Skipped %1. %2 Qt for MCUs version >= %3 required.")
|
printMessage(McuTarget::tr("Skipped %1. %2 Qt for MCUs version >= %3 required.")
|
||||||
.arg(QDir::toNativeSeparators(pth.fileNameWithPathComponents(1)),
|
.arg(QDir::toNativeSeparators(filePath.fileNameWithPathComponents(1)),
|
||||||
qtcSupportText,
|
qtcSupportText,
|
||||||
McuSupportOptions::minimalQulVersion().toString()),
|
McuSupportOptions::minimalQulVersion().toString()),
|
||||||
false);
|
false);
|
||||||
|
|||||||
Reference in New Issue
Block a user