Skip to content

Commit 4570155

Browse files
[projmgr] Rework component resolution to avoid picking non-default implementation
1 parent 0b9f781 commit 4570155

26 files changed

+72
-40
lines changed

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,12 +1934,14 @@ RteComponent* ProjMgrWorker::ProcessComponent(ContextItem& context, ComponentIte
19341934
string componentDescriptor = item.component;
19351935

19361936
set<string> filterSet;
1937+
bool freeText = false;
19371938
if (componentDescriptor.find_first_of(RteConstants::COMPONENT_DELIMITERS) != string::npos) {
19381939
// Consider a full or partial component identifier was given
19391940
filterSet.insert(RteUtils::GetPrefix(componentDescriptor, RteConstants::PREFIX_CVERSION_CHAR));
19401941
} else {
19411942
// Consider free text was given
19421943
filterSet = RteUtils::SplitStringToSet(componentDescriptor);
1944+
freeText = true;
19431945
}
19441946

19451947
vector<string> componentIdVec;
@@ -1967,33 +1969,36 @@ RteComponent* ProjMgrWorker::ProcessComponent(ContextItem& context, ComponentIte
19671969
}
19681970
}
19691971

1970-
// Multiple matches, check exact partial identifier
1971-
string requiredComponentId = RteUtils::RemovePrefixByString(item.component, RteConstants::SUFFIX_CVENDOR);
1972-
if (filteredComponents.size() > 1) {
1973-
RteComponentMap matchedComponents;
1972+
RteComponentMap matchedComponents;
1973+
if (!freeText) {
1974+
// Check required identifier mandatory fields
1975+
string requiredComponentId = RteUtils::GetPrefix(
1976+
RteUtils::RemovePrefixByString(item.component, RteConstants::SUFFIX_CVENDOR),
1977+
RteConstants::PREFIX_CVERSION_CHAR);
19741978
for (const auto& [id, component] : filteredComponents) {
19751979
// Get component id without vendor and version
19761980
const string& componentId = component->GetPartialComponentID(true);
19771981
if (requiredComponentId.compare(componentId) == 0) {
19781982
matchedComponents[id] = component;
19791983
}
19801984
}
1981-
// Select unique exact match
1982-
if (matchedComponents.size() == 1) {
1983-
filteredComponents = matchedComponents;
1984-
}
1985+
} else {
1986+
// Free text
1987+
matchedComponents = filteredComponents;
19851988
}
1986-
// Evaluate filtered components
1987-
if (filteredComponents.empty()) {
1989+
1990+
if (matchedComponents.empty()) {
1991+
// Check for default variant if requested variant is empty
1992+
for (const auto& [id, component] : filteredComponents) {
1993+
if (component->IsDefaultVariant() && !component->GetCvariantName().empty()) {
1994+
return component;
1995+
}
1996+
}
19881997
// No match
19891998
return nullptr;
1990-
}
1991-
// One or multiple matches found
1992-
// check for default variant if requested variant is empty
1993-
for (const auto& [id, component] : filteredComponents) {
1994-
if (component->IsDefaultVariant() && !component->GetCvariantName().empty()) {
1995-
return component;
1996-
}
1999+
} else {
2000+
// One or multiple matches
2001+
filteredComponents = matchedComponents;
19972002
}
19982003

19992004
set<string> availableComponentVersions;

tools/projmgr/test/data/TestLayers/variables-redefinition.cproject.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
project:
44
components:
5-
- component: Device:Startup
5+
- component: Device:Startup&RteTest Startup
66
- component: CORE

tools/projmgr/test/data/TestLayers/variables/target1.clayer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layer:
77
for-device: RteTest_ARMCM0
88

99
components:
10-
- component: Device:Startup
10+
- component: Device:Startup&RteTest Startup
1111

1212
define:
1313
- Target1-Layer

tools/projmgr/test/data/TestLayers/variables/target2.clayer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layer:
77
for-device: RteTest_ARMCM3
88

99
components:
10-
- component: Device:Startup
10+
- component: Device:Startup&RteTest Startup
1111

1212
define:
1313
- Target2-Layer

tools/projmgr/test/data/TestLayers/variables/target3.clayer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ layer:
77
for-board: RteTest Dummy board
88

99
components:
10-
- component: Device:Startup
10+
- component: Device:Startup&RteTest Startup
1111

1212
define:
1313
- Target3-Layer
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json
2+
3+
project:
4+
device: RteTest_ARMCM0
5+
compiler: AC6
6+
components:
7+
- component: Board:Test:Rev1
8+
- component: Board:Test

tools/projmgr/test/data/TestSolution/ConfigFilesUpdate/config.cproject.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ project:
44

55
components:
66
- component: RteTest:CORE
7-
- component: Device:Startup
7+
- component: Device:Startup&RteTest Startup
88

99
rte:
1010
base-dir: $BuildType$

tools/projmgr/test/data/TestSolution/Executes/project/project.cproject.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ project:
44

55
components:
66
- component: ARM::RteTest:CORE
7-
- component: ARM::Device:Startup
7+
- component: ARM::Device:Startup&RteTest Startup
88

99
groups:
1010
- group: Source

tools/projmgr/test/data/TestSolution/Instances/instances.cproject.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ project:
77
instances: 2
88
for-context: .Debug
99

10-
- component: Device:Startup
10+
- component: Device:Startup&RteTest Startup
1111
instances: 2
1212
for-context: .Error

tools/projmgr/test/data/TestSolution/LinkerOptions/layer/linker.clayer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ layer:
44

55
components:
66
- component: Board:Test:Rev1
7-
- component: Device:Startup
7+
- component: Device:Startup&RteTest Startup
88
for-context: [.PriorityRegions, .PriorityDefines]
99
- component: RteTest:CORE
1010
for-context: [.PriorityRegions, .PriorityDefines]

0 commit comments

Comments
 (0)