]>
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 | |
5 | # This program and the accompanying materials\r | |
6 | # are licensed and made available under the terms and conditions of the BSD License\r | |
7 | # which accompanies this distribution. The full text of the license may be found at\r | |
8 | # http://opensource.org/licenses/bsd-license.php\r | |
9 | #\r | |
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | #\r | |
13 | \r | |
14 | from CommonDataClass.DataClass import (\r | |
15 | MODEL_PCD_PATCHABLE_IN_MODULE,\r | |
16 | MODEL_PCD_DYNAMIC_EX,\r | |
17 | MODEL_PCD_DYNAMIC,\r | |
18 | MODEL_EFI_GUID,\r | |
19 | MODEL_EFI_PPI,\r | |
20 | MODEL_EFI_PROTOCOL\r | |
21 | )\r | |
22 | from Common.BuildToolError import FORMAT_INVALID\r | |
23 | import Common.EdkLogger as EdkLogger\r | |
24 | \r | |
25 | UsageList = ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES", "ALWAYS_PRODUCED", "SOMETIMES_PRODUCES",\r | |
26 | "SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUMES", "ALWAYS_CONSUMED",\r | |
27 | "SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUMES")\r | |
97fa0ee9 YL |
28 | ErrorMsgMap = {\r |
29 | MODEL_EFI_GUID : "The usage for this GUID is not listed in this INF: %s[%d]:%s",\r | |
30 | MODEL_EFI_PPI : "The usage for this PPI is not listed in this INF: %s[%d]:%s.",\r | |
31 | MODEL_EFI_PROTOCOL : "The usage for this Protocol is not listed in this INF: %s[%d]:%s.",\r | |
32 | MODEL_PCD_DYNAMIC : "The usage for this PCD is not listed in this INF: %s[%d]:%s."\r | |
33 | }\r | |
e8a47801 | 34 | \r |
97fa0ee9 YL |
35 | def CheckInfComment(SectionType, Comments, InfFile, LineNo, ValueList):\r |
36 | if SectionType in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_EX, MODEL_PCD_DYNAMIC]:\r | |
37 | CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0]+'.'+ValueList[1], ErrorMsgMap[MODEL_PCD_DYNAMIC])\r | |
38 | elif SectionType in [MODEL_EFI_GUID, MODEL_EFI_PPI]:\r | |
39 | CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType])\r | |
40 | elif SectionType == MODEL_EFI_PROTOCOL:\r | |
41 | CheckUsage(Comments, UsageList + ("TO_START", "BY_START"), InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType])\r | |
42 | \r | |
43 | def CheckUsage(Comments, Usages, InfFile, LineNo, Value, ErrorMsg):\r | |
44 | for Comment in Comments:\r | |
45 | for Word in Comment[0].replace('#', ' ').split():\r | |
46 | if Word in Usages:\r | |
47 | return\r | |
48 | EdkLogger.error(\r | |
49 | "Parser", FORMAT_INVALID,\r | |
50 | ErrorMsg % (InfFile, LineNo, Value)\r | |
51 | )\r |