2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
2022-07-23 15:37:22 +01:00
|
|
|
#include <yaml-cpp/yaml.h>
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
namespace Bloom
|
|
|
|
|
{
|
|
|
|
|
/*
|
2022-07-23 15:37:22 +01:00
|
|
|
* Currently, all user configuration is stored in a YAML file (bloom.yaml), in the user's project directory.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2022-07-23 15:37:22 +01:00
|
|
|
* The YAML config file should define parameters for specific debug environments. Because a config file can define
|
|
|
|
|
* multiple debug environments, each environment must be assigned a unique name that can be used to identify the
|
|
|
|
|
* environment. This is why the 'environments' parameter is a YAML map, with the key being the environment name.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2022-08-27 17:56:55 +01:00
|
|
|
* On application start up, we extract the config from this YAML file and generate a ProjectConfig object.
|
2022-05-14 22:43:35 +01:00
|
|
|
* See Application::loadProjectConfiguration() for more on this.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* Some config parameters are specific to certain entities within Bloom, but have no significance across the
|
2022-05-14 22:43:35 +01:00
|
|
|
* rest of the application. For example, AVR8 targets require the 'physicalInterface' and other AVR8 specific
|
|
|
|
|
* parameters. These are used to configure AVR8 targets, but have no significance across the rest of the
|
2022-07-23 15:37:22 +01:00
|
|
|
* application. This is why some configuration structs (like TargetConfig) include a YAML::Node member.
|
|
|
|
|
* When instances of these structs are passed to the appropriate entities, any configuration required by those
|
|
|
|
|
* entities is extracted from the YAML::Node member. This means we don't have to worry about any entity specific
|
|
|
|
|
* config parameters at the application level. We can simply extract what we need at an entity level and the rest
|
|
|
|
|
* of the application can remain oblivious. For an example on extracting entity specific config, see
|
|
|
|
|
* Avr8TargetConfig::Avr8TargetConfig() and Avr8::preActivationConfigure().
|
2021-04-23 22:38:13 +01:00
|
|
|
*
|
|
|
|
|
* For more on project configuration, see Bloom documentation at https://bloom.oscillate.io/docs/configuration
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
|
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
/*
|
|
|
|
|
* Initially, we used the JSON format for project configuration files, but this was changed in version 0.11.0.
|
|
|
|
|
* See https://github.com/navnavnav/Bloom/issues/50 for more.
|
2022-07-24 12:17:44 +01:00
|
|
|
*
|
|
|
|
|
* Because JSON is a subset of YAML, we can (and do) fallback to bloom.json in the absence of bloom.yaml.
|
|
|
|
|
* See Application::loadProjectConfiguration() for more.
|
2022-07-23 15:37:22 +01:00
|
|
|
*/
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
|
|
|
|
* Configuration relating to a specific target.
|
|
|
|
|
*
|
|
|
|
|
* Please don't define any target specific configuration here, unless it applies to *all* targets across
|
2022-07-23 15:37:22 +01:00
|
|
|
* the application. If a target requires specific config, it should be extracted from the YAML::Node (targetNode)
|
|
|
|
|
* member. This should be done in Target::preActivationConfigure(), to which an instance of TargetConfig is passed.
|
2021-04-04 21:04:12 +01:00
|
|
|
* See the comment above on entity specific config for more on this.
|
|
|
|
|
*/
|
|
|
|
|
struct TargetConfig
|
|
|
|
|
{
|
2021-05-30 16:48:34 +01:00
|
|
|
/**
|
|
|
|
|
* The name of the selected target.
|
|
|
|
|
*/
|
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The name of the selected target variant.
|
|
|
|
|
*
|
2022-08-27 17:56:55 +01:00
|
|
|
* Insight uses this to determine which variant to select on start up.
|
2021-05-30 16:48:34 +01:00
|
|
|
*/
|
|
|
|
|
std::optional<std::string> variantName;
|
|
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
/**
|
|
|
|
|
* For extracting any target specific configuration. See Avr8TargetConfig::Avr8TargetConfig() and
|
|
|
|
|
* Avr8::preActivationConfigure() for an example of this.
|
|
|
|
|
*/
|
|
|
|
|
YAML::Node targetNode;
|
2021-12-31 19:44:20 +00:00
|
|
|
|
|
|
|
|
TargetConfig() = default;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-07-23 15:37:22 +01:00
|
|
|
* Obtains config parameters from YAML node.
|
2021-12-31 19:44:20 +00:00
|
|
|
*
|
2022-07-23 15:37:22 +01:00
|
|
|
* @param targetNode
|
2021-12-31 19:44:20 +00:00
|
|
|
*/
|
2022-07-23 15:37:22 +01:00
|
|
|
explicit TargetConfig(const YAML::Node& targetNode);
|
2021-05-30 16:48:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
2022-07-23 15:37:22 +01:00
|
|
|
* YAML::Node (debugToolNode) member, as described in the TargetConfig comment above.
|
2021-05-30 16:48:34 +01:00
|
|
|
*/
|
|
|
|
|
struct DebugToolConfig
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The name of the selected debug tool.
|
|
|
|
|
*/
|
2021-04-04 21:04:12 +01:00
|
|
|
std::string name;
|
2021-04-08 20:42:23 +01:00
|
|
|
|
2021-05-30 16:48:34 +01:00
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2022-09-14 19:53:50 +01:00
|
|
|
bool releasePostDebugSession = false;
|
2021-04-08 20:42:23 +01:00
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
/**
|
|
|
|
|
* For extracting any debug tool specific configuration.
|
|
|
|
|
*/
|
|
|
|
|
YAML::Node debugToolNode;
|
2021-12-31 19:44:20 +00:00
|
|
|
|
|
|
|
|
DebugToolConfig() = default;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-07-23 15:37:22 +01:00
|
|
|
* Obtains config parameters from YAML node.
|
2021-12-31 19:44:20 +00:00
|
|
|
*
|
2022-07-23 15:37:22 +01:00
|
|
|
* @param debugToolNode
|
2021-12-31 19:44:20 +00:00
|
|
|
*/
|
2022-07-23 15:37:22 +01:00
|
|
|
explicit DebugToolConfig(const YAML::Node& debugToolNode);
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Debug server configuration.
|
|
|
|
|
*/
|
|
|
|
|
struct DebugServerConfig
|
|
|
|
|
{
|
2022-07-23 15:37:22 +01:00
|
|
|
/**
|
|
|
|
|
* The name of the selected debug server.
|
|
|
|
|
*/
|
2021-12-31 19:44:20 +00:00
|
|
|
std::string name;
|
2022-07-23 15:37:22 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* For extracting any debug server specific configuration. See GdbDebugServerConfig::GdbDebugServerConfig() and
|
|
|
|
|
* GdbRspDebugServer::GdbRspDebugServer() for an example of this.
|
|
|
|
|
*/
|
|
|
|
|
YAML::Node debugServerNode;
|
2021-12-31 19:44:20 +00:00
|
|
|
|
|
|
|
|
DebugServerConfig() = default;
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
2022-07-23 15:37:22 +01:00
|
|
|
* Obtains config parameters from YAML node.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2022-07-23 15:37:22 +01:00
|
|
|
* @param debugServerNode
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
2022-07-23 15:37:22 +01:00
|
|
|
explicit DebugServerConfig(const YAML::Node& debugServerNode);
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct InsightConfig
|
|
|
|
|
{
|
2021-12-31 19:44:20 +00:00
|
|
|
bool insightEnabled = true;
|
|
|
|
|
|
|
|
|
|
InsightConfig() = default;
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
2022-07-23 15:37:22 +01:00
|
|
|
* Obtains config parameters from YAML node.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2022-07-23 15:37:22 +01:00
|
|
|
* @param insightNode
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
2022-07-23 15:37:22 +01:00
|
|
|
explicit InsightConfig(const YAML::Node& insightNode);
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configuration relating to a specific user defined environment.
|
|
|
|
|
*
|
|
|
|
|
* An instance of this type will be instantiated for each environment defined in the user's config file.
|
2022-01-02 20:45:14 +00:00
|
|
|
* See Application::loadProjectConfiguration() implementation for more on this.
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
|
|
|
|
struct EnvironmentConfig
|
|
|
|
|
{
|
|
|
|
|
/**
|
2022-07-23 15:37:22 +01:00
|
|
|
* The environment name is stored as the key to the YAML map containing the environment parameters.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* Environment names must be unique.
|
|
|
|
|
*/
|
|
|
|
|
std::string name;
|
|
|
|
|
|
2022-02-09 17:44:58 +00:00
|
|
|
/**
|
|
|
|
|
* Flag to determine whether Bloom should shutdown at the end of a debug session.
|
|
|
|
|
*/
|
|
|
|
|
bool shutdownPostDebugSession = false;
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
2021-05-30 16:48:34 +01:00
|
|
|
* Configuration for the environment's selected debug tool.
|
|
|
|
|
*
|
|
|
|
|
* Each environment can select only one debug tool.
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
2021-05-30 16:48:34 +01:00
|
|
|
DebugToolConfig debugToolConfig;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configuration for the environment's selected target.
|
|
|
|
|
*
|
2021-05-30 16:48:34 +01:00
|
|
|
* Each environment can select only one target.
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
|
|
|
|
TargetConfig targetConfig;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configuration for the environment's debug server. Users can define this at the application level if
|
|
|
|
|
* they desire.
|
|
|
|
|
*/
|
|
|
|
|
std::optional<DebugServerConfig> debugServerConfig;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Insight configuration can be defined at an environment level as well as at an application level.
|
|
|
|
|
*/
|
|
|
|
|
std::optional<InsightConfig> insightConfig;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-07-23 15:37:22 +01:00
|
|
|
* Obtains config parameters from YAML node.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2022-07-23 15:37:22 +01:00
|
|
|
* @param name
|
|
|
|
|
* @param environmentNode
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
2022-07-23 15:37:22 +01:00
|
|
|
EnvironmentConfig(std::string name, const YAML::Node& environmentNode);
|
2021-12-31 19:44:20 +00:00
|
|
|
};
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2021-12-31 19:44:20 +00:00
|
|
|
/**
|
|
|
|
|
* This holds all user provided project configuration.
|
|
|
|
|
*/
|
|
|
|
|
struct ProjectConfig
|
|
|
|
|
{
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
|
|
|
|
* A mapping of environment names to EnvironmentConfig objects.
|
|
|
|
|
*/
|
|
|
|
|
std::map<std::string, EnvironmentConfig> environments;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Application level debug server configuration. We use this as a fallback if no debug server config is
|
|
|
|
|
* provided at the environment level.
|
|
|
|
|
*/
|
|
|
|
|
std::optional<DebugServerConfig> debugServerConfig;
|
|
|
|
|
|
2021-12-31 19:44:20 +00:00
|
|
|
/**
|
|
|
|
|
* Application level Insight configuration. We use this as a fallback if no Insight config is provided at
|
|
|
|
|
* the environment level.
|
|
|
|
|
*/
|
|
|
|
|
std::optional<InsightConfig> insightConfig;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
bool debugLoggingEnabled = false;
|
2021-12-31 19:44:20 +00:00
|
|
|
|
|
|
|
|
/**
|
2022-07-23 15:37:22 +01:00
|
|
|
* Obtains config parameters from YAML node.
|
2021-12-31 19:44:20 +00:00
|
|
|
*
|
2022-07-23 15:37:22 +01:00
|
|
|
* @param configNode
|
2021-12-31 19:44:20 +00:00
|
|
|
*/
|
2022-07-23 15:37:22 +01:00
|
|
|
explicit ProjectConfig(const YAML::Node& configNode);
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
}
|