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