Skip to content

Commit f48922b

Browse files
Fixed checks for mounted / compatible device (#1152)
* Fixed checks for mounted / compatible device * Fixed checks - check for wildcards in Dname: *?[] - check for include paths on category="header"
1 parent 7cdea30 commit f48922b

File tree

8 files changed

+38
-7
lines changed

8 files changed

+38
-7
lines changed

tools/packchk/src/PackChk_Msgs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const MsgTable PackChk::msgTable = {
132132
{ "M316", { MsgLevel::LEVEL_WARNING, CRLF_B, "URL must end with slash '/': '%URL%'" } },
133133
{ "M317", { MsgLevel::LEVEL_WARNING, CRLF_B, "Condition '%NAME%': No component found for '%NAME2%'" } },
134134
{ "M318", { MsgLevel::LEVEL_WARNING, CRLF_B, "Attribute '%TAG%' must not have '%TAG2%'" } },
135-
{ "M319", { MsgLevel::LEVEL_ERROR, CRLF_B, "'%TAG%' already defined for '%TAG2%'" } },
135+
{ "M319", { MsgLevel::LEVEL_ERROR, CRLF_B, "'%TAG%': '%NAME%' already defined for '%TAG2%': '%NAME2%', see Line %LINE%" } },
136136
{ "M320", { MsgLevel::LEVEL_ERROR, CRLF_B, "" } },
137137
{ "M321", { MsgLevel::LEVEL_ERROR, CRLF_B, "DS5 project requires '.project' file." } },
138138
{ "M322", { MsgLevel::LEVEL_ERROR, CRLF_B, "Associated File/Path not found: '%PATH%'" } },
@@ -239,7 +239,7 @@ const MsgTable PackChk::msgTable = {
239239
{ "M604", { MsgLevel::LEVEL_WARNING, CRLF_B, "Currently no Dcore feature check for '%NAME%'" } },
240240
{ "M605", { MsgLevel::LEVEL_WARNING, CRLF_B, "Required Dcore '%NAME%' feature '%NAME2%' not defined" } },
241241
{ "M606", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
242-
{ "M607", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
242+
{ "M607", { MsgLevel::LEVEL_WARNING, CRLF_B, "Tag '%TAG%' does not allow wildcard specification: '%NAME%'" } },
243243
{ "M608", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
244244
{ "M609", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
245245
{ "M610", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },

tools/packchk/src/ValidateSemantic.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ bool ValidateSemantic::UpdateRte(RteTarget* target, RteProject* rteProject, RteC
364364
RteComponentAggregate* cmsisComp = target->GetComponentAggregate("ARM::CMSIS.CORE");
365365
target->SelectComponent(cmsisComp, 1, true);
366366
target->SelectComponent(component, 1, true, true);
367-
rteProject->CollectSettings();
367+
rteProject->Apply();
368368
target->CollectFilteredFiles();
369369
target->EvaluateComponentDependencies();
370370

@@ -740,6 +740,23 @@ bool ValidateSemantic::CheckDeviceDependencies(RteDeviceItem *device, RteProject
740740
}
741741
}
742742
}
743+
744+
if(category == "header") {
745+
string fileName = RteUtils::BackSlashesToSlashes(RteUtils::ExtractFileName(file->GetName()));
746+
if(fileName.empty()) {
747+
continue;
748+
}
749+
const string& attribute = file->GetAttribute("attr");
750+
751+
if(attribute == "config") {
752+
const string& fullFileName = targetPath + "/" + file->GetName();
753+
const string hPath = RteUtils::ExtractFilePath(fullFileName, false);
754+
const auto incPathFound = incPaths.find(hPath);
755+
if(incPathFound != incPaths.end()) {
756+
LogMsg("M357", NAME(file->GetName()), file->GetLineNumber());
757+
}
758+
}
759+
}
743760
}
744761
}
745762

tools/packchk/src/ValidateSyntax.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ bool ValidateSyntax::CheckBoards(RtePackage* pKg)
17061706
auto foundDevIdxIt = mountedDeviceIndex.find(devIdx);
17071707
if(foundDevIdxIt != mountedDeviceIndex.end()) {
17081708
const RteItem* foundDev = foundDevIdxIt->second;
1709-
LogMsg("M319", TAG("deviceIndex"), TAG2(foundDev->GetDeviceName()));
1709+
LogMsg("M319", TAG("deviceIndex"), NAME(devIdx), TAG2("Dname"), NAME2(foundDev->GetDeviceName()), LINE(foundDev->GetLineNumber()), lineNo);
17101710
}
17111711
else {
17121712
mountedDeviceIndex[devIdx] = mountedDevice;
@@ -1728,6 +1728,11 @@ bool ValidateSyntax::CheckBoards(RtePackage* pKg)
17281728
continue;
17291729
}
17301730

1731+
if(dname.find_first_of("*?[]") != string::npos) {
1732+
LogMsg("M607", TAG("Dname"), NAME(dname), lineNo);
1733+
continue;
1734+
}
1735+
17311736
list<RteDevice*> devices;
17321737
GetModel().GetDevices(devices, dname, dvendor);
17331738
if(devices.empty()) {

tools/packchk/test/data/CheckBoardMountedCompatibleDevices/BulbBoard_BSP/Keil.BulbBoard_BSP.pdsc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<mountedDevice deviceIndex="3" Dvendor="Cypress:19"/>
4242
<mountedDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A12B0B"/>
4343
<mountedDevice deviceIndex="2" Dvendor="Cypress:19" Dname="S6E1A12B0C"/>
44+
<mountedDevice deviceIndex="4" Dvendor="ARM:82" Dname="ARMCM*"/>
4445
<compatibleDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A12C0A" Dfamily="Foo" DsubFamily="Bar"/>
4546
<compatibleDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A11B0A"/>
4647
<compatibleDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A11C0A"/>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//header 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//header 1

tools/packchk/test/data/ConfigFileInIncludePath/TestVendor.ConfigFileInIncludePathPack.pdsc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ The TestSubFamily is ...
5959
<files>
6060
<file category="include" name="Files/"/>
6161
<file category="source" name="Files/header1.h" attr="config" version="1.0.0" condition="Test ARMCC"/>
62+
<file category="header" name="Header/header1.h" version="1.0.0" condition="Test ARMCC"/>
63+
<file category="header" name="Header/header2.h" attr="config" version="1.0.0" condition="Test ARMCC"/>
6264
</files>
6365
</component>
6466
</components>

tools/packchk/test/integtests/src/PackChkIntegTests.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ TEST_F(PackChkIntegTests, CheckConfigFileInIncludePath) {
863863
}
864864
}
865865

866-
if (!M357_foundCnt) {
866+
if (M357_foundCnt != 2) {
867867
FAIL() << "error: missing message M357";
868868
}
869869
}
@@ -967,6 +967,7 @@ TEST_F(PackChkIntegTests, CheckBoardMountedCompatibleDevices) {
967967
int M318_foundCnt = 0;
968968
int M319_foundCnt = 0;
969969
int M346_foundCnt = 0;
970+
int M607_foundCnt = 0;
970971
for (const string& msg : errMsgs) {
971972
size_t s;
972973
if ((s = msg.find("M308")) != string::npos) {
@@ -981,10 +982,13 @@ TEST_F(PackChkIntegTests, CheckBoardMountedCompatibleDevices) {
981982
if ((s = msg.find("M346")) != string::npos) {
982983
M346_foundCnt++;
983984
}
985+
if ((s = msg.find("M607")) != string::npos) {
986+
M607_foundCnt++;
987+
}
984988
}
985989

986-
if (M308_foundCnt != 2 || M318_foundCnt != 2 || M319_foundCnt != 2 || M346_foundCnt != 3) {
987-
FAIL() << "error: missing message M308, M318, M319, M346";
990+
if (M308_foundCnt != 2 || M318_foundCnt != 2 || M319_foundCnt != 2 || M346_foundCnt != 3 || M607_foundCnt != 1) {
991+
FAIL() << "error: missing message(s) on check mounted and compatible devices";
988992
}
989993
}
990994

0 commit comments

Comments
 (0)