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