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