diff --git a/libs/rtemodel/include/RteModel.h b/libs/rtemodel/include/RteModel.h index 4941c04de..7594fd204 100644 --- a/libs/rtemodel/include/RteModel.h +++ b/libs/rtemodel/include/RteModel.h @@ -260,6 +260,12 @@ class RteModel : public RteItem */ RteApi* GetLatestApi(const std::string& id) const; + /** + * @brief get available API versions for given common ID + * @param id API ID (version is ignored) + * @return list of available RteApi objects + */ + std::list GetAvailableApis(const std::string& id) const; /** * @brief getter for collection of APIs diff --git a/libs/rtemodel/src/RteModel.cpp b/libs/rtemodel/src/RteModel.cpp index b038694a1..bc8876664 100644 --- a/libs/rtemodel/src/RteModel.cpp +++ b/libs/rtemodel/src/RteModel.cpp @@ -296,6 +296,17 @@ RteApi* RteModel::GetLatestApi(const string& id) const return nullptr; } +std::list RteModel::GetAvailableApis(const std::string& id) const +{ + std::list apis; + string commonId = RteUtils::GetPrefix(id, RteConstants::PREFIX_CVERSION_CHAR); + for (auto [key, api] : m_apiList) { + if (RteUtils::GetPrefix(key, RteConstants::PREFIX_CVERSION_CHAR) == commonId) { + apis.push_back(api); + } + } + return apis; +} RteBundle* RteModel::GetBundle(const string& id) const { diff --git a/libs/rtemodel/src/RteProject.cpp b/libs/rtemodel/src/RteProject.cpp index 8c08c24b5..37770f6fb 100644 --- a/libs/rtemodel/src/RteProject.cpp +++ b/libs/rtemodel/src/RteProject.cpp @@ -2094,6 +2094,8 @@ bool RteProject::Validate() RteTarget* target = GetActiveTarget(); if (!target) return true; // nothing to do + RteModel* rteModel = target->GetFilteredModel(); + target->ClearMissingPacks(); // check if all required gpdsc files are available @@ -2236,18 +2238,21 @@ bool RteProject::Validate() msg += "': API version '"; msg += apiVer; msg += "' or compatible is required."; - RteApi* availableApi = c->GetApi(target, false); - if (availableApi) { + m_errors.push_back(msg); + list availableApis = rteModel->GetAvailableApis(c->GetApiID(false)); + for(RteApi* availableApi : availableApis) { string availableApiVer = availableApi->GetApiVersionString(); - msg += " (Version '"; + msg = " Version '"; msg += availableApiVer; msg += "' is found in pack '"; msg += availableApi->GetPackageID(true); - msg += "', install "; - msg += VersionCmp::Compare(apiVer, availableApiVer) < 0 ? "previous" : "next"; - msg += " pack version)."; + if (availableApis.size() == 1) { + msg += "', install "; + msg += VersionCmp::Compare(apiVer, availableApiVer) < 0 ? "previous" : "next"; + msg += " pack version."; + } + m_errors.push_back(msg); } - m_errors.push_back(msg); } else if (apiResult == RteItem::CONFLICT) { bValid = false; RteApi* api = c->GetApi(target, true); diff --git a/libs/rtemodel/test/src/RteConditionTest.cpp b/libs/rtemodel/test/src/RteConditionTest.cpp index b2ca59e8c..ba04d8cc5 100644 --- a/libs/rtemodel/test/src/RteConditionTest.cpp +++ b/libs/rtemodel/test/src/RteConditionTest.cpp @@ -183,6 +183,8 @@ TEST_F(RteConditionTest, MissingIgnoredFulfilledSelectable) { {"Csub", "MissingApiVersion"} }); c = rteModel->FindFirstComponent(item); ASSERT_NE(c, nullptr); + auto apis = rteModel->GetAvailableApis(c->GetApiID(true)); + EXPECT_EQ(apis.size(), 3); EXPECT_EQ(c->GetConditionResult(depSolver), RteItem::MISSING_API_VERSION); activeTarget->SelectComponent(c, 1, true); loadedCprjProject->Apply(); diff --git a/libs/xmltree/src/XmlItem.cpp b/libs/xmltree/src/XmlItem.cpp index b7d9812d3..a7bf8b36a 100644 --- a/libs/xmltree/src/XmlItem.cpp +++ b/libs/xmltree/src/XmlItem.cpp @@ -125,7 +125,7 @@ bool XmlItem::RemoveAttribute(const char* name) bool XmlItem::EraseAttributes(const std::string& pattern) { set attributesToErase; - for (const auto [key, _] : m_attributes) { + for ( auto [key, _] : m_attributes) { if (WildCards::Match(pattern, key)) { attributesToErase.insert(key); } @@ -133,7 +133,7 @@ bool XmlItem::EraseAttributes(const std::string& pattern) if (attributesToErase.empty()) { return false; } - for (const auto& key : attributesToErase) { + for ( auto& key : attributesToErase) { RemoveAttribute(key); } return true;