]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Ecc/Configuration.py
BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions.
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / Configuration.py
CommitLineData
30fdf114
LG
1## @file\r
2# This file is used to define class Configuration\r
3#\r
a4c35ded 4# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
40d841f6 5# This program and the accompanying materials\r
30fdf114
LG
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##\r
15# Import Modules\r
16#\r
72443dd2 17from __future__ import print_function\r
1be2ed90 18import Common.LongFilePathOs as os\r
30fdf114
LG
19import Common.EdkLogger as EdkLogger\r
20from Common.DataType import *\r
5a57246e 21from Common.StringUtils import *\r
1be2ed90 22from Common.LongFilePathSupport import OpenLongFilePath as open\r
30fdf114 23\r
a4c35ded
CJ
24_ConfigFileToInternalTranslation = {\r
25 # not same\r
26 "ModifierList":"ModifierSet",\r
27\r
28 # same\r
29 # please keep this in correct alphabetical order.\r
30 "AutoCorrect":"AutoCorrect",\r
31 "BinaryExtList":"BinaryExtList",\r
32 "CFunctionLayoutCheckAll":"CFunctionLayoutCheckAll",\r
33 "CFunctionLayoutCheckDataDeclaration":"CFunctionLayoutCheckDataDeclaration",\r
34 "CFunctionLayoutCheckFunctionBody":"CFunctionLayoutCheckFunctionBody",\r
35 "CFunctionLayoutCheckFunctionName":"CFunctionLayoutCheckFunctionName",\r
36 "CFunctionLayoutCheckFunctionPrototype":"CFunctionLayoutCheckFunctionPrototype",\r
33a211d0 37 "CFunctionLayoutCheckNoDeprecated":"CFunctionLayoutCheckNoDeprecated",\r
a4c35ded
CJ
38 "CFunctionLayoutCheckNoInitOfVariable":"CFunctionLayoutCheckNoInitOfVariable",\r
39 "CFunctionLayoutCheckNoStatic":"CFunctionLayoutCheckNoStatic",\r
40 "CFunctionLayoutCheckOptionalFunctionalModifier":"CFunctionLayoutCheckOptionalFunctionalModifier",\r
41 "CFunctionLayoutCheckReturnType":"CFunctionLayoutCheckReturnType",\r
42 "CheckAll":"CheckAll",\r
43 "Copyright":"Copyright",\r
44 "DeclarationDataTypeCheckAll":"DeclarationDataTypeCheckAll",\r
45 "DeclarationDataTypeCheckEFIAPIModifier":"DeclarationDataTypeCheckEFIAPIModifier",\r
46 "DeclarationDataTypeCheckEnumeratedType":"DeclarationDataTypeCheckEnumeratedType",\r
47 "DeclarationDataTypeCheckInOutModifier":"DeclarationDataTypeCheckInOutModifier",\r
48 "DeclarationDataTypeCheckNoUseCType":"DeclarationDataTypeCheckNoUseCType",\r
49 "DeclarationDataTypeCheckSameStructure":"DeclarationDataTypeCheckSameStructure",\r
50 "DeclarationDataTypeCheckStructureDeclaration":"DeclarationDataTypeCheckStructureDeclaration",\r
51 "DeclarationDataTypeCheckUnionType":"DeclarationDataTypeCheckUnionType",\r
52 "DoxygenCheckAll":"DoxygenCheckAll",\r
53 "DoxygenCheckCommand":"DoxygenCheckCommand",\r
54 "DoxygenCheckCommentDescription":"DoxygenCheckCommentDescription",\r
55 "DoxygenCheckCommentFormat":"DoxygenCheckCommentFormat",\r
56 "DoxygenCheckFileHeader":"DoxygenCheckFileHeader",\r
57 "DoxygenCheckFunctionHeader":"DoxygenCheckFunctionHeader",\r
58 "GeneralCheckAll":"GeneralCheckAll",\r
59 "GeneralCheckCarriageReturn":"GeneralCheckCarriageReturn",\r
60 "GeneralCheckFileExistence":"GeneralCheckFileExistence",\r
61 "GeneralCheckIndentation":"GeneralCheckIndentation",\r
62 "GeneralCheckIndentationWidth":"GeneralCheckIndentationWidth",\r
63 "GeneralCheckLine":"GeneralCheckLine",\r
855698fb 64 "GeneralCheckLineEnding":"GeneralCheckLineEnding",\r
a4c35ded
CJ
65 "GeneralCheckLineWidth":"GeneralCheckLineWidth",\r
66 "GeneralCheckNoProgma":"GeneralCheckNoProgma",\r
67 "GeneralCheckNoTab":"GeneralCheckNoTab",\r
68 "GeneralCheckNo_Asm":"GeneralCheckNo_Asm",\r
69 "GeneralCheckNonAcsii":"GeneralCheckNonAcsii",\r
70 "GeneralCheckTabWidth":"GeneralCheckTabWidth",\r
855698fb 71 "GeneralCheckTrailingWhiteSpaceLine":"GeneralCheckTrailingWhiteSpaceLine",\r
a4c35ded
CJ
72 "GeneralCheckUni":"GeneralCheckUni",\r
73 "HeaderCheckAll":"HeaderCheckAll",\r
74 "HeaderCheckCFileCommentLicenseFormat":"HeaderCheckCFileCommentLicenseFormat",\r
75 "HeaderCheckCFileCommentReferenceFormat":"HeaderCheckCFileCommentReferenceFormat",\r
76 "HeaderCheckCFileCommentStartSpacesNum":"HeaderCheckCFileCommentStartSpacesNum",\r
77 "HeaderCheckFile":"HeaderCheckFile",\r
78 "HeaderCheckFileCommentEnd":"HeaderCheckFileCommentEnd",\r
79 "HeaderCheckFunction":"HeaderCheckFunction",\r
80 "IncludeFileCheckAll":"IncludeFileCheckAll",\r
81 "IncludeFileCheckData":"IncludeFileCheckData",\r
82 "IncludeFileCheckIfndefStatement":"IncludeFileCheckIfndefStatement",\r
83 "IncludeFileCheckSameName":"IncludeFileCheckSameName",\r
84 "MetaDataFileCheckAll":"MetaDataFileCheckAll",\r
85 "MetaDataFileCheckBinaryInfInFdf":"MetaDataFileCheckBinaryInfInFdf",\r
86 "MetaDataFileCheckGenerateFileList":"MetaDataFileCheckGenerateFileList",\r
87 "MetaDataFileCheckGuidDuplicate":"MetaDataFileCheckGuidDuplicate",\r
88 "MetaDataFileCheckLibraryDefinedInDec":"MetaDataFileCheckLibraryDefinedInDec",\r
89 "MetaDataFileCheckLibraryInstance":"MetaDataFileCheckLibraryInstance",\r
90 "MetaDataFileCheckLibraryInstanceDependent":"MetaDataFileCheckLibraryInstanceDependent",\r
91 "MetaDataFileCheckLibraryInstanceOrder":"MetaDataFileCheckLibraryInstanceOrder",\r
92 "MetaDataFileCheckLibraryNoUse":"MetaDataFileCheckLibraryNoUse",\r
93 "MetaDataFileCheckModuleFileGuidDuplication":"MetaDataFileCheckModuleFileGuidDuplication",\r
94 "MetaDataFileCheckModuleFileGuidFormat":"MetaDataFileCheckModuleFileGuidFormat",\r
95 "MetaDataFileCheckModuleFileNoUse":"MetaDataFileCheckModuleFileNoUse",\r
96 "MetaDataFileCheckModuleFilePcdFormat":"MetaDataFileCheckModuleFilePcdFormat",\r
97 "MetaDataFileCheckModuleFilePpiFormat":"MetaDataFileCheckModuleFilePpiFormat",\r
98 "MetaDataFileCheckModuleFileProtocolFormat":"MetaDataFileCheckModuleFileProtocolFormat",\r
99 "MetaDataFileCheckPathName":"MetaDataFileCheckPathName",\r
100 "MetaDataFileCheckPathOfGenerateFileList":"MetaDataFileCheckPathOfGenerateFileList",\r
101 "MetaDataFileCheckPcdDuplicate":"MetaDataFileCheckPcdDuplicate",\r
102 "MetaDataFileCheckPcdFlash":"MetaDataFileCheckPcdFlash",\r
103 "MetaDataFileCheckPcdNoUse":"MetaDataFileCheckPcdNoUse",\r
104 "MetaDataFileCheckPcdType":"MetaDataFileCheckPcdType",\r
105 "NamingConventionCheckAll":"NamingConventionCheckAll",\r
106 "NamingConventionCheckDefineStatement":"NamingConventionCheckDefineStatement",\r
107 "NamingConventionCheckFunctionName":"NamingConventionCheckFunctionName",\r
108 "NamingConventionCheckIfndefStatement":"NamingConventionCheckIfndefStatement",\r
109 "NamingConventionCheckPathName":"NamingConventionCheckPathName",\r
110 "NamingConventionCheckSingleCharacterVariable":"NamingConventionCheckSingleCharacterVariable",\r
111 "NamingConventionCheckTypedefStatement":"NamingConventionCheckTypedefStatement",\r
112 "NamingConventionCheckVariableName":"NamingConventionCheckVariableName",\r
113 "PredicateExpressionCheckAll":"PredicateExpressionCheckAll",\r
114 "PredicateExpressionCheckBooleanValue":"PredicateExpressionCheckBooleanValue",\r
115 "PredicateExpressionCheckComparisonNullType":"PredicateExpressionCheckComparisonNullType",\r
116 "PredicateExpressionCheckNonBooleanOperator":"PredicateExpressionCheckNonBooleanOperator",\r
117 "ScanOnlyDirList":"ScanOnlyDirList",\r
118 "SkipDirList":"SkipDirList",\r
119 "SkipFileList":"SkipFileList",\r
120 "SmmCommParaCheckAll":"SmmCommParaCheckAll",\r
121 "SmmCommParaCheckBufferType":"SmmCommParaCheckBufferType",\r
122 "SpaceCheckAll":"SpaceCheckAll",\r
123 "SpellingCheckAll":"SpellingCheckAll",\r
124 "UniCheckAll":"UniCheckAll",\r
125 "UniCheckHelpInfo":"UniCheckHelpInfo",\r
126 "UniCheckPCDInfo":"UniCheckPCDInfo",\r
127 "Version":"Version"\r
128 }\r
129\r
30fdf114
LG
130## Configuration\r
131#\r
132# This class is used to define all items in configuration file\r
133#\r
134# @param Filename: The name of configuration file, the default is config.ini\r
135#\r
136class Configuration(object):\r
137 def __init__(self, Filename):\r
138 self.Filename = Filename\r
e56468c0 139\r
30fdf114
LG
140 self.Version = 0.1\r
141\r
142 ## Identify to if check all items\r
143 # 1 - Check all items and ignore all other detailed items\r
144 # 0 - Not check all items, the tool will go through all other detailed items to decide to check or not\r
145 #\r
146 self.CheckAll = 0\r
147\r
148 ## Identify to if automatically correct mistakes\r
149 # 1 - Automatically correct\r
150 # 0 - Not automatically correct\r
151 # Only the following check points can be automatically corrected, others not listed below are not supported even it is 1\r
152 #\r
153 # GeneralCheckTab\r
154 # GeneralCheckIndentation\r
155 # GeneralCheckLine\r
156 # GeneralCheckCarriageReturn\r
157 # SpaceCheckAll\r
158 #\r
159 self.AutoCorrect = 0\r
e56468c0 160\r
30fdf114
LG
161 # List customized Modifer here, split with ','\r
162 # Defaultly use the definition in class DataType\r
eece4292 163 self.ModifierSet = MODIFIER_SET\r
e56468c0 164\r
30fdf114
LG
165 ## General Checking\r
166 self.GeneralCheckAll = 0\r
e56468c0 167\r
30fdf114
LG
168 # Check whether NO Tab is used, replaced with spaces\r
169 self.GeneralCheckNoTab = 1\r
170 # The width of Tab\r
171 self.GeneralCheckTabWidth = 2\r
172 # Check whether the indentation is followed coding style\r
173 self.GeneralCheckIndentation = 1\r
174 # The width of indentation\r
175 self.GeneralCheckIndentationWidth = 2\r
176 # Check whether no line is exceeding defined widty\r
177 self.GeneralCheckLine = 1\r
178 # The width of a line\r
179 self.GeneralCheckLineWidth = 120\r
180 # Check whether no use of _asm in the source file\r
181 self.GeneralCheckNo_Asm = 1\r
182 # Check whether no use of "#progma" in source file except "#pragma pack(#)".\r
183 self.GeneralCheckNoProgma = 1\r
184 # Check whether there is a carriage return at the end of the file\r
185 self.GeneralCheckCarriageReturn = 1\r
186 # Check whether the file exists\r
187 self.GeneralCheckFileExistence = 1\r
e56468c0 188 # Check whether file has non ACSII char\r
189 self.GeneralCheckNonAcsii = 1\r
b3d07ff8
HC
190 # Check whether UNI file is valid\r
191 self.GeneralCheckUni = 1\r
a1583a87
HC
192 # Check Only use CRLF (Carriage Return Line Feed) line endings.\r
193 self.GeneralCheckLineEnding = 1\r
194 # Check if there is no trailing white space in one line.\r
195 self.GeneralCheckTrailingWhiteSpaceLine = 1\r
e56468c0 196\r
30fdf114
LG
197 ## Space Checking\r
198 self.SpaceCheckAll = 1\r
e56468c0 199\r
30fdf114
LG
200 ## Predicate Expression Checking\r
201 self.PredicateExpressionCheckAll = 0\r
e56468c0 202\r
30fdf114
LG
203 # Check whether Boolean values, variable type BOOLEAN not use explicit comparisons to TRUE or FALSE\r
204 self.PredicateExpressionCheckBooleanValue = 1\r
e56468c0 205 # Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).\r
30fdf114
LG
206 self.PredicateExpressionCheckNonBooleanOperator = 1\r
207 # Check whether a comparison of any pointer to zero must be done via the NULL type\r
208 self.PredicateExpressionCheckComparisonNullType = 1\r
e56468c0 209\r
30fdf114
LG
210 ## Headers Checking\r
211 self.HeaderCheckAll = 0\r
e56468c0 212\r
30fdf114
LG
213 # Check whether File header exists\r
214 self.HeaderCheckFile = 1\r
215 # Check whether Function header exists\r
216 self.HeaderCheckFunction = 1\r
d0acc87a
LG
217 # Check whether Meta data File header Comment End with '##'\r
218 self.HeaderCheckFileCommentEnd = 1\r
219 # Check whether C File header Comment content start with two spaces\r
220 self.HeaderCheckCFileCommentStartSpacesNum = 1\r
221 # Check whether C File header Comment's each reference at list should begin with a bullet character '-'\r
222 self.HeaderCheckCFileCommentReferenceFormat = 1\r
223 # Check whether C File header Comment have the License immediately after the ""Copyright"" line\r
224 self.HeaderCheckCFileCommentLicenseFormat = 1\r
f7496d71 225\r
30fdf114
LG
226 ## C Function Layout Checking\r
227 self.CFunctionLayoutCheckAll = 0\r
e56468c0 228\r
30fdf114
LG
229 # Check whether return type exists and in the first line\r
230 self.CFunctionLayoutCheckReturnType = 1\r
231 # Check whether any optional functional modifiers exist and next to the return type\r
232 self.CFunctionLayoutCheckOptionalFunctionalModifier = 1\r
233 # Check whether the next line contains the function name, left justified, followed by the beginning of the parameter list\r
234 # Check whether the closing parenthesis is on its own line and also indented two spaces\r
235 self.CFunctionLayoutCheckFunctionName = 1\r
236 # Check whether the function prototypes in include files have the same form as function definitions\r
237 self.CFunctionLayoutCheckFunctionPrototype = 1\r
238 # Check whether the body of a function is contained by open and close braces that must be in the first column\r
239 self.CFunctionLayoutCheckFunctionBody = 1\r
240 # Check whether the data declarations is the first code in a module.\r
241 self.CFunctionLayoutCheckDataDeclaration = 1\r
242 # Check whether no initialization of a variable as part of its declaration\r
243 self.CFunctionLayoutCheckNoInitOfVariable = 1\r
244 # Check whether no use of STATIC for functions\r
245 self.CFunctionLayoutCheckNoStatic = 1\r
33a211d0
HC
246 # Check whether no use of Deprecated functions\r
247 self.CFunctionLayoutCheckNoDeprecated = 1\r
e56468c0 248\r
30fdf114
LG
249 ## Include Files Checking\r
250 self.IncludeFileCheckAll = 0\r
e56468c0 251\r
30fdf114
LG
252 #Check whether having include files with same name\r
253 self.IncludeFileCheckSameName = 1\r
254 # Check whether all include file contents is guarded by a #ifndef statement.\r
255 # the #ifndef must be the first line of code following the file header comment\r
256 # the #endif must appear on the last line in the file\r
257 self.IncludeFileCheckIfndefStatement = 1\r
258 # Check whether include files contain only public or only private data\r
259 # Check whether include files NOT contain code or define data variables\r
260 self.IncludeFileCheckData = 1\r
e56468c0 261\r
30fdf114
LG
262 ## Declarations and Data Types Checking\r
263 self.DeclarationDataTypeCheckAll = 0\r
e56468c0 264\r
30fdf114
LG
265 # Check whether no use of int, unsigned, char, void, static, long in any .c, .h or .asl files.\r
266 self.DeclarationDataTypeCheckNoUseCType = 1\r
267 # Check whether the modifiers IN, OUT, OPTIONAL, and UNALIGNED are used only to qualify arguments to a function and should not appear in a data type declaration\r
268 self.DeclarationDataTypeCheckInOutModifier = 1\r
269 # Check whether the EFIAPI modifier should be used at the entry of drivers, events, and member functions of protocols\r
270 self.DeclarationDataTypeCheckEFIAPIModifier = 1\r
271 # Check whether Enumerated Type has a 'typedef' and the name is capital\r
272 self.DeclarationDataTypeCheckEnumeratedType = 1\r
273 # Check whether Structure Type has a 'typedef' and the name is capital\r
274 self.DeclarationDataTypeCheckStructureDeclaration = 1\r
275 # Check whether having same Structure\r
276 self.DeclarationDataTypeCheckSameStructure = 1\r
277 # Check whether Union Type has a 'typedef' and the name is capital\r
278 self.DeclarationDataTypeCheckUnionType = 1\r
e56468c0 279\r
30fdf114
LG
280 ## Naming Conventions Checking\r
281 self.NamingConventionCheckAll = 0\r
e56468c0 282\r
30fdf114
LG
283 # Check whether only capital letters are used for #define declarations\r
284 self.NamingConventionCheckDefineStatement = 1\r
285 # Check whether only capital letters are used for typedef declarations\r
286 self.NamingConventionCheckTypedefStatement = 1\r
287 # Check whether the #ifndef at the start of an include file uses both prefix and postfix underscore characters, '_'.\r
288 self.NamingConventionCheckIfndefStatement = 1\r
289 # Rule for path name, variable name and function name\r
290 # 1. First character should be upper case\r
291 # 2. Existing lower case in a word\r
292 # 3. No space existence\r
293 # Check whether the path name followed the rule\r
294 self.NamingConventionCheckPathName = 1\r
295 # Check whether the variable name followed the rule\r
296 self.NamingConventionCheckVariableName = 1\r
297 # Check whether the function name followed the rule\r
298 self.NamingConventionCheckFunctionName = 1\r
299 # Check whether NO use short variable name with single character\r
300 self.NamingConventionCheckSingleCharacterVariable = 1\r
e56468c0 301\r
30fdf114
LG
302 ## Doxygen Checking\r
303 self.DoxygenCheckAll = 0\r
e56468c0 304\r
30fdf114
LG
305 # Check whether the file headers are followed Doxygen special documentation blocks in section 2.3.5\r
306 self.DoxygenCheckFileHeader = 1\r
307 # Check whether the function headers are followed Doxygen special documentation blocks in section 2.3.5\r
308 self.DoxygenCheckFunctionHeader = 1\r
e56468c0 309 # Check whether the first line of text in a comment block is a brief description of the element being documented.\r
30fdf114
LG
310 # The brief description must end with a period.\r
311 self.DoxygenCheckCommentDescription = 1\r
312 # Check whether comment lines with '///< ... text ...' format, if it is used, it should be after the code section.\r
313 self.DoxygenCheckCommentFormat = 1\r
314 # Check whether only Doxygen commands allowed to mark the code are @bug and @todo.\r
315 self.DoxygenCheckCommand = 1\r
e56468c0 316\r
30fdf114
LG
317 ## Meta-Data File Processing Checking\r
318 self.MetaDataFileCheckAll = 0\r
e56468c0 319\r
30fdf114
LG
320 # Check whether each file defined in meta-data exists\r
321 self.MetaDataFileCheckPathName = 1\r
322 # Generate a list for all files defined in meta-data files\r
323 self.MetaDataFileCheckGenerateFileList = 1\r
324 # The path of log file\r
325 self.MetaDataFileCheckPathOfGenerateFileList = 'File.log'\r
e56468c0 326 # Check whether all Library Instances defined for a given module (or dependent library instance) match the module's type.\r
327 # Each Library Instance must specify the Supported Module Types in its INF file,\r
30fdf114
LG
328 # and any module specifying the library instance must be one of the supported types.\r
329 self.MetaDataFileCheckLibraryInstance = 1\r
330 # Check whether a Library Instance has been defined for all dependent library classes\r
331 self.MetaDataFileCheckLibraryInstanceDependent = 1\r
332 # Check whether the Library Instances specified by the LibraryClasses sections are listed in order of dependencies\r
333 self.MetaDataFileCheckLibraryInstanceOrder = 1\r
334 # Check whether the unnecessary inclusion of library classes in the INF file\r
335 self.MetaDataFileCheckLibraryNoUse = 1\r
14239f66
HC
336 # Check the header file in Include\Library directory whether be defined in the package DEC file.\r
337 self.MetaDataFileCheckLibraryDefinedInDec = 1\r
30fdf114
LG
338 # Check whether an INF file is specified in the FDF file, but not in the DSC file, then the INF file must be for a Binary module only\r
339 self.MetaDataFileCheckBinaryInfInFdf = 1\r
340 # Not to report error and warning related OS include file such as "windows.h" and "stdio.h"\r
341 # Check whether a PCD is set in a DSC file or the FDF file, but not in both.\r
342 self.MetaDataFileCheckPcdDuplicate = 1\r
343 # Check whether PCD settings in the FDF file can only be related to flash.\r
344 self.MetaDataFileCheckPcdFlash = 1\r
345 # Check whether PCDs used in INF files but not specified in DSC or FDF files\r
346 self.MetaDataFileCheckPcdNoUse = 1\r
347 # Check whether having duplicate guids defined for Guid/Protocol/Ppi\r
348 self.MetaDataFileCheckGuidDuplicate = 1\r
349 # Check whether all files under module directory are described in INF files\r
350 self.MetaDataFileCheckModuleFileNoUse = 1\r
351 # Check whether the PCD is correctly used in C function via its type\r
352 self.MetaDataFileCheckPcdType = 1\r
40d841f6
LG
353 # Check whether there are FILE_GUID duplication among different INF files\r
354 self.MetaDataFileCheckModuleFileGuidDuplication = 1\r
355\r
b3d07ff8
HC
356 # Check Guid Format in INF files\r
357 self.MetaDataFileCheckModuleFileGuidFormat = 1\r
358 # Check Protocol Format in INF files\r
359 self.MetaDataFileCheckModuleFileProtocolFormat = 1\r
360 # Check Ppi Format in INF files\r
361 self.MetaDataFileCheckModuleFilePpiFormat = 1\r
362 # Check Pcd Format in INF files\r
363 self.MetaDataFileCheckModuleFilePcdFormat = 1\r
f7496d71 364\r
1b2467c5
HC
365 # Check UNI file\r
366 self.UniCheckAll = 0\r
367 # Check INF or DEC file whether defined the localized information in the associated UNI file.\r
368 self.UniCheckHelpInfo = 1\r
369 # Check PCD whether defined the prompt, help in the DEC file and localized information in the associated UNI file.\r
370 self.UniCheckPCDInfo = 1\r
b3d07ff8 371\r
703ef6cf
HC
372 # Check SMM communication function parameter\r
373 self.SmmCommParaCheckAll = 0\r
374 # Check if the EFI_SMM_COMMUNICATION_PROTOCOL parameter buffer type is Reserved / ACPI NVS or UEFI RT code/data\r
375 self.SmmCommParaCheckBufferType = -1\r
376\r
30fdf114
LG
377 #\r
378 # The check points in this section are reserved\r
379 #\r
380 # GotoStatementCheckAll = 0\r
381 #\r
382 self.SpellingCheckAll = 0\r
383\r
384 # The directory listed here will not be parsed, split with ','\r
385 self.SkipDirList = []\r
f7496d71 386\r
8c3f9b4e
HC
387 # The file listed here will not be parsed, split with ','\r
388 self.SkipFileList = []\r
30fdf114 389\r
e56468c0 390 # A list for binary file ext name\r
391 self.BinaryExtList = []\r
f7496d71 392\r
e4ac870f
LG
393 # A list for only scanned folders\r
394 self.ScanOnlyDirList = []\r
f7496d71 395\r
d77cc206
HC
396 # A list for Copyright format\r
397 self.Copyright = []\r
e56468c0 398\r
30fdf114 399 self.ParseConfig()\r
e56468c0 400\r
30fdf114
LG
401 def ParseConfig(self):\r
402 Filepath = os.path.normpath(self.Filename)\r
403 if not os.path.isfile(Filepath):\r
404 ErrorMsg = "Can't find configuration file '%s'" % Filepath\r
405 EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, File = Filepath)\r
e56468c0 406\r
30fdf114
LG
407 LineNo = 0\r
408 for Line in open(Filepath, 'r'):\r
409 LineNo = LineNo + 1\r
410 Line = CleanString(Line)\r
411 if Line != '':\r
412 List = GetSplitValueList(Line, TAB_EQUAL_SPLIT)\r
a4c35ded 413 if List[0] not in _ConfigFileToInternalTranslation:\r
30fdf114
LG
414 ErrorMsg = "Invalid configuration option '%s' was found" % List[0]\r
415 EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, File = Filepath, Line = LineNo)\r
a4c35ded 416 assert _ConfigFileToInternalTranslation[List[0]] in self.__dict__\r
30fdf114
LG
417 if List[0] == 'ModifierList':\r
418 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
419 if List[0] == 'MetaDataFileCheckPathOfGenerateFileList' and List[1] == "":\r
420 continue\r
421 if List[0] == 'SkipDirList':\r
422 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
8c3f9b4e
HC
423 if List[0] == 'SkipFileList':\r
424 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
e56468c0 425 if List[0] == 'BinaryExtList':\r
426 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
d77cc206
HC
427 if List[0] == 'Copyright':\r
428 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
a4c35ded 429 self.__dict__[_ConfigFileToInternalTranslation[List[0]]] = List[1]\r
e56468c0 430\r
30fdf114 431 def ShowMe(self):\r
72443dd2 432 print(self.Filename)\r
30fdf114 433 for Key in self.__dict__.keys():\r
72443dd2 434 print(Key, '=', self.__dict__[Key])\r
a4c35ded
CJ
435\r
436#\r
437# test that our dict and out class still match in contents.\r
438#\r
439if __name__ == '__main__':\r
440 myconfig = Configuration("BaseTools\Source\Python\Ecc\config.ini")\r
441 for each in myconfig.__dict__:\r
442 if each == "Filename":\r
443 continue\r
444 assert each in _ConfigFileToInternalTranslation.values()\r
445 for each in _ConfigFileToInternalTranslation.values():\r
446 assert each in myconfig.__dict__\r