]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Ecc/Configuration.py
BaseTools: Clean up source files
[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
e56468c0 189\r
30fdf114
LG
190 ## Space Checking\r
191 self.SpaceCheckAll = 1\r
e56468c0 192\r
30fdf114
LG
193 ## Predicate Expression Checking\r
194 self.PredicateExpressionCheckAll = 0\r
e56468c0 195\r
30fdf114
LG
196 # Check whether Boolean values, variable type BOOLEAN not use explicit comparisons to TRUE or FALSE\r
197 self.PredicateExpressionCheckBooleanValue = 1\r
e56468c0 198 # Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).\r
30fdf114
LG
199 self.PredicateExpressionCheckNonBooleanOperator = 1\r
200 # Check whether a comparison of any pointer to zero must be done via the NULL type\r
201 self.PredicateExpressionCheckComparisonNullType = 1\r
e56468c0 202\r
30fdf114
LG
203 ## Headers Checking\r
204 self.HeaderCheckAll = 0\r
e56468c0 205\r
30fdf114
LG
206 # Check whether File header exists\r
207 self.HeaderCheckFile = 1\r
208 # Check whether Function header exists\r
209 self.HeaderCheckFunction = 1\r
d0acc87a
LG
210 # Check whether Meta data File header Comment End with '##'\r
211 self.HeaderCheckFileCommentEnd = 1\r
212 # Check whether C File header Comment content start with two spaces\r
213 self.HeaderCheckCFileCommentStartSpacesNum = 1\r
214 # Check whether C File header Comment's each reference at list should begin with a bullet character '-'\r
215 self.HeaderCheckCFileCommentReferenceFormat = 1\r
216 # Check whether C File header Comment have the License immediately after the ""Copyright"" line\r
217 self.HeaderCheckCFileCommentLicenseFormat = 1\r
f7496d71 218\r
30fdf114
LG
219 ## C Function Layout Checking\r
220 self.CFunctionLayoutCheckAll = 0\r
e56468c0 221\r
30fdf114
LG
222 # Check whether return type exists and in the first line\r
223 self.CFunctionLayoutCheckReturnType = 1\r
224 # Check whether any optional functional modifiers exist and next to the return type\r
225 self.CFunctionLayoutCheckOptionalFunctionalModifier = 1\r
226 # Check whether the next line contains the function name, left justified, followed by the beginning of the parameter list\r
227 # Check whether the closing parenthesis is on its own line and also indented two spaces\r
228 self.CFunctionLayoutCheckFunctionName = 1\r
229 # Check whether the function prototypes in include files have the same form as function definitions\r
230 self.CFunctionLayoutCheckFunctionPrototype = 1\r
231 # Check whether the body of a function is contained by open and close braces that must be in the first column\r
232 self.CFunctionLayoutCheckFunctionBody = 1\r
233 # Check whether the data declarations is the first code in a module.\r
234 self.CFunctionLayoutCheckDataDeclaration = 1\r
235 # Check whether no initialization of a variable as part of its declaration\r
236 self.CFunctionLayoutCheckNoInitOfVariable = 1\r
237 # Check whether no use of STATIC for functions\r
238 self.CFunctionLayoutCheckNoStatic = 1\r
e56468c0 239\r
30fdf114
LG
240 ## Include Files Checking\r
241 self.IncludeFileCheckAll = 0\r
e56468c0 242\r
30fdf114
LG
243 #Check whether having include files with same name\r
244 self.IncludeFileCheckSameName = 1\r
245 # Check whether all include file contents is guarded by a #ifndef statement.\r
246 # the #ifndef must be the first line of code following the file header comment\r
247 # the #endif must appear on the last line in the file\r
248 self.IncludeFileCheckIfndefStatement = 1\r
249 # Check whether include files contain only public or only private data\r
250 # Check whether include files NOT contain code or define data variables\r
251 self.IncludeFileCheckData = 1\r
e56468c0 252\r
30fdf114
LG
253 ## Declarations and Data Types Checking\r
254 self.DeclarationDataTypeCheckAll = 0\r
e56468c0 255\r
30fdf114
LG
256 # Check whether no use of int, unsigned, char, void, static, long in any .c, .h or .asl files.\r
257 self.DeclarationDataTypeCheckNoUseCType = 1\r
258 # 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
259 self.DeclarationDataTypeCheckInOutModifier = 1\r
260 # Check whether the EFIAPI modifier should be used at the entry of drivers, events, and member functions of protocols\r
261 self.DeclarationDataTypeCheckEFIAPIModifier = 1\r
262 # Check whether Enumerated Type has a 'typedef' and the name is capital\r
263 self.DeclarationDataTypeCheckEnumeratedType = 1\r
264 # Check whether Structure Type has a 'typedef' and the name is capital\r
265 self.DeclarationDataTypeCheckStructureDeclaration = 1\r
266 # Check whether having same Structure\r
267 self.DeclarationDataTypeCheckSameStructure = 1\r
268 # Check whether Union Type has a 'typedef' and the name is capital\r
269 self.DeclarationDataTypeCheckUnionType = 1\r
e56468c0 270\r
30fdf114
LG
271 ## Naming Conventions Checking\r
272 self.NamingConventionCheckAll = 0\r
e56468c0 273\r
30fdf114
LG
274 # Check whether only capital letters are used for #define declarations\r
275 self.NamingConventionCheckDefineStatement = 1\r
276 # Check whether only capital letters are used for typedef declarations\r
277 self.NamingConventionCheckTypedefStatement = 1\r
278 # Check whether the #ifndef at the start of an include file uses both prefix and postfix underscore characters, '_'.\r
279 self.NamingConventionCheckIfndefStatement = 1\r
280 # Rule for path name, variable name and function name\r
281 # 1. First character should be upper case\r
282 # 2. Existing lower case in a word\r
283 # 3. No space existence\r
284 # Check whether the path name followed the rule\r
285 self.NamingConventionCheckPathName = 1\r
286 # Check whether the variable name followed the rule\r
287 self.NamingConventionCheckVariableName = 1\r
288 # Check whether the function name followed the rule\r
289 self.NamingConventionCheckFunctionName = 1\r
290 # Check whether NO use short variable name with single character\r
291 self.NamingConventionCheckSingleCharacterVariable = 1\r
e56468c0 292\r
30fdf114
LG
293 ## Doxygen Checking\r
294 self.DoxygenCheckAll = 0\r
e56468c0 295\r
30fdf114
LG
296 # Check whether the file headers are followed Doxygen special documentation blocks in section 2.3.5\r
297 self.DoxygenCheckFileHeader = 1\r
298 # Check whether the function headers are followed Doxygen special documentation blocks in section 2.3.5\r
299 self.DoxygenCheckFunctionHeader = 1\r
e56468c0 300 # Check whether the first line of text in a comment block is a brief description of the element being documented.\r
30fdf114
LG
301 # The brief description must end with a period.\r
302 self.DoxygenCheckCommentDescription = 1\r
303 # Check whether comment lines with '///< ... text ...' format, if it is used, it should be after the code section.\r
304 self.DoxygenCheckCommentFormat = 1\r
305 # Check whether only Doxygen commands allowed to mark the code are @bug and @todo.\r
306 self.DoxygenCheckCommand = 1\r
e56468c0 307\r
30fdf114
LG
308 ## Meta-Data File Processing Checking\r
309 self.MetaDataFileCheckAll = 0\r
e56468c0 310\r
30fdf114
LG
311 # Check whether each file defined in meta-data exists\r
312 self.MetaDataFileCheckPathName = 1\r
313 # Generate a list for all files defined in meta-data files\r
314 self.MetaDataFileCheckGenerateFileList = 1\r
315 # The path of log file\r
316 self.MetaDataFileCheckPathOfGenerateFileList = 'File.log'\r
e56468c0 317 # Check whether all Library Instances defined for a given module (or dependent library instance) match the module's type.\r
318 # Each Library Instance must specify the Supported Module Types in its INF file,\r
30fdf114
LG
319 # and any module specifying the library instance must be one of the supported types.\r
320 self.MetaDataFileCheckLibraryInstance = 1\r
321 # Check whether a Library Instance has been defined for all dependent library classes\r
322 self.MetaDataFileCheckLibraryInstanceDependent = 1\r
323 # Check whether the Library Instances specified by the LibraryClasses sections are listed in order of dependencies\r
324 self.MetaDataFileCheckLibraryInstanceOrder = 1\r
325 # Check whether the unnecessary inclusion of library classes in the INF file\r
326 self.MetaDataFileCheckLibraryNoUse = 1\r
14239f66
HC
327 # Check the header file in Include\Library directory whether be defined in the package DEC file.\r
328 self.MetaDataFileCheckLibraryDefinedInDec = 1\r
30fdf114
LG
329 # 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
330 self.MetaDataFileCheckBinaryInfInFdf = 1\r
331 # Not to report error and warning related OS include file such as "windows.h" and "stdio.h"\r
332 # Check whether a PCD is set in a DSC file or the FDF file, but not in both.\r
333 self.MetaDataFileCheckPcdDuplicate = 1\r
334 # Check whether PCD settings in the FDF file can only be related to flash.\r
335 self.MetaDataFileCheckPcdFlash = 1\r
336 # Check whether PCDs used in INF files but not specified in DSC or FDF files\r
337 self.MetaDataFileCheckPcdNoUse = 1\r
338 # Check whether having duplicate guids defined for Guid/Protocol/Ppi\r
339 self.MetaDataFileCheckGuidDuplicate = 1\r
340 # Check whether all files under module directory are described in INF files\r
341 self.MetaDataFileCheckModuleFileNoUse = 1\r
342 # Check whether the PCD is correctly used in C function via its type\r
343 self.MetaDataFileCheckPcdType = 1\r
40d841f6
LG
344 # Check whether there are FILE_GUID duplication among different INF files\r
345 self.MetaDataFileCheckModuleFileGuidDuplication = 1\r
346\r
b3d07ff8
HC
347 # Check Guid Format in INF files\r
348 self.MetaDataFileCheckModuleFileGuidFormat = 1\r
349 # Check Protocol Format in INF files\r
350 self.MetaDataFileCheckModuleFileProtocolFormat = 1\r
351 # Check Ppi Format in INF files\r
352 self.MetaDataFileCheckModuleFilePpiFormat = 1\r
353 # Check Pcd Format in INF files\r
354 self.MetaDataFileCheckModuleFilePcdFormat = 1\r
f7496d71 355\r
1b2467c5
HC
356 # Check UNI file\r
357 self.UniCheckAll = 0\r
358 # Check INF or DEC file whether defined the localized information in the associated UNI file.\r
359 self.UniCheckHelpInfo = 1\r
360 # Check PCD whether defined the prompt, help in the DEC file and localized information in the associated UNI file.\r
361 self.UniCheckPCDInfo = 1\r
b3d07ff8 362\r
703ef6cf
HC
363 # Check SMM communication function parameter\r
364 self.SmmCommParaCheckAll = 0\r
365 # Check if the EFI_SMM_COMMUNICATION_PROTOCOL parameter buffer type is Reserved / ACPI NVS or UEFI RT code/data\r
366 self.SmmCommParaCheckBufferType = -1\r
367\r
30fdf114
LG
368 #\r
369 # The check points in this section are reserved\r
370 #\r
371 # GotoStatementCheckAll = 0\r
372 #\r
373 self.SpellingCheckAll = 0\r
374\r
375 # The directory listed here will not be parsed, split with ','\r
376 self.SkipDirList = []\r
f7496d71 377\r
8c3f9b4e
HC
378 # The file listed here will not be parsed, split with ','\r
379 self.SkipFileList = []\r
30fdf114 380\r
e56468c0 381 # A list for binary file ext name\r
382 self.BinaryExtList = []\r
f7496d71 383\r
e4ac870f
LG
384 # A list for only scanned folders\r
385 self.ScanOnlyDirList = []\r
f7496d71 386\r
d77cc206
HC
387 # A list for Copyright format\r
388 self.Copyright = []\r
e56468c0 389\r
30fdf114 390 self.ParseConfig()\r
e56468c0 391\r
30fdf114
LG
392 def ParseConfig(self):\r
393 Filepath = os.path.normpath(self.Filename)\r
394 if not os.path.isfile(Filepath):\r
395 ErrorMsg = "Can't find configuration file '%s'" % Filepath\r
396 EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, File = Filepath)\r
e56468c0 397\r
30fdf114
LG
398 LineNo = 0\r
399 for Line in open(Filepath, 'r'):\r
400 LineNo = LineNo + 1\r
401 Line = CleanString(Line)\r
402 if Line != '':\r
403 List = GetSplitValueList(Line, TAB_EQUAL_SPLIT)\r
a4c35ded 404 if List[0] not in _ConfigFileToInternalTranslation:\r
30fdf114
LG
405 ErrorMsg = "Invalid configuration option '%s' was found" % List[0]\r
406 EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, File = Filepath, Line = LineNo)\r
a4c35ded 407 assert _ConfigFileToInternalTranslation[List[0]] in self.__dict__\r
30fdf114
LG
408 if List[0] == 'ModifierList':\r
409 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
410 if List[0] == 'MetaDataFileCheckPathOfGenerateFileList' and List[1] == "":\r
411 continue\r
412 if List[0] == 'SkipDirList':\r
413 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
8c3f9b4e
HC
414 if List[0] == 'SkipFileList':\r
415 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
e56468c0 416 if List[0] == 'BinaryExtList':\r
417 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
d77cc206
HC
418 if List[0] == 'Copyright':\r
419 List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)\r
a4c35ded 420 self.__dict__[_ConfigFileToInternalTranslation[List[0]]] = List[1]\r
e56468c0 421\r
30fdf114 422 def ShowMe(self):\r
72443dd2 423 print(self.Filename)\r
30fdf114 424 for Key in self.__dict__.keys():\r
72443dd2 425 print(Key, '=', self.__dict__[Key])\r
a4c35ded
CJ
426\r
427#\r
428# test that our dict and out class still match in contents.\r
429#\r
430if __name__ == '__main__':\r
431 myconfig = Configuration("BaseTools\Source\Python\Ecc\config.ini")\r
432 for each in myconfig.__dict__:\r
433 if each == "Filename":\r
434 continue\r
435 assert each in _ConfigFileToInternalTranslation.values()\r
436 for each in _ConfigFileToInternalTranslation.values():\r
437 assert each in myconfig.__dict__\r