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