Skip to content

Commit

Permalink
List available API versions (#696)
Browse files Browse the repository at this point in the history
* List available API versions
* Update XmlItem.cpp

---------

Co-authored-by: Evgueni Driouk <evgueni.driouk@arm.com>
  • Loading branch information
edriouk and Evgueni Driouk authored Sep 29, 2023
1 parent c14b5f1 commit f7bc0b6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
6 changes: 6 additions & 0 deletions libs/rtemodel/include/RteModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<RteApi*> GetAvailableApis(const std::string& id) const;

/**
* @brief getter for collection of APIs
Expand Down
11 changes: 11 additions & 0 deletions libs/rtemodel/src/RteModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,17 @@ RteApi* RteModel::GetLatestApi(const string& id) const
return nullptr;
}

std::list<RteApi*> RteModel::GetAvailableApis(const std::string& id) const
{
std::list<RteApi*> 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
{
Expand Down
19 changes: 12 additions & 7 deletions libs/rtemodel/src/RteProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<RteApi*> 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);
Expand Down
2 changes: 2 additions & 0 deletions libs/rtemodel/test/src/RteConditionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions libs/xmltree/src/XmlItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ bool XmlItem::RemoveAttribute(const char* name)
bool XmlItem::EraseAttributes(const std::string& pattern)
{
set<string> attributesToErase;
for (const auto [key, _] : m_attributes) {
for ( auto [key, _] : m_attributes) {
if (WildCards::Match(pattern, key)) {
attributesToErase.insert(key);
}
}
if (attributesToErase.empty()) {
return false;
}
for (const auto& key : attributesToErase) {
for ( auto& key : attributesToErase) {
RemoveAttribute(key);
}
return true;
Expand Down

0 comments on commit f7bc0b6

Please sign in to comment.