Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTE: Pack description tag dominate does not overrule API #1316

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions libs/rtemodel/src/RteModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,17 @@ RteComponent* RteModel::GetComponent(RteComponentInstance* ci, bool matchVersion

RteApi* RteModel::GetApi(const map<string, string>& componentAttributes) const
{
RteApi* api = nullptr;
for (auto [_, a] : m_apiList) {
if (a && a->MatchApiAttributes(componentAttributes))
return a;
if(a && a->MatchApiAttributes(componentAttributes)) {
if(a->GetPackage()->IsDominating()) {
return a; // first dominating API wins
} else if(!api) {
api = a; // keep latest
}
}
}
return nullptr;
return api;
}

RteApi* RteModel::GetApi(const string& id) const
Expand All @@ -277,13 +283,18 @@ RteApi* RteModel::GetApi(const string& id) const
RteApi* RteModel::GetLatestApi(const string& id) const
{
string commonId = RteUtils::GetPrefix(id, RteConstants::PREFIX_CVERSION_CHAR);
RteApi* api = nullptr;
// get highest API version
for (auto [key, api] : m_apiList) {
for (auto [key, a] : m_apiList) {
if (RteUtils::GetPrefix(key, RteConstants::PREFIX_CVERSION_CHAR) == commonId) {
return api;
if(a->GetPackage()->IsDominating()) {
return a; // first dominating API wins
} else if(!api) {
api = a; // keep latest
}
}
}
return nullptr;
return api;
}

std::list<RteApi*> RteModel::GetAvailableApis(const std::string& id) const
Expand Down
2 changes: 1 addition & 1 deletion libs/rtemodel/src/RtePackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ string RtePackage::ConstructID()
m_commonID = RtePackage::GetPackageIDfromAttributes(*this, false);

m_nDeprecated = IsDeprecated() ? 1 : 0;
m_nDominating = IsDominating() ? 1 : 0;
m_nDominating = !m_nDeprecated && GetItemByTag("dominate") != nullptr;
return id;
}

Expand Down
18 changes: 18 additions & 0 deletions libs/rtemodel/test/src/RteModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,24 @@ TEST(RteModelTest, LoadPacks) {
RteGenerator* gen = c->GetGenerator();
EXPECT_FALSE(gen != nullptr);

// get API
const string& apiId = "::RteTest:CORE(API)";
RteApi* api = rteModel->GetLatestApi(apiId);
ASSERT_TRUE(api);
EXPECT_EQ(api->GetID(), "::RteTest:CORE(API)@1.1.2");
EXPECT_EQ(api->GetPackageID(), "ARM::[email protected]");

// make pack "dominant"
pack = rteModel->GetPackage("ARM::[email protected]");
ASSERT_TRUE(pack);
RteItem* dominateItem = new RteItem("dominate", pack);
pack->AddChild(dominateItem);
pack->Construct(); // refresh internal state
api = rteModel->GetLatestApi(apiId);
ASSERT_TRUE(api);
EXPECT_EQ(api->GetID(), "::RteTest:CORE(API)@1.1.1");
EXPECT_EQ(api->GetPackageID(), "ARM::[email protected]");

ExtGenRteCallback extGenRteCallback;
rteKernel.SetRteCallback(&extGenRteCallback);
gen = c->GetGenerator();
Expand Down
2 changes: 1 addition & 1 deletion test/packs/ARM/RteTest_DFP/0.2.0/ARM.RteTest_DFP.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
</conditions>

<apis>
<api Cclass="RteTest" Cgroup="CORE" Capiversion="1.1.1" exclusive="1">
<api Cclass="RteTest" Cgroup="CORE" Capiversion="1.1.2" exclusive="1">
<description>RteTest CORE API</description>
<files>
<!-- CPU independent -->
Expand Down
Loading