Skip to content

Commit 1c775a0

Browse files
grasci-armedriouk
andauthored
Only suggest components from the same bundle (#1283) (#2172)
#2127 Co-authored-by: Evgueni Driouk <[email protected]>
1 parent b4e6c4a commit 1c775a0

File tree

4 files changed

+56
-15
lines changed

4 files changed

+56
-15
lines changed

libs/rtemodel/include/RteComponent.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,9 +1014,11 @@ class RteComponentGroup : public RteComponentContainer
10141014
* @brief find recursively component aggregates matching supplied attributes
10151015
* @param componentAttributes component attributes as a reference to XmlItem
10161016
* @param components std::set collection of RteComponentAggregate pointer to fill
1017+
* @param bundleName bundle to be used
10171018
* @return overall matching result as RteItem::ConditionResult value
10181019
*/
1019-
virtual ConditionResult GetComponentAggregates(const XmlItem& componentAttributes, std::set<RteComponentAggregate*>& components) const;
1020+
virtual ConditionResult GetComponentAggregates(const XmlItem& componentAttributes, std::set<RteComponentAggregate*>& components,
1021+
const std::string& bundleName = EMPTY_STRING) const;
10201022

10211023
/**
10221024
* @brief adjust component selection in the group when active bundle changes
@@ -1168,7 +1170,8 @@ class RteComponentClassContainer : public RteComponentGroup
11681170
* @param components std::set collection of RteComponentAggregate pointer to fill
11691171
* @return overall matching result as RteItem::ConditionResult value
11701172
*/
1171-
ConditionResult GetComponentAggregates(const XmlItem& componentAttributes, std::set<RteComponentAggregate*>& components) const override;
1173+
ConditionResult GetComponentAggregates(const XmlItem& componentAttributes, std::set<RteComponentAggregate*>& components,
1174+
const std::string& bundleName = EMPTY_STRING) const override;
11721175

11731176
/**
11741177
* @brief find component aggregate matching supplied instance to resolve a component

libs/rtemodel/src/RteComponent.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ void RteComponentAggregate::Clear()
441441

442442
bool RteComponentAggregate::IsFiltered() const
443443
{
444-
if (GetSelectedBundleShortID() != GetBundleShortID())
444+
if (GetSelectedBundleName() != GetCbundleName())
445445
return false;
446446
return true;
447447
}
@@ -1701,13 +1701,21 @@ string RteComponentGroup::GetDocFile() const
17011701
}
17021702

17031703

1704-
RteItem::ConditionResult RteComponentGroup::GetComponentAggregates(const XmlItem& componentAttributes, set<RteComponentAggregate*>& aggregates) const
1704+
RteItem::ConditionResult RteComponentGroup::GetComponentAggregates(const XmlItem& componentAttributes,
1705+
set<RteComponentAggregate*>& aggregates, const std::string& bundleName) const
17051706
{
17061707
ConditionResult res = MISSING;
17071708

17081709
for (auto child : m_children) {
17091710
RteComponentAggregate* a = dynamic_cast<RteComponentAggregate*>(child);
1710-
if (a && a->MatchComponentAttributes(componentAttributes.GetAttributes())) {
1711+
if(!a) {
1712+
continue;
1713+
}
1714+
auto& componentBundle = a->GetCbundleName();
1715+
if(!(bundleName.empty() || bundleName == componentBundle)) {
1716+
continue; // skip non-matching bundles
1717+
}
1718+
if (a->MatchComponentAttributes(componentAttributes.GetAttributes())) {
17111719
aggregates.insert(a);
17121720
ConditionResult r = INSTALLED;
17131721
if (a->IsFiltered()) {
@@ -1735,7 +1743,7 @@ RteItem::ConditionResult RteComponentGroup::GetComponentAggregates(const XmlItem
17351743
}
17361744
for (auto [_, g] : m_groups) {
17371745
if (g) {
1738-
ConditionResult r = g->GetComponentAggregates(componentAttributes, aggregates);
1746+
ConditionResult r = g->GetComponentAggregates(componentAttributes, aggregates, bundleName);
17391747
if (res < r)
17401748
res = r;
17411749
}
@@ -1896,11 +1904,15 @@ RteComponentGroup* RteComponentClassContainer::CreateGroup(const string& name)
18961904
return new RteComponentClass(this);
18971905
}
18981906

1899-
RteItem::ConditionResult RteComponentClassContainer::GetComponentAggregates(const XmlItem& componentAttributes, set<RteComponentAggregate*>& aggregates) const
1907+
RteItem::ConditionResult RteComponentClassContainer::GetComponentAggregates(const XmlItem& componentAttributes, set<RteComponentAggregate*>& aggregates,
1908+
const std::string& _bundleName) const
19001909
{
19011910
RteComponentGroup* classGroup = GetGroup(componentAttributes.GetAttribute("Cclass"));
1902-
if (classGroup)
1903-
return classGroup->GetComponentAggregates(componentAttributes, aggregates);
1911+
if(classGroup) {
1912+
// limit to selected bundle if at least one component is selected
1913+
const string& selectedBundleName = classGroup->IsSelected() ? classGroup->GetSelectedBundleName() : EMPTY_STRING;
1914+
return classGroup->GetComponentAggregates(componentAttributes, aggregates, selectedBundleName);
1915+
}
19041916
return MISSING;
19051917
}
19061918

libs/rtemodel/test/src/RteConditionTest.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,40 @@ TEST_F(RteConditionTest, MissingIgnoredFulfilledSelectable) {
7979
RteCondition* denyIncompatibleVariant = pack->GetCondition("DenyIncompatibleVariant");
8080
ASSERT_NE(denyIncompatibleVariant, nullptr);
8181

82-
// select component to check dependencies
82+
// list only selected bundle
8383
RteComponentInstance item(nullptr);
8484
item.SetTag("component");
85+
item.SetAttributes({ {"Cbundle","BundleOne" },
86+
{"Cclass","RteTestBundle" },
87+
{"Cgroup", "G2" },
88+
{"Cversion","1.1.0"},
89+
{"condition","Require_G0"} });
90+
item.SetPackageAttributes(packInfo);
91+
RteComponent* c = rteModel->FindFirstComponent(item);
92+
ASSERT_NE(c, nullptr);
93+
auto requireG0Condition = pack->GetCondition("Require_G0");
94+
ASSERT_NE(requireG0Condition, nullptr);
95+
auto expr = dynamic_cast<RteConditionExpression*>(requireG0Condition->GetFirstChild());
96+
ASSERT_NE(expr, nullptr);
97+
set<RteComponentAggregate*> aggregates;
98+
activeTarget->GetComponentAggregates(*expr, aggregates);
99+
ASSERT_EQ(aggregates.size(), 3); // all available bundles
100+
aggregates.clear();
101+
activeTarget->SelectComponent(c, 1, true);
102+
EXPECT_EQ(depSolver->GetConditionResult(), RteItem::SELECTABLE);
103+
activeTarget->GetComponentAggregates(*expr, aggregates);
104+
ASSERT_EQ(aggregates.size(), 1); // only with selected bundle
105+
auto depsAggr = *aggregates.begin();
106+
EXPECT_EQ(depsAggr->GetCbundleName(), "BundleOne");
107+
activeTarget->SelectComponent(c, 0, true);
108+
109+
// select component to check dependencies
85110
item.SetAttributes({ {"Cclass","RteTest" },
86111
{"Cgroup", "AcceptDependency" },
87112
{"Cversion","0.9.9"},
88113
{"condition","AcceptDependency"} });
89-
item.SetPackageAttributes(packInfo);
90114

91-
RteComponent* c = rteModel->FindFirstComponent(item);
115+
c = rteModel->FindFirstComponent(item);
92116
ASSERT_NE(c, nullptr);
93117
activeTarget->SelectComponent(c, 1, true);
94118
EXPECT_EQ(depSolver->GetConditionResult(), RteItem::FULFILLED); // required dependency already selected

test/packs/ARM/RteTest/0.1.0/ARM.RteTest.pdsc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@
8686
<condition id="DenyIncompatibleVariant">
8787
<deny condition="Incompatible Variant"/>
8888
</condition>
89-
89+
<condition id="Require_G0">
90+
<require Cclass="RteTestBundle" Cgroup="G0"/>
91+
</condition>
9092
</conditions>
9193

9294
<apis>
@@ -140,7 +142,7 @@
140142
<file category="doc" name="https://arm-software.github.io/CMSIS_5/Pack/html/createPackUtil.html"/>
141143
</files>
142144
</component>
143-
<component Cgroup="G2">
145+
<component Cgroup="G2" condition="Require_G0">
144146
<description>Bundle One, component G2</description>
145147
<files>
146148
<file category="doc" name="https://arm-software.github.io/CMSIS_5/Pack/html/createPackUtil.html"/>
@@ -157,7 +159,7 @@
157159
<file category="doc" name="https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_conditions_pg.html"/>
158160
</files>
159161
</component>
160-
<component Cgroup="G2">
162+
<component Cgroup="G2" condition="Require_G0">
161163
<description>Bundle Two, component G2</description>
162164
<files>
163165
<file category="doc" name="https://arm-software.github.io/CMSIS_5/Pack/html/createPackUtil.html"/>

0 commit comments

Comments
 (0)