From 0204ad009bdfe345263dabc3b4b17ff5a3ede9b6 Mon Sep 17 00:00:00 2001 From: Daniel Brondani Date: Tue, 21 Oct 2025 11:28:16 +0200 Subject: [PATCH] [projmgr] Rework debugger custom properties default handling --- tools/projmgr/include/ProjMgrRunDebug.h | 1 - tools/projmgr/src/ProjMgrRunDebug.cpp | 15 ++------------- .../test/data/TestRunDebug/custom.csolution.yml | 3 +++ .../TestRunDebug/ref/custom+TestHW.cbuild-run.yml | 5 +++-- tools/projmgr/test/src/ProjMgrUnitTests.cpp | 1 + 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/tools/projmgr/include/ProjMgrRunDebug.h b/tools/projmgr/include/ProjMgrRunDebug.h index 68ec244d5..5d904a69c 100644 --- a/tools/projmgr/include/ProjMgrRunDebug.h +++ b/tools/projmgr/include/ProjMgrRunDebug.h @@ -225,7 +225,6 @@ class ProjMgrRunDebug { const std::map& pnames); void CollectDebugTopology(const ContextItem& context, std::vector>> debugs, const std::map& pnames); - void CustomVecPushBack(std::vector& vec, const CustomItem& value); CustomItem& CustomMapFind(std::vector>& customMap, const std::string& key); void MergeCustomItems(const CustomItem& src, CustomItem& dst); }; diff --git a/tools/projmgr/src/ProjMgrRunDebug.cpp b/tools/projmgr/src/ProjMgrRunDebug.cpp index ec2b6d973..feae88781 100644 --- a/tools/projmgr/src/ProjMgrRunDebug.cpp +++ b/tools/projmgr/src/ProjMgrRunDebug.cpp @@ -633,15 +633,6 @@ bool ProjMgrRunDebug::GetDebugAdapter(const string& name, const DebugAdaptersIte return false; } -void ProjMgrRunDebug::CustomVecPushBack(vector& vec, const CustomItem& value) { - for (const auto& item : vec) { - if (item.scalar == value.scalar) { - return; - } - } - vec.push_back(value); -} - CustomItem& ProjMgrRunDebug::CustomMapFind(vector>& customMap, const string& key) { for (auto& [k, v] : customMap) { if (key == k) { @@ -657,13 +648,11 @@ void ProjMgrRunDebug::MergeCustomItems(const CustomItem& src, CustomItem& dst) { dst.scalar = src.scalar; } else if (!src.vec.empty()) { - for (const auto& item : src.vec) { - CustomVecPushBack(dst.vec, item); - } + dst.vec = src.vec; } else if (!src.map.empty()) { for (const auto& [k, v] : src.map) { - MergeCustomItems(v, CustomMapFind(dst.map, k)); + CustomMapFind(dst.map, k) = v; } } } diff --git a/tools/projmgr/test/data/TestRunDebug/custom.csolution.yml b/tools/projmgr/test/data/TestRunDebug/custom.csolution.yml index 087875d45..6f188af42 100644 --- a/tools/projmgr/test/data/TestRunDebug/custom.csolution.yml +++ b/tools/projmgr/test/data/TestRunDebug/custom.csolution.yml @@ -18,6 +18,9 @@ solution: - value 2 custom-map: key: value + custom-array-map: + - key: value 1 + - key: value 2 images: - project-context: custom diff --git a/tools/projmgr/test/data/TestRunDebug/ref/custom+TestHW.cbuild-run.yml b/tools/projmgr/test/data/TestRunDebug/ref/custom+TestHW.cbuild-run.yml index 813a4461a..a33013bb0 100644 --- a/tools/projmgr/test/data/TestRunDebug/ref/custom+TestHW.cbuild-run.yml +++ b/tools/projmgr/test/data/TestRunDebug/ref/custom+TestHW.cbuild-run.yml @@ -34,12 +34,13 @@ cbuild-run: custom-adapter-key: custom adapter value custom-key-overwrite: custom value overwrite custom-map: - adapter-key: adapter value key: value custom-array: - - adapter item - value 1 - value 2 + custom-array-map: + - key: value 1 + - key: value 2 custom-key: custom value debug-vars: vars: | diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 48a386a7b..cdbb8f0da 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -6736,6 +6736,7 @@ TEST_F(ProjMgrUnitTests, TestRunDebugCustom) { testAdapter["defaults"]["custom-key-overwrite"] = "custom adapter key overwrite"; testAdapter["defaults"]["custom-map"]["adapter-key"] = "adapter value"; testAdapter["defaults"]["custom-array"][0] = "adapter item"; + testAdapter["defaults"]["custom-array-map"][0]["adapter-key"] = "adapter value"; debugAdapters["debug-adapters"].push_back(testAdapter); ofstream debugAdaptersFile; debugAdaptersFile.open(debugAdaptersPath, fstream::trunc);