Introduced debugTool configuration object (as a replacement for the single debugToolName parameter)

This commit is contained in:
Nav
2021-05-30 16:48:34 +01:00
parent dd1920df19
commit a0b59e3bf7
3 changed files with 74 additions and 13 deletions

View File

@@ -1,7 +1,10 @@
{
"environments": {
"default": {
"debugToolName": "atmel-ice",
"debugTool": {
"name": "atmel-ice",
"releasePostDebugSession": true
},
"target": {
"name": "avr8",

View File

@@ -49,15 +49,16 @@ void InsightConfig::init(QJsonObject jsonObject) {
}
void EnvironmentConfig::init(std::string name, QJsonObject jsonObject) {
this->name = name;
this->debugToolName = jsonObject.find("debugToolName")->toString().toLower().toStdString();
// Extract target data
if (!jsonObject.contains("target")) {
// Environment has no target data - ignore
throw Exceptions::InvalidConfig("No target configuration provided");
if (!jsonObject.contains("debugTool")) {
throw Exceptions::InvalidConfig("No debug tool configuration provided.");
}
if (!jsonObject.contains("target")) {
throw Exceptions::InvalidConfig("No target configuration provided.");
}
this->name = name;
this->debugToolConfig.init(jsonObject.find("debugTool")->toObject());
this->targetConfig.init(jsonObject.find("target")->toObject());
if (jsonObject.contains("debugServer")) {
@@ -87,6 +88,20 @@ void TargetConfig::init(QJsonObject jsonObject) {
this->jsonObject = jsonObject;
}
void DebugToolConfig::init(QJsonObject jsonObject) {
if (!jsonObject.contains("name")) {
throw Exceptions::InvalidConfig("No debug tool name found.");
}
this->name = jsonObject.find("name")->toString().toLower().toStdString();
if (jsonObject.contains("releasePostDebugSession")) {
this->releasePostDebugSession = jsonObject.find("releasePostDebugSession").value().toBool();
}
this->jsonObject = jsonObject;
}
void DebugServerConfig::init(QJsonObject jsonObject) {
this->name = jsonObject.find("name")->toString().toLower().toStdString();
this->jsonObject = jsonObject;

View File

@@ -49,9 +49,50 @@ namespace Bloom
*/
void init(QJsonObject jsonObject);
/**
* The name of the selected target.
*/
std::string name;
std::string variantName;
/**
* The name of the selected target variant.
*
* Insight uses this to determine which variant to select on startup.
*/
std::optional<std::string> variantName;
QJsonObject jsonObject;
};
/**
* Configuration relating to a specific debug tool.
*
* As with the TargetConfig struct, please don't add any manufacture/model specific configuration here. This
* configuration should apply to all supported debug tools. Specific configuration can be extracted from the
* jsonObject member, as described in the TargetConfig comment above.
*/
struct DebugToolConfig
{
/**
* Obtains config parameters from JSON object.
*
* @param jsonObject
*/
void init(QJsonObject jsonObject);
/**
* The name of the selected debug tool.
*/
std::string name;
/**
* Determines if the TargetController will release the debug tool at the end of a debug session.
*
* If this is enabled, the TargetController will automatically suspend once the current debug session has
* ended. If not enabled, the TargetController will remain active and in control of the debug tool, preventing
* the user from running any other application that needs access to the debug tool.
*/
bool releasePostDebugSession = true;
QJsonObject jsonObject;
};
@@ -107,14 +148,16 @@ namespace Bloom
std::string name;
/**
* Name of the selected debug tool for this environment.
* Configuration for the environment's selected debug tool.
*
* Each environment can select only one debug tool.
*/
std::string debugToolName;
DebugToolConfig debugToolConfig;
/**
* Configuration for the environment's selected target.
*
* Each environment can consist of only one target.
* Each environment can select only one target.
*/
TargetConfig targetConfig;