Skip to content

Commit a90309c

Browse files
authored
[projmgr] Add board's pack and identifier info into generated CPRJ
1 parent a7657a7 commit a90309c

File tree

8 files changed

+228
-1
lines changed

8 files changed

+228
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<package schemaVersion="1.3" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="PACK.xsd">
4+
<name>RteTestBoard</name>
5+
<description>Testing packages listing</description>
6+
<vendor>ARM</vendor>
7+
8+
<releases>
9+
<release version="0.1.0" date="2022-03-11">
10+
Initial version
11+
</release>
12+
</releases>
13+
14+
<requirements>
15+
<packages>
16+
<package vendor="ARM" name="RteTest_DFP" version="0.1.1:0.2.0"/>
17+
</packages>
18+
</requirements>
19+
20+
<boards>
21+
<board name="RteTest board listing" vendor="Keil" revision="Rev.C">
22+
<description>uVision Simulator</description>
23+
<mountedDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM0"/>
24+
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM3"/>
25+
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM4_NOFP"/>
26+
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM4_FP"/>
27+
</board>
28+
</boards>
29+
30+
</package>

tools/projmgr/src/ProjMgrGenerator.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void ProjMgrGenerator::GenerateCprjCompilers(XMLTreeElement* element, const Tool
133133
}
134134

