From 5d67ddaadfd81fbce0e915bc27d29cbef2b3a2b0 Mon Sep 17 00:00:00 2001 From: Jen-Tse Huang Date: Tue, 31 Mar 2026 15:07:45 +0200 Subject: [PATCH] Show err in Problems, Ouput and cbuild-idx.yml if no compatible layer found --- tools/projmgr/include/ProjMgr.h | 6 +++++ tools/projmgr/src/ProjMgr.cpp | 30 +++++++++++++-------- tools/projmgr/src/ProjMgrRpcServer.cpp | 4 +++ tools/projmgr/test/src/ProjMgrUnitTests.cpp | 2 +- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/tools/projmgr/include/ProjMgr.h b/tools/projmgr/include/ProjMgr.h index 057e0e7f5..1a7d4e8ec 100644 --- a/tools/projmgr/include/ProjMgr.h +++ b/tools/projmgr/include/ProjMgr.h @@ -88,6 +88,12 @@ class ProjMgr { bool RunConvert(const std::string&csolution = RteUtils::EMPTY_STRING, const std::string& activeTargetSet = RteUtils::EMPTY_STRING, const bool& updateRte = false); + /** + * @brief call function to (re-)generate cbuild-idx.yml + * @return true if executed successfully + */ + bool CallGenerateCbuildIndex(); + protected: /** * @brief parse command line options diff --git a/tools/projmgr/src/ProjMgr.cpp b/tools/projmgr/src/ProjMgr.cpp index 50a12a734..0c3fe3317 100644 --- a/tools/projmgr/src/ProjMgr.cpp +++ b/tools/projmgr/src/ProjMgr.cpp @@ -657,9 +657,9 @@ bool ProjMgr::Configure() { 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() +":"; for (const string& var : undefVars) { - errMsg += " - $" + var + "$\n"; + errMsg += "\n - $" + var + "$"; } ProjMgrLogger::Get().Error(errMsg); } @@ -1097,9 +1097,9 @@ bool ProjMgr::RunListLayers(void) { bool error = m_worker.HasVarDefineError() && !m_updateIdx; if (error) { 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() + ":"; for (const string& var : undefVars) { - errMsg += " - $" + var + "$\n"; + errMsg += "\n - $" + var + "$"; } ProjMgrLogger::Get().Error(errMsg); } @@ -1123,13 +1123,8 @@ bool ProjMgr::RunListLayers(void) { // Update the cbuild-idx.yml file with layer information if (m_updateIdx) { // Generate Cbuild index - const auto& processedContexts = m_worker.GetProcessedContexts(); - if (!processedContexts.empty()) { - m_worker.ElaborateVariablesConfigurations(); - if (!m_emitter.GenerateCbuildIndex(processedContexts, - m_failedContext, map())) { - return false; - } + if (!CallGenerateCbuildIndex()) { + return false; } } return !error; @@ -1373,3 +1368,16 @@ bool ProjMgr::IsSolutionImageOnly() { } return imageOnly; } + +bool ProjMgr::CallGenerateCbuildIndex() { + const auto& processedContexts = m_worker.GetProcessedContexts(); + if (!processedContexts.empty()) { + m_worker.ElaborateVariablesConfigurations(); + if (!m_emitter.GenerateCbuildIndex(processedContexts, + m_failedContext, map())) { + return false; + } + } + return true; +} + diff --git a/tools/projmgr/src/ProjMgrRpcServer.cpp b/tools/projmgr/src/ProjMgrRpcServer.cpp index ce8698625..b37a4dc62 100644 --- a/tools/projmgr/src/ProjMgrRpcServer.cpp +++ b/tools/projmgr/src/ProjMgrRpcServer.cpp @@ -826,6 +826,8 @@ RpcArgs::DiscoverLayersInfo RpcHandler::DiscoverLayers(const string& solution, c } if(!m_manager.SetupContexts(csolutionFile, activeTarget)) { result.message = "Setup of solution contexts failed"; + ProjMgrLogger::Get().Error(result.message.value()); + m_manager.CallGenerateCbuildIndex(); return result; } m_worker.SetUpCommand(true); @@ -833,6 +835,8 @@ RpcArgs::DiscoverLayersInfo RpcHandler::DiscoverLayers(const string& solution, c 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()); + m_manager.CallGenerateCbuildIndex(); return result; } else { // retrieve valid configurations diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 36c407554..b568da19a 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -4415,7 +4415,7 @@ TEST_F(ProjMgrUnitTests, RunCheckContextProcessing) { EXPECT_EQ(2, RunProjMgr(8, argv, 0)); // Check error for processed context - const string expected = "error csolution: undefined variables in contexts.csolution.yml:\n - $LayerVar$\n\n"; + const string expected = "error csolution: undefined variables in contexts.csolution.yml:\n - $LayerVar$\n"; auto errStr = streamRedirect.GetErrorString(); EXPECT_TRUE(errStr.find(expected) != string::npos);