]>
Commit | Line | Data |
---|---|---|
e8a47801 LG |
1 | ## @file\r |
2 | # This file is used to check format of comments\r | |
3 | #\r | |
4 | # Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r | |
2e351cbe | 5 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
e8a47801 LG |
6 | #\r |
7 | \r | |
8 | from CommonDataClass.DataClass import (\r | |
9 | MODEL_PCD_PATCHABLE_IN_MODULE,\r | |
10 | MODEL_PCD_DYNAMIC_EX,\r | |
11 | MODEL_PCD_DYNAMIC,\r | |
12 | MODEL_EFI_GUID,\r | |
13 | MODEL_EFI_PPI,\r | |
14 | MODEL_EFI_PROTOCOL\r | |
15 | )\r | |
16 | from Common.BuildToolError import FORMAT_INVALID\r | |
17 | import Common.EdkLogger as EdkLogger\r | |
18 | \r | |
19 | UsageList = ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES", "ALWAYS_PRODUCED", "SOMETIMES_PRODUCES",\r | |
20 | "SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUMES", "ALWAYS_CONSUMED",\r | |
21 | "SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUMES")\r | |
97fa0ee9 YL |
22 | ErrorMsgMap = {\r |
23 | MODEL_EFI_GUID : "The usage for this GUID is not listed in this INF: %s[%d]:%s",\r | |
24 | MODEL_EFI_PPI : "The usage for this PPI is not listed in this INF: %s[%d]:%s.",\r | |
25 | MODEL_EFI_PROTOCOL : "The usage for this Protocol is not listed in this INF: %s[%d]:%s.",\r | |
26 | MODEL_PCD_DYNAMIC : "The usage for this PCD is not listed in this INF: %s[%d]:%s."\r | |
27 | }\r | |
e8a47801 | 28 | \r |
97fa0ee9 YL |
29 | def CheckInfComment(SectionType, Comments, InfFile, LineNo, ValueList):\r |
30 | if SectionType in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_EX, MODEL_PCD_DYNAMIC]:\r | |
31 | CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0]+'.'+ValueList[1], ErrorMsgMap[MODEL_PCD_DYNAMIC])\r | |
32 | elif SectionType in [MODEL_EFI_GUID, MODEL_EFI_PPI]:\r | |
33 | CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType])\r | |
34 | elif SectionType == MODEL_EFI_PROTOCOL:\r | |
35 | CheckUsage(Comments, UsageList + ("TO_START", "BY_START"), InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType])\r | |
36 | \r | |
37 | def CheckUsage(Comments, Usages, InfFile, LineNo, Value, ErrorMsg):\r | |
38 | for Comment in Comments:\r | |
39 | for Word in Comment[0].replace('#', ' ').split():\r | |
40 | if Word in Usages:\r | |
41 | return\r | |
42 | EdkLogger.error(\r | |
43 | "Parser", FORMAT_INVALID,\r | |
44 | ErrorMsg % (InfFile, LineNo, Value)\r | |
45 | )\r |