]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Eot/Eot.py
BaseTools: Eot remove unused code
[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
52302d4d
LG
343 # Find guid value defined in Dec file\r
344 if GuidName in EotGlobalData.gGuidDict:\r
345 GuidValue = EotGlobalData.gGuidDict[GuidName]\r
346 SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)\r
347 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
348 continue\r
349\r
350 # Search defined Macros for guid name\r
351 SqlCommand ="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName\r
352 GuidMacroSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
353 # Ignore NULL result\r
354 if not GuidMacroSet:\r
355 continue\r
356 GuidMacro = GuidMacroSet[0][0].strip()\r
357 if not GuidMacro:\r
358 continue\r
359 # Find Guid value of Guid Macro\r
360 SqlCommand ="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro, MODEL_IDENTIFIER_MACRO_DEFINE)\r
361 GuidValueSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
362 if GuidValueSet != []:\r
363 GuidValue = GuidValueSet[0][0]\r
364 GuidValue = GuidValue[GuidValue.find(GuidMacro) + len(GuidMacro) :]\r
365 GuidValue = GuidValue.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()\r
366 GuidValue = GuidStructureStringToGuidString(GuidValue)\r
367 SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)\r
368 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
369 continue\r
370\r
371 # Update Hard Coded Ppi/Protocol\r
372 SqlCommand = """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""\r
373 RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
374 for Record in RecordSet:\r
375 if Record[1] == 'Ppi':\r
376 EotGlobalData.gPpiList[Record[0].lower()] = -2\r
377 if Record[1] == 'Protocol':\r
378 EotGlobalData.gProtocolList[Record[0].lower()] = -2\r
379\r
380 ## GenerateQueryTable() method\r
381 #\r
382 # Generate two tables improve query performance\r
383 #\r
384 # @param self: The object pointer\r
385 #\r
386 def GenerateQueryTable(self):\r
387 EdkLogger.quiet("Generating temp query table for analysis ... ")\r
388 for Identifier in EotGlobalData.gIdentifierTableList:\r
389 SqlCommand = """insert into Query (Name, Modifier, Value, Model)\r
390 select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \\r
391 % (Identifier[0], MODEL_IDENTIFIER_VARIABLE, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION)\r
392 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
393 SqlCommand = """insert into Query2 (Name, Modifier, Value, Model)\r
394 select Name, Modifier, Value, Model from %s where Model = %s""" \\r
395 % (Identifier[0], MODEL_IDENTIFIER_MACRO_DEFINE)\r
396 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
397\r
398 ## ParseExecutionOrder() method\r
399 #\r
400 # Get final execution order\r
401 # 1. Search all PPI\r
402 # 2. Search all PROTOCOL\r
403 #\r
404 # @param self: The object pointer\r
405 #\r
406 def ParseExecutionOrder(self):\r
407 EdkLogger.quiet("Searching Ppi/Protocol ... ")\r
408 for Identifier in EotGlobalData.gIdentifierTableList:\r
409 ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled = \\r
410 -1, '', '', -1, '', '', '', '', '', '', '', '', 0\r
411\r
412 SourceFileID = Identifier[0].replace('Identifier', '')\r
413 SourceFileFullPath = Identifier[1]\r
414 Identifier = Identifier[0]\r
415\r
416 # Find Ppis\r
417 ItemMode = 'Produced'\r
418 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
419 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
420 % (Identifier, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
421 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r
422\r
423 ItemMode = 'Produced'\r
424 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
425 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
426 % (Identifier, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
427 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)\r
428\r
429 SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r
430\r
431 ItemMode = 'Consumed'\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, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
435 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r
436\r
437 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Ppi', ItemMode)\r
438\r
439 ItemMode = 'Callback'\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, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
443 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r
444\r
445 # Find Procotols\r
446 ItemMode = 'Produced'\r
447 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
448 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
449 % (Identifier, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
450 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)\r
451\r
452 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
453 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
454 % (Identifier, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
455 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)\r
456\r
457 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r
458\r
459 ItemMode = 'Consumed'\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, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
463 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)\r
464\r
465 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
466 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
467 % (Identifier, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
468 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)\r
469\r
470 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r
471\r
472 ItemMode = 'Callback'\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, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
476 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)\r
477\r
478 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r
479\r
480 # Hard Code\r
481 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)\r
482 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)\r
483 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)\r
484 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)\r
485 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)\r
486 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)\r
487 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)\r
488 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)\r
489 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)\r
490\r
491 EotGlobalData.gDb.Conn.commit()\r
492\r
493\r
494 ## BuildDatabase() methoc\r
495 #\r
496 # Build the database for target\r
497 #\r
498 # @param self: The object pointer\r
499 #\r
500 def BuildDatabase(self):\r
501 # Clean report table\r
502 EotGlobalData.gDb.TblReport.Drop()\r
503 EotGlobalData.gDb.TblReport.Create()\r
504\r
505 # Build database\r
506 if self.IsInit:\r
507 self.BuildMetaDataFileDatabase(EotGlobalData.gINF_FILES)\r
508 EdkLogger.quiet("Building database for source code ...")\r
509 c.CreateCCodeDB(EotGlobalData.gSOURCE_FILES)\r
510 EdkLogger.quiet("Building database for source code done!")\r
511\r
512 EotGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EotGlobalData.gDb)\r
513\r
514 ## BuildMetaDataFileDatabase() method\r
515 #\r
516 # Build the database for meta data files\r
517 #\r
518 # @param self: The object pointer\r
519 # @param Inf_Files: A list for all INF files\r
520 #\r
521 def BuildMetaDataFileDatabase(self, Inf_Files):\r
522 EdkLogger.quiet("Building database for meta data files ...")\r
523 for InfFile in Inf_Files:\r
524 EdkLogger.quiet("Parsing %s ..." % str(InfFile))\r
525 EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile], '')\r
526\r
527 EotGlobalData.gDb.Conn.commit()\r
528 EdkLogger.quiet("Building database for meta data files done!")\r
529\r
530 ## ParseOption() method\r
531 #\r
532 # Parse command line options\r
533 #\r
534 # @param self: The object pointer\r
535 #\r
536 def ParseOption(self):\r
537 (Options, Target) = self.EotOptionParser()\r
538\r
539 # Set log level\r
540 self.SetLogLevel(Options)\r
541\r
542 if Options.FvFileList:\r
543 self.FvFileList = Options.FvFileList\r
544 \r
545 if Options.MapFileList:\r
546 self.MapFileList = Options.FvMapFileList\r
547\r
548 if Options.SourceFileList:\r
549 self.SourceFileList = Options.SourceFileList\r
550\r
551 if Options.IncludeDirList:\r
552 self.IncludeDirList = Options.IncludeDirList\r
553\r
554 if Options.DecFileList:\r
555 self.DecFileList = Options.DecFileList\r
556 \r
557 if Options.GuidList:\r
558 self.GuidList = Options.GuidList\r
559\r
560 if Options.LogFile:\r
561 self.LogFile = Options.LogFile\r
562\r
563 if Options.keepdatabase:\r
564 self.IsInit = False\r
565\r
566 ## SetLogLevel() method\r
567 #\r
568 # Set current log level of the tool based on args\r
569 #\r
570 # @param self: The object pointer\r
571 # @param Option: The option list including log level setting\r
572 #\r
573 def SetLogLevel(self, Option):\r
4231a819 574 if Option.verbose is not None:\r
52302d4d 575 EdkLogger.SetLevel(EdkLogger.VERBOSE)\r
4231a819 576 elif Option.quiet is not None:\r
52302d4d 577 EdkLogger.SetLevel(EdkLogger.QUIET)\r
4231a819 578 elif Option.debug is not None:\r
52302d4d
LG
579 EdkLogger.SetLevel(Option.debug + 1)\r
580 else:\r
581 EdkLogger.SetLevel(EdkLogger.INFO)\r
582\r
583 ## EotOptionParser() method\r
584 #\r
585 # Using standard Python module optparse to parse command line option of this tool.\r
586 #\r
587 # @param self: The object pointer\r
588 #\r
589 # @retval Opt A optparse.Values object containing the parsed options\r
590 # @retval Args Target of build command\r
591 #\r
592 def EotOptionParser(self):\r
593 Parser = OptionParser(description = self.Copyright, version = self.Version, prog = "Eot.exe", usage = "%prog [options]")\r
594 Parser.add_option("-m", "--makefile filename", action="store", type="string", dest='MakeFile',\r
595 help="Specify a makefile for the platform.")\r
596 Parser.add_option("-c", "--dsc filename", action="store", type="string", dest="DscFile",\r
597 help="Specify a dsc file for the platform.")\r
598 Parser.add_option("-f", "--fv filename", action="store", type="string", dest="FvFileList",\r
599 help="Specify fv file list, quoted by \"\".")\r
600 Parser.add_option("-a", "--map filename", action="store", type="string", dest="MapFileList",\r
601 help="Specify map file list, quoted by \"\".")\r
602 Parser.add_option("-s", "--source files", action="store", type="string", dest="SourceFileList",\r
603 help="Specify source file list by a file")\r
604 Parser.add_option("-i", "--include dirs", action="store", type="string", dest="IncludeDirList",\r
605 help="Specify include dir list by a file")\r
606 Parser.add_option("-e", "--dec files", action="store", type="string", dest="DecFileList",\r
607 help="Specify dec file list by a file")\r
608 Parser.add_option("-g", "--guid list", action="store", type="string", dest="GuidList",\r
609 help="Specify guid file list by a file")\r
610 Parser.add_option("-l", "--log filename", action="store", type="string", dest="LogFile",\r
611 help="Specify real execution log file")\r
612\r
613 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
614\r
615 Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")\r
616 Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\\r
617 "including library instances selected, final dependency expression, "\\r
618 "and warning messages, etc.")\r
619 Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")\r
620\r
621 (Opt, Args)=Parser.parse_args()\r
622\r
623 return (Opt, Args)\r
624\r
625##\r
626#\r
627# This acts like the main() function for the script, unless it is 'import'ed into another\r
628# script.\r
629#\r
630if __name__ == '__main__':\r
631 # Initialize log system\r
632 EdkLogger.Initialize()\r
633 EdkLogger.IsRaiseError = False\r
634 EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime()) + "[00:00]" + "\n")\r
635\r
636 StartTime = time.clock()\r
637 Eot = Eot()\r
638 FinishTime = time.clock()\r
639\r
640 BuildDuration = time.strftime("%M:%S", time.gmtime(int(round(FinishTime - StartTime))))\r
641 EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration))\r