CMakePM: Presets: Add ability to register a Debugger via "vendor" field

This adds "Debugger" as a dependency for the CMake Project Manager.

The "vendor" field of a configurePreset can look like:

```
      "vendor": {
        "qt.io/QtCreator/1.0": {
          "debugger": "C:/Qt/Tools/mingw1120_64/bin/gdb.exe"
          }
        }
      }
```

or with all the DebugItem details as:

```
      "vendor": {
        "qt.io/QtCreator/1.0": {
          "debugger": {
            "DisplayName": "GNU gdb 11.2.0 for MinGW 11.2.0 64-bit",
            "Abis": ["x86-windows-msys-pe-64bit"],
            "Binary": "C:/Qt/Tools/mingw1120_64/bin/gdb.exe",
            "EngineType": 1,
            "Version": "11.2.0"
          }
        }
      }
```

Fixes: QTCREATORBUG-30836
Change-Id: Ia89ff29ce5fad713ee8617477ec798bd86f2f811
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-05-29 16:37:14 +02:00
parent 73e8dfba44
commit 968051eb72
6 changed files with 90 additions and 31 deletions

View File

@@ -148,6 +148,30 @@ std::optional<PresetsDetails::Condition> parseCondition(const QJsonValue &jsonVa
return condition;
}
bool parseVendor(const QJsonValue &jsonValue, std::optional<QVariantMap> &vendorSettings)
{
// The whole section is optional
if (jsonValue.isUndefined())
return true;
if (!jsonValue.isObject())
return false;
const QJsonObject object = jsonValue.toObject();
const QJsonValue qtIo = object.value("qt.io/QtCreator/1.0");
if (qtIo.isUndefined())
return true;
if (!qtIo.isObject())
return false;
const QJsonObject qtIoObject = qtIo.toObject();
vendorSettings = QVariantMap();
for (const QString &settingKey : qtIoObject.keys()) {
const QJsonValue settingValue = qtIoObject.value(settingKey);
vendorSettings->insert(settingKey, settingValue.toVariant());
}
return true;
}
bool parseConfigurePresets(const QJsonValue &jsonValue,
QList<PresetsDetails::ConfigurePreset> &configurePresets,
const Utils::FilePath &fileDir)
@@ -188,6 +212,9 @@ bool parseConfigurePresets(const QJsonValue &jsonValue,
if (object.contains("condition"))
preset.condition = parseCondition(object.value("condition"));
if (object.contains("vendor"))
parseVendor(object.value("vendor"), preset.vendor);
if (object.contains("displayName"))
preset.displayName = object.value("displayName").toString();
if (object.contains("description"))
@@ -378,6 +405,9 @@ bool parseBuildPresets(const QJsonValue &jsonValue,
if (object.contains("condition"))
preset.condition = parseCondition(object.value("condition"));
if (object.contains("vendor"))
parseVendor(object.value("vendor"), preset.vendor);
if (object.contains("displayName"))
preset.displayName = object.value("displayName").toString();
if (object.contains("description"))
@@ -435,30 +465,6 @@ bool parseBuildPresets(const QJsonValue &jsonValue,
return true;
}
bool parseVendor(const QJsonValue &jsonValue, std::optional<QVariantMap> &vendorSettings)
{
// The whole section is optional
if (jsonValue.isUndefined())
return true;
if (!jsonValue.isObject())
return false;
const QJsonObject object = jsonValue.toObject();
const QJsonValue qtIo = object.value("qt.io/QtCreator/1.0");
if (qtIo.isUndefined())
return true;
if (!qtIo.isObject())
return false;
const QJsonObject qtIoObject = qtIo.toObject();
vendorSettings = QVariantMap();
for (const QString &settingKey : qtIoObject.keys()) {
const QJsonValue settingValue = qtIoObject.value(settingKey);
vendorSettings->insert(settingKey, settingValue.toVariant());
}
return true;
}
const PresetsData &PresetsParser::presetsData() const
{
return m_presetsData;
@@ -535,10 +541,9 @@ bool PresetsParser::parse(const Utils::FilePath &jsonFile, QString &errorMessage
return true;
}
static QHash<QString, QString> merge(const QHash<QString, QString> &first,
const QHash<QString, QString> &second)
static QVariantMap merge(const QVariantMap &first, const QVariantMap &second)
{
QHash<QString, QString> result = first;
QVariantMap result = first;
for (auto it = second.constKeyValueBegin(); it != second.constKeyValueEnd(); ++it) {
result[it->first] = it->second;
}