[projmgr] show messages in Problems, Ouput and cbuild-idx.yml if no compatible layer found#2419
[projmgr] show messages in Problems, Ouput and cbuild-idx.yml if no compatible layer found#2419jthuangarm wants to merge 1 commit intoOpen-CMSIS-Pack:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2419 +/- ##
=======================================
Coverage 64.73% 64.73%
=======================================
Files 145 145
Lines 26142 26150 +8
Branches 15778 15781 +3
=======================================
+ Hits 16922 16929 +7
- Misses 7066 7067 +1
Partials 2154 2154
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Test Results 3 files 21 suites 15m 41s ⏱️ Results for commit 5d67dda. |
| if (m_worker.HasVarDefineError()) { | ||
| auto undefVars = m_worker.GetUndefLayerVars(); | ||
| string errMsg = "undefined variables in "+ fs::path(m_csolutionFile).filename().generic_string() +":\n"; | ||
| string errMsg = "undefined variables in "+ fs::path(m_csolutionFile).filename().generic_string() +":"; |
There was a problem hiding this comment.
lines 660-665 are exact copies of the lines 1099-1104
Could you please create a function for that?
| if(!m_manager.SetupContexts(csolutionFile, activeTarget)) { | ||
| result.message = "Setup of solution contexts failed"; | ||
| ProjMgrLogger::Get().Error(result.message.value()); | ||
| m_manager.CallGenerateCbuildIndex(); |
There was a problem hiding this comment.
I'm not sure if .cbuild-idx.yml should be generated here as a side effect.
Immediately before DiscoverLayers, ConvertSolution is called and generates .cbuild-idx.yml
There was a problem hiding this comment.
I did some experiments on this. Previously, I had a working approach where I only appended new messages (errors and warnings) to the existing .cbuild-idx.yml generated by ConvertSolution. This allowed both the original messages and the new discoveryLayer errors to be visible in the the file and in the frontend.
messages:
errors:
- "undefined variables in Network, csolution. yml: \n - $Board-Layer$"
- No compatible software layer found. Review required connections of the project
However, after discussing this with Joachim, he pointed out that the first error message can be misleading. In that case, regenerating the .cbuild-idx.yml and showing only the layer discovery error (i.e. the second message) might be more appropriate.
Please let me know what you think about it. We could also create a function to overwrite the messages, instead of appending or regenerating them.
| StrSet fails; | ||
| if(!m_worker.ListLayers(layers, "", fails) || !m_worker.ElaborateVariablesConfigurations()) { | ||
| result.message = "No compatible software layer found. Review required connections of the project"; | ||
| ProjMgrLogger::Get().Error(result.message.value()); |
There was a problem hiding this comment.
Pull request overview
This PR improves projmgr’s error reporting and log propagation by ensuring relevant errors are logged and reflected in cbuild-idx.yml, and by making undefined-variable output formatting more consistent.
Changes:
- Centralized
cbuild-idx.ymlregeneration via a newProjMgr::CallGenerateCbuildIndex()helper and reused it inlist layers --update-idx. - Improved
RpcHandler::DiscoverLayersfailure handling by logging theresult.messageand triggering cbuild index regeneration so messages surface in the frontend andcbuild-idx.yml. - Adjusted undefined-variable error formatting (one variable per line, no extra trailing blank line) and updated unit test expectations accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tools/projmgr/test/src/ProjMgrUnitTests.cpp | Updates expected stderr text to match the new undefined-variable formatting. |
| tools/projmgr/src/ProjMgrRpcServer.cpp | Logs RPC failure messages and attempts to regenerate cbuild-idx.yml on early exits. |
| tools/projmgr/src/ProjMgr.cpp | Adds CallGenerateCbuildIndex() and refactors --update-idx to use it; adjusts undefined-variable message formatting. |
| tools/projmgr/include/ProjMgr.h | Exposes the new CallGenerateCbuildIndex() API with a brief Doxygen comment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| result.message = "Setup of solution contexts failed"; | ||
| ProjMgrLogger::Get().Error(result.message.value()); | ||
| m_manager.CallGenerateCbuildIndex(); |
There was a problem hiding this comment.
The indentation in this block uses tab characters (e.g., before the ProjMgrLogger call). The surrounding code in this file is consistently space-indented, so please replace the tabs with spaces to match the project’s formatting conventions.
| ProjMgrLogger::Get().Error(result.message.value()); | ||
| m_manager.CallGenerateCbuildIndex(); | ||
| return result; |
There was a problem hiding this comment.
CallGenerateCbuildIndex() returns false if cbuild-idx generation fails, but the return value is ignored here. Please handle the failure (e.g., log an additional error / adjust result.message) so index-generation errors don’t get silently swallowed.
| if(!m_worker.ListLayers(layers, "", fails) || !m_worker.ElaborateVariablesConfigurations()) { | ||
| result.message = "No compatible software layer found. Review required connections of the project"; | ||
| ProjMgrLogger::Get().Error(result.message.value()); | ||
| m_manager.CallGenerateCbuildIndex(); |
There was a problem hiding this comment.
The indentation in this block uses tab characters (before the ProjMgrLogger call). The rest of the file appears to use spaces for indentation, so please convert these tabs to spaces for consistent formatting.
| ProjMgrLogger::Get().Error(result.message.value()); | ||
| m_manager.CallGenerateCbuildIndex(); | ||
| return result; |
There was a problem hiding this comment.
CallGenerateCbuildIndex() can fail and returns false, but the result is ignored. Please check the return value and propagate/report a failure so callers can distinguish “layer discovery failed” from “also failed to update cbuild-idx.yml/log messages”.
| return false; | ||
| } | ||
| } | ||
| return true; |
There was a problem hiding this comment.
This new method ends with a tab-indented return true;, which is inconsistent with the surrounding space indentation in this file. Please replace the tab with spaces to keep formatting consistent.
| return true; | |
| return true; |
To address Open-CMSIS-Pack/vscode-cmsis-solution#119
Centralization of cbuild index generation:
CallGenerateCbuildIndex()toProjMgrto centralize the generation of thecbuild-idx.ymlfile. The method is now reused across multiple locations to eliminate code duplication.cbuild-idx.ymlis required. This ensures consistent synchronization of error messages in the file, particularly for cases wherecbuild-idx.ymlis already generated prior toRpcHandler::DiscoverLayers.result.messageintoProjMgrLoggerso that all messages produced during the process are captured in the generatedcbuild-idx.ymlfile. These messages inProjMgrLoggerare also exposed via the RPC methodRpcHandler::GetLogMessagesand displayed in the frontend.Error reporting improvements:
undefined variablesto print each variable on its own line without an extra newline at the end, making the output more consistent. Adjusted the expected error message inProjMgrUnitTests.cppto match the new error output format.