Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tools/projmgr/include/ProjMgrParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,34 @@ struct MemoryItem {
std::string algorithm;
};

/**
* @brief custom item containing
* scalar
* array
* map
*/
struct CustomItem {
std::string scalar;
std::vector<CustomItem> vec;
std::vector<std::pair<std::string, CustomItem>> map;
};

/**
* @brief debugger item containing
* name of debug configuration
* debug protocol (jtag or swd)
* debug clock speed
* debug configuration file
* start pname
* custom properties
*/
struct DebuggerItem {
std::string name;
std::string protocol;
std::string clock;
std::string dbgconf;
std::string startPname;
CustomItem custom;
};

/**
Expand Down Expand Up @@ -609,6 +623,7 @@ struct DebugAdapterDefaultsItem {
std::string port;
std::string protocol;
std::string clock;
CustomItem custom;
};

/**
Expand Down
3 changes: 3 additions & 0 deletions tools/projmgr/include/ProjMgrRunDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ class ProjMgrRunDebug {
const std::map<std::string, RteDeviceProperty*>& pnames);
void CollectDebugTopology(const ContextItem& context, std::vector<std::pair<const RteItem*, std::vector<std::string>>> debugs,
const std::map<std::string, RteDeviceProperty*>& pnames);
void CustomVecPushBack(std::vector<CustomItem>& vec, const CustomItem& value);
CustomItem& CustomMapFind(std::vector<std::pair<std::string, CustomItem>>& customMap, const std::string& key);
void MergeCustomItems(const CustomItem& src, CustomItem& dst);
};

#endif // PROJMGRRUNDEBUG_H
2 changes: 2 additions & 0 deletions tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ struct GdbServerItem {
* debug configuration file
* start pname
* list of gdbserver items
* custom options
*/
struct DebuggerType {
std::string name;
Expand All @@ -297,6 +298,7 @@ struct DebuggerType {
std::string dbgconf;
std::string startPname;
std::vector<GdbServerItem> gdbserver;
CustomItem custom;
};

/**
Expand Down
2 changes: 2 additions & 0 deletions tools/projmgr/include/ProjMgrYamlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ class ProjMgrYamlParser {
bool ParseLinker(const YAML::Node& parent, const std::string& file, std::vector<LinkerItem>& linker);
void ParseRte(const YAML::Node& parent, std::string& rteBaseDir);
void ParseDebugDefaults(const YAML::Node& parent, const std::string& file, DebugAdapterDefaultsItem& defaults);
void ParseCustom(const YAML::Node& parent, const std::vector<std::string>& skip, CustomItem& custom);
bool GetTypes(const std::string& type, std::string& buildType, std::string& targetType, std::string& pattern);
bool ValidateCdefault(const std::string& input, const YAML::Node& root);
bool ValidateCsolution(const std::string& input, const YAML::Node& root);
Expand All @@ -365,6 +366,7 @@ class ProjMgrYamlParser {
void ParsePortablePath(const YAML::Node& parent, const std::string& file, const std::string& key, std::string& value);
void ParsePortablePaths(const YAML::Node& parent, const std::string& file, const std::string& key, std::vector<std::string>& value);
void EnsurePortability(const std::string& file, const YAML::Mark& mark, const std::string& key, std::string& value);
CustomItem GetCustomValue(const YAML::Node& node);

};

Expand Down
2 changes: 1 addition & 1 deletion tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2413,7 +2413,7 @@
"protocol": { "enum": [ "jtag", "swd" ], "description": "Selected debug protocol (jtag or swd)." },
"clock": { "type": "number", "description": "Selected debug clock speed (in Hz)." }
},
"additionalProperties": false
"additionalProperties": true
}
}
}
27 changes: 27 additions & 0 deletions tools/projmgr/src/ProjMgrCbuildRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ProjMgrCbuildRun : public ProjMgrCbuildBase {
void SetAccessPortsNode(YAML::Node node, const std::vector<AccessPortType>& accessPorts);
void SetDatapatchNode(YAML::Node node, const std::vector<DatapatchType>& datapatch);
void SetGdbServerNode(YAML::Node node, const std::vector<GdbServerItem>& gdbserver);
void SetCustomNodes(YAML::Node node, const CustomItem& debugger);
YAML::Node GetCustomNode(const CustomItem& value);
};

ProjMgrCbuildRun::ProjMgrCbuildRun(YAML::Node node,
Expand Down Expand Up @@ -110,6 +112,31 @@ void ProjMgrCbuildRun::SetDebuggerNode(YAML::Node node, const DebuggerType& debu
}
SetNodeValue(node[YAML_START_PNAME], debugger.startPname);
SetGdbServerNode(node[YAML_GDBSERVER], debugger.gdbserver);
SetCustomNodes(node, debugger.custom);
}
}

YAML::Node ProjMgrCbuildRun::GetCustomNode(const CustomItem& value) {
YAML::Node node;
if (!value.scalar.empty()) {
node = value.scalar;
}
else if (!value.vec.empty()) {
for (const auto& item : value.vec) {
node.push_back(GetCustomNode(item));
}
}
else if (!value.map.empty()) {
for (const auto& [k, v] : value.map) {
node[k] = GetCustomNode(v);
}
}
return node;
}

void ProjMgrCbuildRun::SetCustomNodes(YAML::Node node, const CustomItem& custom) {
for (const auto& [key, value] : custom.map) {
node[key] = GetCustomNode(value);
}
}

Expand Down
40 changes: 40 additions & 0 deletions tools/projmgr/src/ProjMgrRunDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,13 @@ void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const
if (!m_runDebug.debugger.clock.has_value() && !adapter.defaults.clock.empty()) {
m_runDebug.debugger.clock = RteUtils::StringToULL(adapter.defaults.clock);
}
// default custom options
m_runDebug.debugger.custom = adapter.defaults.custom;
}
}

// merge custom options
MergeCustomItems(context.debugger.custom, m_runDebug.debugger.custom);
}

void ProjMgrRunDebug::CollectDebugTopology(const ContextItem& context, const vector<pair<const RteItem*, vector<string>>> debugs,
Expand Down Expand Up @@ -632,3 +637,38 @@ bool ProjMgrRunDebug::GetDebugAdapter(const string& name, const DebugAdaptersIte
}
return false;
}

void ProjMgrRunDebug::CustomVecPushBack(vector<CustomItem>& vec, const CustomItem& value) {
for (const auto& item : vec) {
if (item.scalar == value.scalar) {
return;
}
}
vec.push_back(value);
}

CustomItem& ProjMgrRunDebug::CustomMapFind(vector<pair<string, CustomItem>>& customMap, const string& key) {
for (auto& [k, v] : customMap) {
if (key == k) {
return v;
}
}
customMap.push_back({ key, CustomItem() });
return customMap.back().second;
}

void ProjMgrRunDebug::MergeCustomItems(const CustomItem& src, CustomItem& dst) {
if (!src.scalar.empty()) {
dst.scalar = src.scalar;
}
else if (!src.vec.empty()) {
for (const auto& item : src.vec) {
CustomVecPushBack(dst.vec, item);
}
}
else if (!src.map.empty()) {
for (const auto& [k, v] : src.map) {
MergeCustomItems(v, CustomMapFind(dst.map, k));
}
}
}
1 change: 1 addition & 0 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,7 @@ bool ProjMgrWorker::ProcessDebuggers(ContextItem& context) {
}
}
context.debugger.startPname = m_activeTargetSet.debugger.startPname;
context.debugger.custom = m_activeTargetSet.debugger.custom;
}
for (const auto& [filename, fi] : context.rteActiveProject->GetFileInstances()) {
if (fi->HasAttribute("configfile")) {
Expand Down
30 changes: 30 additions & 0 deletions tools/projmgr/src/ProjMgrYamlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ void ProjMgrYamlParser::ParseDebugger(const YAML::Node& parent, const string& fi
ParseNumber(debuggerNode, file, YAML_CLOCK, debugger.clock);
ParsePortablePath(debuggerNode, file, YAML_DBGCONF, debugger.dbgconf);
ParseString(debuggerNode, YAML_START_PNAME, debugger.startPname);
ParseCustom(debuggerNode, { YAML_NAME, YAML_PROTOCOL, YAML_CLOCK, YAML_DBGCONF, YAML_START_PNAME }, debugger.custom);
}
}

Expand All @@ -631,6 +632,7 @@ void ProjMgrYamlParser::ParseDebugDefaults(const YAML::Node& parent, const strin
ParseNumber(defaultsNode, file, YAML_PORT, defaults.port);
ParseString(defaultsNode, YAML_PROTOCOL, defaults.protocol);
ParseNumber(defaultsNode, file, YAML_CLOCK, defaults.clock);
ParseCustom(defaultsNode, { YAML_PORT, YAML_PROTOCOL, YAML_CLOCK }, defaults.custom);
}
}

Expand Down Expand Up @@ -1074,6 +1076,34 @@ void ProjMgrYamlParser::ParseImages(const YAML::Node& parent, const string& file
}
}

CustomItem ProjMgrYamlParser::GetCustomValue(const YAML::Node& node) {
CustomItem value;
if (node.IsScalar()) {
value.scalar = node.as<string>();
}
else if (node.IsSequence()) {
for (const auto& item : node) {
value.vec.push_back(GetCustomValue(item));
}
}
else if (node.IsMap()) {
for (const auto& item : node) {
value.map.push_back({ item.first.as<string>(), GetCustomValue(item.second) });
}
}
return value;
}

void ProjMgrYamlParser::ParseCustom(const YAML::Node& parent, const vector<string>& skip, CustomItem& custom) {
for (const auto& node : parent) {
const auto& key = node.first.as<string>();
if (find(skip.begin(), skip.end(), key) != skip.end()) {
continue;
}
custom.map.push_back({ key, GetCustomValue(node.second) });
}
}

// Validation Maps
const set<string> defaultKeys = {
YAML_COMPILER,
Expand Down
7 changes: 7 additions & 0 deletions tools/projmgr/test/data/TestRunDebug/custom.cproject.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json

project:

components:
- component: Startup
- component: CORE
28 changes: 28 additions & 0 deletions tools/projmgr/test/data/TestRunDebug/custom.csolution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:

compiler: AC6

target-types:
- type: TestHW
device: RteTest_ARMCM4_NOFP
target-set:
- set:
debugger:
name: Test Custom Adapter
custom-key: custom value
custom-key-overwrite: custom value overwrite
custom-array:
- value 1
- value 2
custom-map:
key: value
images:
- project-context: custom

projects:
- project: custom.cproject.yml

packs:
- pack: ARM::RteTest_DFP
Loading
Loading