135135
void ProjMgrGenerator::GenerateCprjTarget(XMLTreeElement* element, const ContextItem& context) {
136-
static constexpr const char* DEVICE_ATTRIBUTES[] = { "Ddsp", "Dendian", "Dfpu", "Dmve", "Dname", "Pname", "Dsecure", "Dtz", "Dvendor" };
136+
constexpr const char* DEVICE_ATTRIBUTES[] = { "Ddsp", "Dendian", "Dfpu", "Dmve", "Dname", "Pname", "Dsecure", "Dtz", "Dvendor" };
137137
map<string, string> attributes = context.targetAttributes;
138138
if (attributes["Dendian"] == "Configurable") {
139139
attributes["Dendian"].erase();
@@ -143,6 +143,13 @@ void ProjMgrGenerator::GenerateCprjTarget(XMLTreeElement* element, const Context
143143
SetAttribute(element, name, value);
144144
}
145145

146+
// board attributes
147+
constexpr const char* BOARD_ATTRIBUTES[] = { "Bvendor", "Bname", "Bversion" };
148+
for (const auto& name : BOARD_ATTRIBUTES) {
149+
const string& value = attributes[name];
150+
SetAttribute(element, name, value);
151+
}
152+
146153
XMLTreeElement* targetOutputElement = element->CreateElement("output");
147154
if (targetOutputElement) {
148155
targetOutputElement->AddAttribute("name", context.name);

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ bool ProjMgrWorker::ProcessDevice(ContextItem& context) {
337337
if (board && (board->GetName() == boardItem.name)) {
338338
if (boardItem.vendor.empty() || (boardItem.vendor == DeviceVendor::GetCanonicalVendorName(board->GetVendorName()))) {
339339
matchedBoard = board;
340+
const auto& boardPackage = matchedBoard->GetPackage();
341+
context.packages.insert({ ProjMgrUtils::GetPackageID(boardPackage), boardPackage });
342+
context.targetAttributes["Bname"] = matchedBoard->GetName();
343+
context.targetAttributes["Bvendor"] = matchedBoard->GetVendorName();
344+
context.targetAttributes["Bversion"] = matchedBoard->GetAttribute("revision");
340345
break;
341346
}
342347
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2+
<cprj schemaVersion="1.7.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PACK.xsd">
3+
<created timestamp="2022-03-11T12:20:40" tool="csolution 0.0.0+ga1d985c"/>
4+
5+
<info isLayer="false">
6+
<description>Automatically generated project</description>
7+
</info>
8+
9+
<packages>
10+
<package name="RteTest_DFP" vendor="ARM" version="0.2.0"/>
11+
</packages>
12+
13+
<compilers>
14+
<compiler name="AC6" version="6.16.0"/>
15+
</compilers>
16+
17+
<target Bname="RteTest Test board-3" Bvendor="Keil" Bversion="1.1.1" Dendian="Little-endian" Dfpu="NO_FPU" Dname="RteTest_ARMCM0" Dsecure="Non-secure" Dvendor="ARM:82">
18+
<output intdir="test_IntDir/" name="test" outdir="test_OutDir/" type="exe"/>
19+
<ldflags compiler="AC6" file="RTE/Device/RteTest_ARMCM0/ARMCM0_ac6.sct"/>
20+
</target>
21+
22+
<components>
23+
<component Cclass="Device" Cgroup="Startup" Cvariant="RteTest Startup" Cvendor="ARM" Cversion="2.0.3">
24+
<file attr="config" category="linkerScript" name="Device/ARM/ARMCM0/Source/ARM/ARMCM0_ac6.sct" version="1.0.0"/>
25+
<file attr="config" category="sourceC" name="Device/ARM/ARMCM0/Source/startup_ARMCM0.c" version="2.0.3"/>
26+
<file attr="config" category="sourceC" name="Device/ARM/ARMCM0/Source/system_ARMCM0.c" version="1.0.0"/>
27+
</component>
28+
<component Cclass="RteTest" Cgroup="CORE" Cvendor="ARM" Cversion="0.1.1"/>
29+
</components>
30+
31+
<files>
32+
<group name="Sources">
33+
<file category="sourceC" name="main.c"/>
34+
</group>
35+
</files>
36+
</cprj>
37+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2+
<cprj schemaVersion="1.7.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PACK.xsd">
3+
<created timestamp="2022-03-11T11:50:45" tool="csolution 0.0.0+ga1d985c"/>
4+
5+
<info isLayer="false">
6+
<description>Automatically generated project</description>
7+
</info>
8+
9+
<packages>
10+
<package name="RteTestBoard" vendor="ARM" version="0.1.0"/>
11+
<package name="RteTest_DFP" vendor="ARM" version="0.2.0"/>
12+
</packages>
13+
14+
<compilers>
15+
<compiler name="AC6" version="6.16.0"/>
16+
</compilers>
17+
18+
<target Bname="RteTest board listing" Bvendor="Keil" Bversion="Rev.C" Dendian="Little-endian" Dfpu="NO_FPU" Dname="RteTest_ARMCM0" Dsecure="Non-secure" Dvendor="ARM:82">
19+
<output intdir="test1.Debug+CM0_IntDir/" name="test1.Debug+CM0" outdir="test1.Debug+CM0_OutDir/" type="exe"/>
20+
<ldflags compiler="AC6" file="RTE/Device/RteTest_ARMCM0/ARMCM0_ac6.sct"/>
21+
</target>
22+
23+
<components>
24+
<component Cclass="Device" Cgroup="Startup" Cvariant="RteTest Startup" Cvendor="ARM" Cversion="2.0.3">
25+
<file attr="config" category="linkerScript" name="Device/ARM/ARMCM0/Source/ARM/ARMCM0_ac6.sct" version="1.0.0"/>
26+
<file attr="config" category="sourceC" name="Device/ARM/ARMCM0/Source/startup_ARMCM0.c" version="2.0.3"/>
27+
<file attr="config" category="sourceC" name="Device/ARM/ARMCM0/Source/system_ARMCM0.c" version="1.0.0"/>
28+
</component>
29+
<component Cclass="RteTest" Cgroup="CORE" Cvendor="ARM" Cversion="0.1.1"/>
30+
</components>
31+
32+
<files>
33+
<group name="Sources">
34+
<arflags add="-Lib-group" compiler="AC6"/>
35+
<asflags add="-ASM-group" compiler="AC6"/>
36+
<cflags add="-C-group" compiler="AC6"/>
37+
<cxxflags add="-CPP-group" compiler="AC6"/>
38+
<ldflags add="-Link-group" compiler="AC6"/>
39+
<file category="sourceC" name="main.c">
40+
<arflags add="-Lib-file-AC6" compiler="AC6"/>
41+
<asflags add="-ASM-file-AC6" compiler="AC6"/>
42+
<cflags add="-C-file-AC6" compiler="AC6"/>
43+
<cxxflags add="-CPP-file-AC6" compiler="AC6"/>
44+
<ldflags add="-Link-file-AC6" compiler="AC6"/>
45+
</file>
46+
</group>
47+
<group name="Debug Group">
48+
<file category="sourceC" name="debug.c"/>
49+
</group>
50+
</files>
51+
</cprj>
52+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2+
<cprj schemaVersion="1.7.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PACK.xsd">
3+
<created timestamp="2022-03-11T11:55:01" tool="csolution 0.0.0+ga1d985c"/>
4+
5+
<info isLayer="false">
6+
<description>Automatically generated project</description>
7+
</info>
8+
9+
<packages>
10+
<package name="RteTestBoard" vendor="ARM" version="0.1.0"/>
11+
<package name="RteTest_DFP" vendor="ARM" version="0.2.0"/>
12+
</packages>
13+
14+
<compilers>
15+
<compiler name="GCC" version="10.2.1"/>
16+
</compilers>
17+
18+
<target Bname="RteTest board listing" Bvendor="Keil" Bversion="Rev.C" Dendian="Little-endian" Dfpu="NO_FPU" Dname="RteTest_ARMCM0" Dsecure="Non-secure" Dvendor="ARM:82">
19+
<output intdir="test1.Release+CM0_IntDir/" name="test1.Release+CM0" outdir="test1.Release+CM0_OutDir/" type="exe"/>
20+
<ldflags compiler="GCC" file="RTE/Device/RteTest_ARMCM0/gcc_arm.ld"/>
21+
</target>
22+
23+
<components>
24+
<component Cclass="Device" Cgroup="Startup" Cvariant="RteTest Startup" Cvendor="ARM" Cversion="2.0.3">
25+
<file attr="config" category="linkerScript" name="Device/ARM/ARMCM0/Source/GCC/gcc_arm.ld" version="2.0.0"/>
26+
<file attr="config" category="sourceC" name="Device/ARM/ARMCM0/Source/startup_ARMCM0.c" version="2.0.3"/>
27+
<file attr="config" category="sourceC" name="Device/ARM/ARMCM0/Source/system_ARMCM0.c" version="1.0.0"/>
28+
</component>
29+
<component Cclass="RteTest" Cgroup="CORE" Cvendor="ARM" Cversion="0.1.1"/>
30+
</components>
31+
32+
<files>
33+
<group name="Sources">
34+
<arflags add="-Lib-group" compiler="GCC"/>
35+
<asflags add="-ASM-group" compiler="GCC"/>
36+
<cflags add="-C-group" compiler="GCC"/>
37+
<cxxflags add="-CPP-group" compiler="GCC"/>
38+
<ldflags add="-Link-group" compiler="GCC"/>
39+
<file category="sourceC" name="main.c">
40+
<arflags add="-Lib-file-GCC" compiler="GCC"/>
41+
<asflags add="-ASM-file-GCC" compiler="GCC"/>
42+
<cflags add="-C-file-GCC" compiler="GCC"/>
43+
<cxxflags add="-CPP-file-GCC" compiler="GCC"/>
44+
<ldflags add="-Link-file-GCC" compiler="GCC"/>
45+
</file>
46+
</group>
47+
<group name="Release Group">
48+
<file category="sourceC" name="release.c"/>
49+
</group>
50+
</files>
51+
</cprj>
52+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/0.9.1/tools/projmgr/schemas/csolution.schema.json
2+
3+
solution:
4+
target-types:
5+
- type: CM0
6+
board: RteTest board listing
7+
8+
build-types:
9+
- type: Debug
10+
compiler: AC6
11+
optimize: debug
12+
debug: on
13+
- type: Release
14+
compiler: GCC
15+
optimize: max
16+
debug: off
17+
18+
projects:
19+
- project: ./TestProject1/test1.cproject.yml
20+

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ TEST_F(ProjMgrUnitTests, RunProjMgr_Generator) {
448448
TEST_F(ProjMgrUnitTests, ListPacks) {
449449
set<string> expected = {
450450
"ARM::RteTest@0.1.0",
451+
"ARM::RteTestBoard@0.1.0",
451452
"ARM::RteTestGenerator@0.1.0",
452453
"ARM::RteTest_DFP@0.1.1",
453454
"ARM::RteTest_DFP@0.2.0"
@@ -730,6 +731,10 @@ TEST_F(ProjMgrUnitTests, RunProjMgr_Only_Board_Info) {
730731
argv[4] = (char*)"-o";
731732
argv[5] = (char*)testoutput_folder.c_str();
732733
EXPECT_EQ(0, RunProjMgr(6, argv));
734+
735+
// Check generated CPRJ
736+
CompareFile(testoutput_folder + "/test/test.cprj",
737+
testinput_folder + "/TestProject/test_only_board.cprj");
733738
}
734739

735740
TEST_F(ProjMgrUnitTests, RunProjMgr_Only_Board_No_Pname) {
@@ -1293,3 +1298,22 @@ TEST_F(ProjMgrUnitTests, RunProjMgrSolution_Local_Pack_File_Not_Found) {
12931298
auto errStr = streamRedirect.GetErrorString();
12941299
EXPECT_NE(string::npos, errStr.find(errExpected));
12951300
}
1301+
1302+
TEST_F(ProjMgrUnitTests, RunProjMgrSolution_List_Board_Pack) {
1303+
char* argv[7];
1304+
const string& csolution = testinput_folder + "/TestSolution/test.csolution_list_board_package.yml";
1305+
1306+
// convert -s solution.yml
1307+
argv[1] = (char*)"convert";
1308+
argv[2] = (char*)"-s";
1309+
argv[3] = (char*)csolution.c_str();
1310+
argv[4] = (char*)"-o";
1311+
argv[5] = (char*)testoutput_folder.c_str();
1312+
EXPECT_EQ(0, RunProjMgr(6, argv));
1313+
1314+
// Check generated CPRJs
1315+
CompareFile(testoutput_folder + "/test1.Debug+CM0/test1.Debug+CM0.cprj",
1316+
testinput_folder + "/TestSolution/TestProject1/test1.Debug+CM0_board_package.cprj");
1317+
CompareFile(testoutput_folder + "/test1.Release+CM0/test1.Release+CM0.cprj",
1318+
testinput_folder + "/TestSolution/TestProject1/test1.Release+CM0_board_package.cprj");
1319+
}

0 commit comments

Comments
 (0)