McuSupport: Store the source location of the JSON file

This allows to mention the file name the configuration was created from in
error messages.

Change-Id: Id8e3d4a754cf5c1f0a12c6b21af1158713c68690
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Rainer Keller
2022-10-14 09:25:29 +02:00
committed by Rainer Keller
parent d42214e556
commit 6326ccfe30
4 changed files with 9 additions and 9 deletions

View File

@@ -22,7 +22,6 @@
#include <projectexplorer/toolchainmanager.h>
#include <utils/algorithm.h>
#include <utils/environment.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <QDir>
@@ -658,7 +657,7 @@ static QList<PackageDescription> parsePackages(const QJsonArray &cmakeEntries)
return result;
}
McuTargetDescription parseDescriptionJson(const QByteArray &data)
McuTargetDescription parseDescriptionJson(const QByteArray &data, const Utils::FilePath &sourceFile)
{
const QJsonDocument document = QJsonDocument::fromJson(data);
const QJsonObject target = document.object();
@@ -692,7 +691,8 @@ McuTargetDescription parseDescriptionJson(const QByteArray &data)
});
const QString platformName = platform.value("platformName").toString();
return {qulVersion,
return {sourceFile,
qulVersion,
compatVersion,
{platform.value("id").toString(),
platformName,
@@ -754,7 +754,8 @@ McuSdkRepository targetsAndPackages(const McuPackagePtr &qtForMCUsPackage,
if (!filePath.isReadableFile())
continue;
const McuTargetDescription desc = parseDescriptionJson(
filePath.fileContents().value_or(QByteArray()));
filePath.fileContents().value_or(QByteArray()),
filePath);
bool ok = false;
const int compatVersion = desc.compatVersion.toInt(&ok);
if (!desc.compatVersion.isEmpty() && ok && compatVersion > MAX_COMPATIBILITY_VERSION) {

View File

@@ -5,10 +5,7 @@
#include "mcusupport_global.h"
#include "settingshandler.h"
namespace Utils {
class FilePath;
} // namespace Utils
#include <utils/fileutils.h>
namespace McuSupport::Internal {
@@ -28,7 +25,7 @@ bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message);
McuSdkRepository targetsAndPackages(const McuPackagePtr &qtForMCUsPackage,
const SettingsHandler::Ptr &);
McuTargetDescription parseDescriptionJson(const QByteArray &);
McuTargetDescription parseDescriptionJson(const QByteArray &, const Utils::FilePath &sourceFile = Utils::FilePath());
McuSdkRepository targetsFromDescriptions(const QList<McuTargetDescription> &,
const SettingsHandler::Ptr &,
const McuPackagePtr &qtForMCUsPackage,

View File

@@ -39,6 +39,7 @@ struct McuTargetDescription
{
enum class TargetType { MCU, Desktop };
Utils::FilePath sourceFile;
QString qulVersion;
QString compatVersion;
struct Platform

View File

@@ -352,6 +352,7 @@ McuSupportTest::McuSupportTest()
, compilerDescription{armGccLabel, armGccEnvVar, TOOLCHAIN_DIR_CMAKE_VARIABLE, armGccLabel, armGccDirectorySetting, {}, {}, {}, {}, false}
, toochainFileDescription{armGccLabel, armGccEnvVar, TOOLCHAIN_FILE_CMAKE_VARIABLE, armGccLabel, armGccDirectorySetting, {}, {}, {}, {}, false}
, targetDescription {
"autotest-sourceFile",
"2.0.1",
"2",
platformDescription,