Skip to content

Commit

Permalink
[RTE] API version selection/resolution may be incorrect Open-CMSIS-Pa…
Browse files Browse the repository at this point in the history
…ck#1124 (Open-CMSIS-Pack#692) (Open-CMSIS-Pack#1131)

improved error reporting for tools

Co-authored-by: Evgueni Driouk <[email protected]>
  • Loading branch information
grasci-arm and Evgueni Driouk authored Sep 22, 2023
1 parent e1674e6 commit afa82b5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libs/rtemodel/include/RteInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,12 @@ class RteComponentInstanceGroup : public RteItem
*/
bool HasUnresolvedComponents(const std::string& targetName, bool bCopy = false) const;

/**
* @brief get condition result for this item (least from children)
* @param context condition evaluation context
* @return cached ConditionResult
*/
ConditionResult GetConditionResult(RteConditionContext* context) const override;

/**
* @brief check if group or its sub-groups contain instance aggregates used by specified target
Expand Down
27 changes: 27 additions & 0 deletions libs/rtemodel/src/RteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,33 @@ bool RteComponentInstanceGroup::HasUnresolvedComponents(const string& targetName
return false;
}

RteItem::ConditionResult RteComponentInstanceGroup::GetConditionResult(RteConditionContext* context) const
{
const RteTarget* t = context->GetTarget();
const string& targetName = t->GetName();
RteItem::ConditionResult result = RteItem::ConditionResult::IGNORED;
for (auto ita = m_children.begin(); ita != m_children.end(); ita++) {
RteComponentInstanceAggregate* a = dynamic_cast<RteComponentInstanceAggregate*>(*ita);
RteComponentAggregate* ca = a? a->GetComponentAggregate(targetName): nullptr;
if (!ca) {
continue;
}
auto res = ca->GetConditionResult(context);
if (result > res) {
result = res;
}
}
map<string, RteComponentInstanceGroup*>::const_iterator it;
for (it = m_groups.begin(); it != m_groups.end(); it++) {
RteComponentInstanceGroup* g = it->second;
auto res = g->GetConditionResult(context);
if (result > res) {
result = res;
}
}
return result;
}

bool RteComponentInstanceGroup::IsUsedByTarget(const string& targetName) const
{
for (auto ita = m_children.begin(); ita != m_children.end(); ita++) {
Expand Down
5 changes: 5 additions & 0 deletions libs/rtemodel/test/src/RteConditionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@ TEST_F(RteConditionTest, MissingIgnoredFulfilledSelectable) {
activeTarget->SelectComponent(c, 1, true);
loadedCprjProject->Apply();
EXPECT_FALSE(loadedCprjProject->Validate());
EXPECT_EQ(loadedCprjProject->GetClasses()->GetConditionResult(depSolver), RteItem::MISSING_API_VERSION);

activeTarget->SelectComponent(c, 0, true);
loadedCprjProject->Apply();
EXPECT_TRUE(loadedCprjProject->Validate());
EXPECT_EQ(loadedCprjProject->GetClasses()->GetConditionResult(depSolver), RteItem::FULFILLED);

item.SetAttribute("Csub", "MissingApiVersionMin");
c = rteModel->FindFirstComponent(item);
Expand All @@ -211,12 +214,14 @@ TEST_F(RteConditionTest, MissingIgnoredFulfilledSelectable) {
EXPECT_EQ(c->GetConditionResult(depSolver), RteItem::CONFLICT);
EXPECT_EQ(c2->GetConditionResult(depSolver), RteItem::CONFLICT);
loadedCprjProject->Apply();
EXPECT_EQ(loadedCprjProject->GetClasses()->GetConditionResult(depSolver), RteItem::CONFLICT);
EXPECT_FALSE(loadedCprjProject->Validate());
activeTarget->SelectComponent(c2, 0, true);
EXPECT_EQ(c->GetConditionResult(depSolver), RteItem::IGNORED);
EXPECT_EQ(c2->GetConditionResult(depSolver), RteItem::IGNORED);
loadedCprjProject->Apply();
EXPECT_TRUE(loadedCprjProject->Validate());
EXPECT_EQ(loadedCprjProject->GetClasses()->GetConditionResult(depSolver), RteItem::FULFILLED);

// API version conflict
item.SetAttributes({ {"Cclass","RteTest" },
Expand Down

0 comments on commit afa82b5

Please sign in to comment.