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