From 16c155823522ee94b60bfb41295eb5448076a119 Mon Sep 17 00:00:00 2001 From: Daniel Brondani Date: Wed, 4 Feb 2026 13:44:51 +0100 Subject: [PATCH] [projmgr] Fix `for-compiler` check and error message (#1409) --- tools/projmgr/include/ProjMgrWorker.h | 2 ++ tools/projmgr/src/ProjMgrWorker.cpp | 16 ++++++++++------ tools/projmgr/test/src/ProjMgrUnitTests.cpp | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/projmgr/include/ProjMgrWorker.h b/tools/projmgr/include/ProjMgrWorker.h index 100bdbc50..eb0fb62da 100644 --- a/tools/projmgr/include/ProjMgrWorker.h +++ b/tools/projmgr/include/ProjMgrWorker.h @@ -1143,6 +1143,7 @@ class ProjMgrWorker { m_missingFiles.clear(); m_types = {}; m_activeTargetType.clear(); + m_missingToolchains.clear(); m_undefCompiler = false; m_isSetupCommand = false; }; @@ -1303,6 +1304,7 @@ class ProjMgrWorker { template bool CheckFilter(const std::string& filter, const T& item); void ResolvePackRequirement(ContextItem& context, const PackItem& packEntry, bool ignoreCBuildPack); void FormatResolvedPackIds(); + void RetrieveToolchainConfigFiles(); }; #endif // PROJMGRWORKER_H diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index 303d0badd..4e197b1ee 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -1835,6 +1835,7 @@ void ProjMgrWorker::ResolvePackRequirement(ContextItem& context, const PackItem& } bool ProjMgrWorker::ProcessToolchain(ContextItem& context) { + RetrieveToolchainConfigFiles(); if (context.compiler.empty()) { // Use the default compiler if available if (context.cdefault && !context.cdefault->compiler.empty()) { @@ -3939,7 +3940,7 @@ void ProjMgrWorker::PrintMissingFilters(void) { (misspelled ? ", did you mean '." + type + "'?" : "")); } for (const auto& toolchain : m_missingToolchains) { - ProjMgrLogger::Get().Warn("compiler '" + toolchain + "' is not supported"); + ProjMgrLogger::Get().Warn("'for-compiler: " + toolchain + "' is not supported"); } } @@ -5152,17 +5153,20 @@ bool ProjMgrWorker::GetLatestToolchain(ToolchainItem& toolchain) { return found; } -bool ProjMgrWorker::GetToolchainConfig(const string& toolchainName, const string& toolchainVersion, string& configPath, string& selectedConfigVersion) { - const string& compilerRoot = GetCompilerRoot(); +void ProjMgrWorker::RetrieveToolchainConfigFiles(void) { // get toolchain configuration files if (m_toolchainConfigFiles.empty()) { // get *.cmake files from compiler root (not recursively) - auto cmakeFiles = RteFsUtils::GrepFiles(compilerRoot, "*.cmake"); + auto cmakeFiles = RteFsUtils::GrepFiles(GetCompilerRoot(), "*.cmake"); std::transform(cmakeFiles.begin(), cmakeFiles.end(), std::back_inserter(m_toolchainConfigFiles), [](const std::filesystem::path& item) { return item.generic_string(); - }); + }); } +} + +bool ProjMgrWorker::GetToolchainConfig(const string& toolchainName, const string& toolchainVersion, string& configPath, string& selectedConfigVersion) { + RetrieveToolchainConfigFiles(); // find greatest compatible file bool found = false; static const regex regEx = regex("(\\w+)\\.(\\d+\\.\\d+\\.\\d+)"); @@ -5189,7 +5193,7 @@ bool ProjMgrWorker::GetToolchainConfig(const string& toolchainName, const string } } if (!found) { - m_toolchainErrors[MessageType::Error].insert("no toolchain cmake files found for '" + toolchainName + "' in '" + compilerRoot + "' directory"); + m_toolchainErrors[MessageType::Error].insert("no toolchain cmake files found for '" + toolchainName + "' in '" + GetCompilerRoot() + "' directory"); } return found; } diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 5b3774636..4ba5c3240 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -5221,7 +5221,7 @@ warning csolution: build-type '.UnknownBuild' does not exist in solution\n\ warning csolution: target-type '+Debug' does not exist in solution, did you mean '.Debug'?\n\ warning csolution: target-type '+MappedDebug' does not exist in solution, did you mean '.MappedDebug'?\n\ warning csolution: target-type '+UnknownTarget' does not exist in solution\n\ -warning csolution: compiler 'Ac6' is not supported\n\ +warning csolution: 'for-compiler: Ac6' is not supported\n\ "; auto errStr = streamRedirect.GetErrorString(); EXPECT_TRUE(errStr.find(expected) != string::npos);