Skip to content

[projmgr] show messages in Problems, Ouput and cbuild-idx.yml if no compatible layer found#2419

Draft
jthuangarm wants to merge 1 commit intoOpen-CMSIS-Pack:mainfrom
jthuangarm:discoverlayer
Draft

[projmgr] show messages in Problems, Ouput and cbuild-idx.yml if no compatible layer found#2419
jthuangarm wants to merge 1 commit intoOpen-CMSIS-Pack:mainfrom
jthuangarm:discoverlayer

Conversation

@jthuangarm
Copy link
Copy Markdown
Contributor

@jthuangarm jthuangarm commented Mar 31, 2026

To address Open-CMSIS-Pack/vscode-cmsis-solution#119

Centralization of cbuild index generation:

  • Added a new method CallGenerateCbuildIndex() to ProjMgr to centralize the generation of the cbuild-idx.yml file. The method is now reused across multiple locations to eliminate code duplication.
  • Regenerate a cbuild-idx.yml is required. This ensures consistent synchronization of error messages in the file, particularly for cases where cbuild-idx.yml is already generated prior to RpcHandler::DiscoverLayers.
  • Integrated result.message into ProjMgrLogger so that all messages produced during the process are captured in the generated cbuild-idx.yml file. These messages in ProjMgrLogger are also exposed via the RPC method RpcHandler::GetLogMessages and displayed in the frontend.

Error reporting improvements:

  • Updated error messages for undefined variables to print each variable on its own line without an extra newline at the end, making the output more consistent. Adjusted the expected error message in ProjMgrUnitTests.cpp to match the new error output format.

@jthuangarm jthuangarm changed the title Show err in Problems, Ouput and cbuild-idx.yml if no compatible layer found [projmgr] show messages in Problems, Ouput and cbuild-idx.yml if no compatible layer found Mar 31, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.73%. Comparing base (6edc54f) to head (5d67dda).

Files with missing lines Patch % Lines
tools/projmgr/src/ProjMgr.cpp 78.57% 2 Missing and 1 partial ⚠️
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           
Flag Coverage Δ
projmgr-cov 87.76% <83.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tools/projmgr/include/ProjMgr.h 100.00% <ø> (ø)
tools/projmgr/src/ProjMgrRpcServer.cpp 85.29% <100.00%> (+0.10%) ⬆️
tools/projmgr/src/ProjMgr.cpp 80.82% <78.57%> (-0.04%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

Test Results

    3 files     21 suites   15m 41s ⏱️
  455 tests   455 ✅ 0 💤 0 ❌
1 365 runs  1 365 ✅ 0 💤 0 ❌

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() +":";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

@jthuangarm jthuangarm Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as at line 829

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml regeneration via a new ProjMgr::CallGenerateCbuildIndex() helper and reused it in list layers --update-idx.
  • Improved RpcHandler::DiscoverLayers failure handling by logging the result.message and triggering cbuild index regeneration so messages surface in the frontend and cbuild-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.

Comment on lines 828 to +830
result.message = "Setup of solution contexts failed";
ProjMgrLogger::Get().Error(result.message.value());
m_manager.CallGenerateCbuildIndex();
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +829 to 831
ProjMgrLogger::Get().Error(result.message.value());
m_manager.CallGenerateCbuildIndex();
return result;
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 836 to +839
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();
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +838 to 840
ProjMgrLogger::Get().Error(result.message.value());
m_manager.CallGenerateCbuildIndex();
return result;
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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”.

Copilot uses AI. Check for mistakes.
return false;
}
}
return true;
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
return true;
return true;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants