From a0b59e3bf7de128bed05a35cf167cc593e195f08 Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 30 May 2021 16:48:34 +0100 Subject: [PATCH] Introduced debugTool configuration object (as a replacement for the single debugToolName parameter) --- resources/bloom.template.json | 7 +++-- src/ApplicationConfig.cpp | 29 +++++++++++++++----- src/ApplicationConfig.hpp | 51 ++++++++++++++++++++++++++++++++--- 3 files changed, 74 insertions(+), 13 deletions(-) diff --git a/resources/bloom.template.json b/resources/bloom.template.json index fa0a4899..39295086 100644 --- a/resources/bloom.template.json +++ b/resources/bloom.template.json @@ -1,7 +1,10 @@ { "environments": { "default": { - "debugToolName": "atmel-ice", + "debugTool": { + "name": "atmel-ice", + "releasePostDebugSession": true + }, "target": { "name": "avr8", @@ -19,4 +22,4 @@ "insight": { "enabled": true } -} \ No newline at end of file +} diff --git a/src/ApplicationConfig.cpp b/src/ApplicationConfig.cpp index bc75e802..a8cf67d0 100644 --- a/src/ApplicationConfig.cpp +++ b/src/ApplicationConfig.cpp @@ -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; diff --git a/src/ApplicationConfig.hpp b/src/ApplicationConfig.hpp index 5389d8a1..d86199eb 100644 --- a/src/ApplicationConfig.hpp +++ b/src/ApplicationConfig.hpp @@ -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 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;