Commit | Line | Data |
---|---|---|
52302d4d LG |
1 | ## @file\r |
2 | # This file is used to be the main entrance of EOT tool\r | |
3 | #\r | |
1be2ed90 | 4 | # Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r |
40d841f6 | 5 | # This program and the accompanying materials\r |
52302d4d 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 | |
1be2ed90 | 17 | import Common.LongFilePathOs as os, time, glob\r |
52302d4d LG |
18 | import Common.EdkLogger as EdkLogger\r |
19 | import EotGlobalData\r | |
20 | from optparse import OptionParser\r | |
21 | from Common.String import NormPath\r | |
22 | from Common import BuildToolError\r | |
23 | from Common.Misc import GuidStructureStringToGuidString\r | |
24 | from InfParserLite import *\r | |
25 | import c\r | |
26 | import Database\r | |
27 | from FvImage import *\r | |
28 | from array import array\r | |
29 | from Report import Report\r | |
b36d134f | 30 | from Common.BuildVersion import gBUILD_VERSION\r |
52302d4d | 31 | from Parser import ConvertGuid\r |
1be2ed90 | 32 | from Common.LongFilePathSupport import OpenLongFilePath as open\r |
52302d4d LG |
33 | \r |
34 | ## Class Eot\r | |
35 | #\r | |
36 | # This class is used to define Eot main entrance\r | |
37 | #\r | |
38 | # @param object: Inherited from object class\r | |
39 | #\r | |
40 | class Eot(object):\r | |
41 | ## The constructor\r | |
42 | #\r | |
43 | # @param self: The object pointer\r | |
44 | #\r | |
45 | def __init__(self, CommandLineOption=True, IsInit=True, SourceFileList=None, \\r | |
46 | IncludeDirList=None, DecFileList=None, GuidList=None, LogFile=None,\r | |
47 | FvFileList="", MapFileList="", Report='Report.html', Dispatch=None):\r | |
48 | # Version and Copyright\r | |
b36d134f | 49 | self.VersionNumber = ("0.02" + " " + gBUILD_VERSION)\r |
52302d4d LG |
50 | self.Version = "%prog Version " + self.VersionNumber\r |
51 | self.Copyright = "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved."\r | |
52 | self.Report = Report\r | |
53 | \r | |
54 | self.IsInit = IsInit\r | |
55 | self.SourceFileList = SourceFileList\r | |
56 | self.IncludeDirList = IncludeDirList\r | |
57 | self.DecFileList = DecFileList\r | |
58 | self.GuidList = GuidList\r | |
59 | self.LogFile = LogFile\r | |
60 | self.FvFileList = FvFileList\r | |
61 | self.MapFileList = MapFileList\r | |
62 | self.Dispatch = Dispatch\r | |
63 | \r | |
64 | # Check workspace environment\r | |
65 | if "EFI_SOURCE" not in os.environ:\r | |
66 | if "EDK_SOURCE" not in os.environ:\r | |
67 | pass\r | |
68 | else:\r | |
69 | EotGlobalData.gEDK_SOURCE = os.path.normpath(os.getenv("EDK_SOURCE"))\r | |
70 | else:\r | |
71 | EotGlobalData.gEFI_SOURCE = os.path.normpath(os.getenv("EFI_SOURCE"))\r | |
72 | EotGlobalData.gEDK_SOURCE = os.path.join(EotGlobalData.gEFI_SOURCE, 'Edk')\r | |
73 | \r | |
74 | if "WORKSPACE" not in os.environ:\r | |
75 | EdkLogger.error("EOT", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",\r | |
76 | ExtraData="WORKSPACE")\r | |
77 | else:\r | |
78 | EotGlobalData.gWORKSPACE = os.path.normpath(os.getenv("WORKSPACE"))\r | |
79 | \r | |
80 | EotGlobalData.gMACRO['WORKSPACE'] = EotGlobalData.gWORKSPACE\r | |
81 | EotGlobalData.gMACRO['EFI_SOURCE'] = EotGlobalData.gEFI_SOURCE\r | |
82 | EotGlobalData.gMACRO['EDK_SOURCE'] = EotGlobalData.gEDK_SOURCE\r | |
83 | \r | |
84 | # Parse the options and args\r | |
85 | if CommandLineOption:\r | |
86 | self.ParseOption()\r | |
87 | \r | |
88 | if self.FvFileList:\r | |
89 | for FvFile in GetSplitValueList(self.FvFileList, ' '):\r | |
90 | FvFile = os.path.normpath(FvFile)\r | |
91 | if not os.path.isfile(FvFile):\r | |
92 | EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % FvFile)\r | |
93 | EotGlobalData.gFV_FILE.append(FvFile)\r | |
94 | else:\r | |
95 | EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "The fv file list of target platform was not specified")\r | |
96 | \r | |
97 | if self.MapFileList:\r | |
98 | for MapFile in GetSplitValueList(self.MapFileList, ' '):\r | |
99 | MapFile = os.path.normpath(MapFile)\r | |
100 | if not os.path.isfile(MapFile):\r | |
101 | EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % MapFile)\r | |
102 | EotGlobalData.gMAP_FILE.append(MapFile)\r | |
103 | \r | |
104 | # Generate source file list\r | |
105 | self.GenerateSourceFileList(self.SourceFileList, self.IncludeDirList)\r | |
106 | \r | |
107 | # Generate guid list of dec file list\r | |
108 | self.ParseDecFile(self.DecFileList)\r | |
109 | \r | |
110 | # Generate guid list from GUID list file\r | |
111 | self.ParseGuidList(self.GuidList)\r | |
112 | \r | |
113 | # Init Eot database\r | |
114 | EotGlobalData.gDb = Database.Database(Database.DATABASE_PATH)\r | |
115 | EotGlobalData.gDb.InitDatabase(self.IsInit)\r | |
116 | \r | |
117 | # Build ECC database\r | |
118 | self.BuildDatabase()\r | |
119 | \r | |
120 | # Parse Ppi/Protocol\r | |
121 | self.ParseExecutionOrder()\r | |
122 | \r | |
123 | # Merge Identifier tables\r | |
124 | self.GenerateQueryTable()\r | |
125 | \r | |
126 | # Generate report database\r | |
127 | self.GenerateReportDatabase()\r | |
128 | \r | |
129 | # Load Fv Info\r | |
130 | self.LoadFvInfo()\r | |
131 | \r | |
132 | # Load Map Info\r | |
133 | self.LoadMapInfo()\r | |
134 | \r | |
135 | # Generate Report\r | |
136 | self.GenerateReport()\r | |
137 | \r | |
138 | # Convert log file\r | |
139 | self.ConvertLogFile(self.LogFile)\r | |
140 | \r | |
141 | # DONE\r | |
142 | EdkLogger.quiet("EOT FINISHED!")\r | |
143 | \r | |
144 | # Close Database\r | |
145 | EotGlobalData.gDb.Close()\r | |
146 | \r | |
147 | ## ParseDecFile() method\r | |
148 | #\r | |
149 | # parse DEC file and get all GUID names with GUID values as {GuidName : GuidValue}\r | |
150 | # The Dict is stored in EotGlobalData.gGuidDict\r | |
151 | #\r | |
152 | # @param self: The object pointer\r | |
153 | # @param DecFileList: A list of all DEC files\r | |
154 | #\r | |
155 | def ParseDecFile(self, DecFileList):\r | |
156 | if DecFileList:\r | |
157 | path = os.path.normpath(DecFileList)\r | |
158 | lfr = open(path, 'rb')\r | |
159 | for line in lfr:\r | |
160 | path = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))\r | |
161 | if os.path.exists(path):\r | |
162 | dfr = open(path, 'rb')\r | |
163 | for line in dfr:\r | |
164 | line = CleanString(line)\r | |
165 | list = line.split('=')\r | |
166 | if len(list) == 2:\r | |
167 | EotGlobalData.gGuidDict[list[0].strip()] = GuidStructureStringToGuidString(list[1].strip())\r | |
168 | \r | |
169 | \r | |
170 | ## ParseGuidList() method\r | |
171 | #\r | |
172 | # Parse Guid list and get all GUID names with GUID values as {GuidName : GuidValue}\r | |
173 | # The Dict is stored in EotGlobalData.gGuidDict\r | |
174 | #\r | |
175 | # @param self: The object pointer\r | |
176 | # @param GuidList: A list of all GUID and its value\r | |
177 | #\r | |
178 | def ParseGuidList(self, GuidList):\r | |
179 | Path = os.path.join(EotGlobalData.gWORKSPACE, GuidList)\r | |
180 | if os.path.isfile(Path):\r | |
181 | for Line in open(Path):\r | |
182 | (GuidName, GuidValue) = Line.split()\r | |
183 | EotGlobalData.gGuidDict[GuidName] = GuidValue\r | |
184 | \r | |
185 | ## ConvertLogFile() method\r | |
186 | #\r | |
187 | # Parse a real running log file to get real dispatch order\r | |
188 | # The result is saved to old file name + '.new'\r | |
189 | #\r | |
190 | # @param self: The object pointer\r | |
191 | # @param LogFile: A real running log file name\r | |
192 | #\r | |
193 | def ConvertLogFile(self, LogFile):\r | |
194 | newline = []\r | |
195 | lfr = None\r | |
196 | lfw = None\r | |
197 | if LogFile:\r | |
198 | lfr = open(LogFile, 'rb')\r | |
199 | lfw = open(LogFile + '.new', 'wb')\r | |
200 | for line in lfr:\r | |
201 | line = line.strip()\r | |
202 | line = line.replace('.efi', '')\r | |
203 | index = line.find("Loading PEIM at ")\r | |
204 | if index > -1:\r | |
205 | newline.append(line[index + 55 : ])\r | |
206 | continue\r | |
207 | index = line.find("Loading driver at ")\r | |
208 | if index > -1:\r | |
209 | newline.append(line[index + 57 : ])\r | |
210 | continue\r | |
211 | \r | |
212 | for line in newline:\r | |
213 | lfw.write(line + '\r\n')\r | |
214 | \r | |
215 | if lfr:\r | |
216 | lfr.close()\r | |
217 | if lfw:\r | |
218 | lfw.close()\r | |
219 | \r | |
220 | ## GenerateSourceFileList() method\r | |
221 | #\r | |
222 | # Generate a list of all source files\r | |
223 | # 1. Search the file list one by one\r | |
224 | # 2. Store inf file name with source file names under it like\r | |
225 | # { INF file name: [source file1, source file2, ...]}\r | |
226 | # 3. Search the include list to find all .h files\r | |
227 | # 4. Store source file list to EotGlobalData.gSOURCE_FILES\r | |
228 | # 5. Store INF file list to EotGlobalData.gINF_FILES\r | |
229 | #\r | |
230 | # @param self: The object pointer\r | |
231 | # @param SourceFileList: A list of all source files\r | |
232 | # @param IncludeFileList: A list of all include files\r | |
233 | #\r | |
234 | def GenerateSourceFileList(self, SourceFileList, IncludeFileList):\r | |
235 | EdkLogger.quiet("Generating source files list ... ")\r | |
236 | mSourceFileList = []\r | |
237 | mInfFileList = []\r | |
238 | mDecFileList = []\r | |
239 | mFileList = {}\r | |
240 | mCurrentInfFile = ''\r | |
241 | mCurrentSourceFileList = []\r | |
242 | \r | |
243 | if SourceFileList:\r | |
244 | sfl = open(SourceFileList, 'rb')\r | |
245 | for line in sfl:\r | |
246 | line = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))\r | |
247 | if line[-2:].upper() == '.C' or line[-2:].upper() == '.H':\r | |
248 | if line not in mCurrentSourceFileList:\r | |
249 | mCurrentSourceFileList.append(line)\r | |
250 | mSourceFileList.append(line)\r | |
251 | EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % line)\r | |
252 | if line[-4:].upper() == '.INF':\r | |
253 | if mCurrentInfFile != '':\r | |
254 | mFileList[mCurrentInfFile] = mCurrentSourceFileList\r | |
255 | mCurrentSourceFileList = []\r | |
256 | mCurrentInfFile = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line))\r | |
257 | EotGlobalData.gOP_INF.write('%s\n' % mCurrentInfFile)\r | |
258 | if mCurrentInfFile not in mFileList:\r | |
259 | mFileList[mCurrentInfFile] = mCurrentSourceFileList\r | |
260 | \r | |
261 | # Get all include files from packages\r | |
262 | if IncludeFileList:\r | |
263 | ifl = open(IncludeFileList, 'rb')\r | |
264 | for line in ifl:\r | |
265 | if not line.strip():\r | |
266 | continue\r | |
267 | newline = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))\r | |
268 | for Root, Dirs, Files in os.walk(str(newline)):\r | |
269 | for File in Files:\r | |
270 | FullPath = os.path.normpath(os.path.join(Root, File))\r | |
271 | if FullPath not in mSourceFileList and File[-2:].upper() == '.H':\r | |
272 | mSourceFileList.append(FullPath)\r | |
273 | EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % FullPath)\r | |
274 | if FullPath not in mDecFileList and File.upper().find('.DEC') > -1:\r | |
275 | mDecFileList.append(FullPath)\r | |
276 | \r | |
277 | EotGlobalData.gSOURCE_FILES = mSourceFileList\r | |
278 | EotGlobalData.gOP_SOURCE_FILES.close()\r | |
279 | \r | |
280 | EotGlobalData.gINF_FILES = mFileList\r | |
281 | EotGlobalData.gOP_INF.close()\r | |
282 | \r | |
283 | EotGlobalData.gDEC_FILES = mDecFileList\r | |
284 | \r | |
285 | \r | |
286 | ## GenerateReport() method\r | |
287 | #\r | |
288 | # Generate final HTML report\r | |
289 | #\r | |
290 | # @param self: The object pointer\r | |
291 | #\r | |
292 | def GenerateReport(self):\r | |
293 | EdkLogger.quiet("Generating report file ... ")\r | |
294 | Rep = Report(self.Report, EotGlobalData.gFV, self.Dispatch)\r | |
295 | Rep.GenerateReport()\r | |
296 | \r | |
297 | ## LoadMapInfo() method\r | |
298 | #\r | |
299 | # Load map files and parse them\r | |
300 | #\r | |
301 | # @param self: The object pointer\r | |
302 | #\r | |
303 | def LoadMapInfo(self):\r | |
304 | if EotGlobalData.gMAP_FILE != []:\r | |
305 | EdkLogger.quiet("Parsing Map file ... ")\r | |
306 | EotGlobalData.gMap = ParseMapFile(EotGlobalData.gMAP_FILE)\r | |
307 | \r | |
308 | ## LoadFvInfo() method\r | |
309 | #\r | |
310 | # Load FV binary files and parse them\r | |
311 | #\r | |
312 | # @param self: The object pointer\r | |
313 | #\r | |
314 | def LoadFvInfo(self):\r | |
315 | EdkLogger.quiet("Parsing FV file ... ")\r | |
316 | EotGlobalData.gFV = MultipleFv(EotGlobalData.gFV_FILE)\r | |
317 | EotGlobalData.gFV.Dispatch(EotGlobalData.gDb)\r | |
318 | \r | |
319 | for Protocol in EotGlobalData.gProtocolList:\r | |
320 | EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s\n' %Protocol)\r | |
321 | \r | |
322 | ## GenerateReportDatabase() method\r | |
323 | #\r | |
324 | # Generate data for the information needed by report\r | |
325 | # 1. Update name, macro and value of all found PPI/PROTOCOL GUID\r | |
326 | # 2. Install hard coded PPI/PROTOCOL\r | |
327 | #\r | |
328 | # @param self: The object pointer\r | |
329 | #\r | |
330 | def GenerateReportDatabase(self):\r | |
331 | EdkLogger.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")\r | |
332 | \r | |
333 | # Update Protocol/Ppi Guid\r | |
334 | SqlCommand = """select DISTINCT GuidName from Report"""\r | |
335 | RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r | |
336 | for Record in RecordSet:\r | |
337 | GuidName = Record[0]\r | |
338 | GuidMacro = ''\r | |
339 | GuidMacro2 = ''\r | |
340 | GuidValue = ''\r | |
341 | \r | |
52302d4d LG |
342 | # Find guid value defined in Dec file\r |
343 | if GuidName in EotGlobalData.gGuidDict:\r | |
344 | GuidValue = EotGlobalData.gGuidDict[GuidName]\r | |
345 | SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)\r | |
346 | EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r | |
347 | continue\r | |
348 | \r | |
349 | # Search defined Macros for guid name\r | |
350 | SqlCommand ="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName\r | |
351 | GuidMacroSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r | |
352 | # Ignore NULL result\r | |
353 | if not GuidMacroSet:\r | |
354 | continue\r | |
355 | GuidMacro = GuidMacroSet[0][0].strip()\r | |
356 | if not GuidMacro:\r | |
357 | continue\r | |
358 | # Find Guid value of Guid Macro\r | |
359 | SqlCommand ="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro, MODEL_IDENTIFIER_MACRO_DEFINE)\r | |
360 | GuidValueSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r | |
361 | if GuidValueSet != []:\r | |
362 | GuidValue = GuidValueSet[0][0]\r | |
363 | GuidValue = GuidValue[GuidValue.find(GuidMacro) + len(GuidMacro) :]\r | |
364 | GuidValue = GuidValue.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()\r | |
365 | GuidValue = GuidStructureStringToGuidString(GuidValue)\r | |
366 | SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)\r | |
367 | EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r | |
368 | continue\r | |
369 | \r | |
370 | # Update Hard Coded Ppi/Protocol\r | |
371 | SqlCommand = """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""\r | |
372 | RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r | |
373 | for Record in RecordSet:\r | |
374 | if Record[1] == 'Ppi':\r | |
375 | EotGlobalData.gPpiList[Record[0].lower()] = -2\r | |
376 | if Record[1] == 'Protocol':\r | |
377 | EotGlobalData.gProtocolList[Record[0].lower()] = -2\r | |
378 | \r | |
379 | ## GenerateQueryTable() method\r | |
380 | #\r | |
381 | # Generate two tables improve query performance\r | |
382 | #\r | |
383 | # @param self: The object pointer\r | |
384 | #\r | |
385 | def GenerateQueryTable(self):\r | |
386 | EdkLogger.quiet("Generating temp query table for analysis ... ")\r | |
387 | for Identifier in EotGlobalData.gIdentifierTableList:\r | |
388 | SqlCommand = """insert into Query (Name, Modifier, Value, Model)\r | |
389 | select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \\r | |
390 | % (Identifier[0], MODEL_IDENTIFIER_VARIABLE, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION)\r | |
391 | EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r | |
392 | SqlCommand = """insert into Query2 (Name, Modifier, Value, Model)\r | |
393 | select Name, Modifier, Value, Model from %s where Model = %s""" \\r | |
394 | % (Identifier[0], MODEL_IDENTIFIER_MACRO_DEFINE)\r | |
395 | EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r | |
396 | \r | |
397 | ## ParseExecutionOrder() method\r | |
398 | #\r | |
399 | # Get final execution order\r | |
400 | # 1. Search all PPI\r | |
401 | # 2. Search all PROTOCOL\r | |
402 | #\r | |
403 | # @param self: The object pointer\r | |
404 | #\r | |
405 | def ParseExecutionOrder(self):\r | |
406 | EdkLogger.quiet("Searching Ppi/Protocol ... ")\r | |
407 | for Identifier in EotGlobalData.gIdentifierTableList:\r | |
408 | ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled = \\r | |
409 | -1, '', '', -1, '', '', '', '', '', '', '', '', 0\r | |
410 | \r | |
411 | SourceFileID = Identifier[0].replace('Identifier', '')\r | |
412 | SourceFileFullPath = Identifier[1]\r | |
413 | Identifier = Identifier[0]\r | |
414 | \r | |
415 | # Find Ppis\r | |
416 | ItemMode = 'Produced'\r | |
417 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
418 | where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
419 | % (Identifier, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
420 | SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r | |
421 | \r | |
422 | ItemMode = 'Produced'\r | |
423 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
424 | where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
425 | % (Identifier, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
426 | SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)\r | |
427 | \r | |
428 | SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r | |
429 | \r | |
430 | ItemMode = 'Consumed'\r | |
431 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
432 | where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
433 | % (Identifier, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
434 | SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r | |
435 | \r | |
436 | SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Ppi', ItemMode)\r | |
437 | \r | |
438 | ItemMode = 'Callback'\r | |
439 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
440 | where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
441 | % (Identifier, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
442 | SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r | |
443 | \r | |
444 | # Find Procotols\r | |
445 | ItemMode = 'Produced'\r | |
446 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
447 | where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
448 | % (Identifier, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
449 | SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)\r | |
450 | \r | |
451 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
452 | where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
453 | % (Identifier, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
454 | SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)\r | |
455 | \r | |
456 | SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r | |
457 | \r | |
458 | ItemMode = 'Consumed'\r | |
459 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
460 | where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
461 | % (Identifier, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
462 | SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)\r | |
463 | \r | |
464 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
465 | where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
466 | % (Identifier, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
467 | SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)\r | |
468 | \r | |
469 | SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r | |
470 | \r | |
471 | ItemMode = 'Callback'\r | |
472 | SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r | |
473 | where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r | |
474 | % (Identifier, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING)\r | |
475 | SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)\r | |
476 | \r | |
477 | SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r | |
478 | \r | |
479 | # Hard Code\r | |
480 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)\r | |
481 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)\r | |
482 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)\r | |
483 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)\r | |
484 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)\r | |
485 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)\r | |
486 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)\r | |
487 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)\r | |
488 | EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)\r | |
489 | \r | |
490 | EotGlobalData.gDb.Conn.commit()\r | |
491 | \r | |
492 | \r | |
493 | ## BuildDatabase() methoc\r | |
494 | #\r | |
495 | # Build the database for target\r | |
496 | #\r | |
497 | # @param self: The object pointer\r | |
498 | #\r | |
499 | def BuildDatabase(self):\r | |
500 | # Clean report table\r | |
501 | EotGlobalData.gDb.TblReport.Drop()\r | |
502 | EotGlobalData.gDb.TblReport.Create()\r | |
503 | \r | |
504 | # Build database\r | |
505 | if self.IsInit:\r | |
506 | self.BuildMetaDataFileDatabase(EotGlobalData.gINF_FILES)\r | |
507 | EdkLogger.quiet("Building database for source code ...")\r | |
508 | c.CreateCCodeDB(EotGlobalData.gSOURCE_FILES)\r | |
509 | EdkLogger.quiet("Building database for source code done!")\r | |
510 | \r | |
511 | EotGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EotGlobalData.gDb)\r | |
512 | \r | |
513 | ## BuildMetaDataFileDatabase() method\r | |
514 | #\r | |
515 | # Build the database for meta data files\r | |
516 | #\r | |
517 | # @param self: The object pointer\r | |
518 | # @param Inf_Files: A list for all INF files\r | |
519 | #\r | |
520 | def BuildMetaDataFileDatabase(self, Inf_Files):\r | |
521 | EdkLogger.quiet("Building database for meta data files ...")\r | |
522 | for InfFile in Inf_Files:\r | |
523 | EdkLogger.quiet("Parsing %s ..." % str(InfFile))\r | |
524 | EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile], '')\r | |
525 | \r | |
526 | EotGlobalData.gDb.Conn.commit()\r | |
527 | EdkLogger.quiet("Building database for meta data files done!")\r | |
528 | \r | |
529 | ## ParseOption() method\r | |
530 | #\r | |
531 | # Parse command line options\r | |
532 | #\r | |
533 | # @param self: The object pointer\r | |
534 | #\r | |
535 | def ParseOption(self):\r | |
536 | (Options, Target) = self.EotOptionParser()\r | |
537 | \r | |
538 | # Set log level\r | |
539 | self.SetLogLevel(Options)\r | |
540 | \r | |
541 | if Options.FvFileList:\r | |
542 | self.FvFileList = Options.FvFileList\r | |
543 | \r | |
544 | if Options.MapFileList:\r | |
545 | self.MapFileList = Options.FvMapFileList\r | |
546 | \r | |
547 | if Options.SourceFileList:\r | |
548 | self.SourceFileList = Options.SourceFileList\r | |
549 | \r | |
550 | if Options.IncludeDirList:\r | |
551 | self.IncludeDirList = Options.IncludeDirList\r | |
552 | \r | |
553 | if Options.DecFileList:\r | |
554 | self.DecFileList = Options.DecFileList\r | |
555 | \r | |
556 | if Options.GuidList:\r | |
557 | self.GuidList = Options.GuidList\r | |
558 | \r | |
559 | if Options.LogFile:\r | |
560 | self.LogFile = Options.LogFile\r | |
561 | \r | |
562 | if Options.keepdatabase:\r | |
563 | self.IsInit = False\r | |
564 | \r | |
565 | ## SetLogLevel() method\r | |
566 | #\r | |
567 | # Set current log level of the tool based on args\r | |
568 | #\r | |
569 | # @param self: The object pointer\r | |
570 | # @param Option: The option list including log level setting\r | |
571 | #\r | |
572 | def SetLogLevel(self, Option):\r | |
4231a819 | 573 | if Option.verbose is not None:\r |
52302d4d | 574 | EdkLogger.SetLevel(EdkLogger.VERBOSE)\r |
4231a819 | 575 | elif Option.quiet is not None:\r |
52302d4d | 576 | EdkLogger.SetLevel(EdkLogger.QUIET)\r |
4231a819 | 577 | elif Option.debug is not None:\r |
52302d4d LG |
578 | EdkLogger.SetLevel(Option.debug + 1)\r |
579 | else:\r | |
580 | EdkLogger.SetLevel(EdkLogger.INFO)\r | |
581 | \r | |
582 | ## EotOptionParser() method\r | |
583 | #\r | |
584 | # Using standard Python module optparse to parse command line option of this tool.\r | |
585 | #\r | |
586 | # @param self: The object pointer\r | |
587 | #\r | |
588 | # @retval Opt A optparse.Values object containing the parsed options\r | |
589 | # @retval Args Target of build command\r | |
590 | #\r | |
591 | def EotOptionParser(self):\r | |
592 | Parser = OptionParser(description = self.Copyright, version = self.Version, prog = "Eot.exe", usage = "%prog [options]")\r | |
593 | Parser.add_option("-m", "--makefile filename", action="store", type="string", dest='MakeFile',\r | |
594 | help="Specify a makefile for the platform.")\r | |
595 | Parser.add_option("-c", "--dsc filename", action="store", type="string", dest="DscFile",\r | |
596 | help="Specify a dsc file for the platform.")\r | |
597 | Parser.add_option("-f", "--fv filename", action="store", type="string", dest="FvFileList",\r | |
598 | help="Specify fv file list, quoted by \"\".")\r | |
599 | Parser.add_option("-a", "--map filename", action="store", type="string", dest="MapFileList",\r | |
600 | help="Specify map file list, quoted by \"\".")\r | |
601 | Parser.add_option("-s", "--source files", action="store", type="string", dest="SourceFileList",\r | |
602 | help="Specify source file list by a file")\r | |
603 | Parser.add_option("-i", "--include dirs", action="store", type="string", dest="IncludeDirList",\r | |
604 | help="Specify include dir list by a file")\r | |
605 | Parser.add_option("-e", "--dec files", action="store", type="string", dest="DecFileList",\r | |
606 | help="Specify dec file list by a file")\r | |
607 | Parser.add_option("-g", "--guid list", action="store", type="string", dest="GuidList",\r | |
608 | help="Specify guid file list by a file")\r | |
609 | Parser.add_option("-l", "--log filename", action="store", type="string", dest="LogFile",\r | |
610 | help="Specify real execution log file")\r | |
611 | \r | |
612 | Parser.add_option("-k", "--keepdatabase", action="store_true", type=None, help="The existing Eot database will not be cleaned except report information if this option is specified.")\r | |
613 | \r | |
614 | Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")\r | |
615 | Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\\r | |
616 | "including library instances selected, final dependency expression, "\\r | |
617 | "and warning messages, etc.")\r | |
618 | Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")\r | |
619 | \r | |
620 | (Opt, Args)=Parser.parse_args()\r | |
621 | \r | |
622 | return (Opt, Args)\r | |
623 | \r | |
624 | ##\r | |
625 | #\r | |
626 | # This acts like the main() function for the script, unless it is 'import'ed into another\r | |
627 | # script.\r | |
628 | #\r | |
629 | if __name__ == '__main__':\r | |
630 | # Initialize log system\r | |
631 | EdkLogger.Initialize()\r | |
632 | EdkLogger.IsRaiseError = False\r | |
633 | EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime()) + "[00:00]" + "\n")\r | |
634 | \r | |
635 | StartTime = time.clock()\r | |
636 | Eot = Eot()\r | |
637 | FinishTime = time.clock()\r | |
638 | \r | |
639 | BuildDuration = time.strftime("%M:%S", time.gmtime(int(round(FinishTime - StartTime))))\r | |
640 | EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration))\r |