Skip to content

Commit c779cb3

Browse files
authored
[projmgr] Improve duplicate components in cproject/clayer.yml
1 parent 214348b commit c779cb3

7 files changed

Lines changed: 67 additions & 2 deletions

File tree

tools/projmgr/schemas/common.schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,6 @@
10061006
"title": "components:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#components",
10071007
"type": "array",
10081008
"description": "List of software components that are added from packs. Can be applied in *.cproject.yml and *.clayer.yml files.",
1009-
"uniqueItems": true,
10101009
"minItems": 1,
10111010
"items": { "$ref": "#/definitions/ComponentType" }
10121011
},

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3757,7 +3757,7 @@ bool ProjMgrWorker::AddComponent(const ComponentItem& src, const string& layer,
37573757
if (CheckContextFilters(src.type, context)) {
37583758
for (auto& [dstNode, layer] : dst) {
37593759
if (dstNode.component == src.component) {
3760-
ProjMgrLogger::Get().Error("conflict: component '" + dstNode.component + "' is declared multiple times", context.name);
3760+
ProjMgrLogger::Get().Error("conflict: component '" + dstNode.component + "' is listed multiple times", context.name);
37613761
return false;
37623762
}
37633763
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
layer:
2+
components:
3+
- component: RteTest:CORE
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
project:
2+
components:
3+
- component: Startup
4+
- component: RteTest:CORE
5+
layers:
6+
- layer: ./duplicateComponents.clayer.yml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project:
2+
components:
3+
- component: Startup
4+
- component: RteTest:CORE
5+
- component: RteTest:CORE
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
solution:
2+
target-types:
3+
- type: CM0
4+
device: RteTest_ARMCM0
5+
6+
build-types:
7+
- type: Debug
8+
compiler: AC6
9+
10+
packs:
11+
- pack: ARM::RteTest
12+
- pack: ARM::RteTest_DFP
13+
14+
projects:
15+
- project: ./Cproject/duplicateComponents_cproject.cproject.yml
16+
- project: ./Clayer/duplicateComponents_clayer.cproject.yml

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7384,3 +7384,39 @@ TEST_F(ProjMgrUnitTests, TargetSetDependencies) {
73847384
EXPECT_FALSE(cbuildIdx["build-idx"]["cbuilds"][0]["depends-on"].IsDefined());
73857385
EXPECT_FALSE(cbuildIdx["build-idx"]["cbuilds"][1]["depends-on"].IsDefined());
73867386
}
7387+
7388+
TEST_F(ProjMgrUnitTests, DuplicateComponents) {
7389+
StdStreamRedirect streamRedirect;
7390+
7391+
const string csolution = testinput_folder + "/TestSolution/DuplicateComponents/duplicateComponents.csolution.yml";
7392+
7393+
char* argv[9];
7394+
argv[1] = (char*)"convert";
7395+
argv[2] = (char*)"--solution";
7396+
argv[3] = (char*)csolution.c_str();
7397+
argv[4] = (char*)"-o";
7398+
argv[5] = (char*)testoutput_folder.c_str();
7399+
argv[6] = (char*)"--context";
7400+
argv[7] = (char*)"duplicateComponents_cproject";
7401+
argv[8] = (char*)"--no-check-schema";
7402+
7403+
EXPECT_EQ(1, RunProjMgr(8, argv, m_envp));
7404+
auto errStr = streamRedirect.GetErrorString();
7405+
EXPECT_NE(string::npos, errStr.find("error csolution: conflict: component 'RteTest:CORE' is listed multiple times"));
7406+
7407+
argv[7] = (char*)"duplicateComponents_clayer";
7408+
EXPECT_EQ(1, RunProjMgr(8, argv, m_envp));
7409+
errStr = streamRedirect.GetErrorString();
7410+
EXPECT_NE(string::npos, errStr.find("error csolution: conflict: component 'RteTest:CORE' is listed multiple times"));
7411+
7412+
// Run with "--no-check-schema"
7413+
argv[7] = (char*)"duplicateComponents_cproject";
7414+
EXPECT_EQ(1, RunProjMgr(9, argv, m_envp));
7415+
errStr = streamRedirect.GetErrorString();
7416+
EXPECT_NE(string::npos, errStr.find("error csolution: conflict: component 'RteTest:CORE' is listed multiple times"));
7417+
7418+
argv[7] = (char*)"duplicateComponents_clayer";
7419+
EXPECT_EQ(1, RunProjMgr(9, argv, m_envp));
7420+
errStr = streamRedirect.GetErrorString();
7421+
EXPECT_NE(string::npos, errStr.find("error csolution: conflict: component 'RteTest:CORE' is listed multiple times"));
7422+
}

0 commit comments

Comments
 (0)