2 # This file is used to be the main entrance of EOT tool
\r
4 # Copyright (c) 2008 - 2010, Intel Corporation
\r
5 # All rights reserved. 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
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
17 import os, time, glob
\r
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
27 from FvImage import *
\r
28 from array import array
\r
29 from Report import Report
\r
30 from Common.Misc import ParseConsoleLog
\r
31 from Parser import ConvertGuid
\r
35 # This class is used to define Eot main entrance
\r
37 # @param object: Inherited from object class
\r
42 # @param self: The object pointer
\r
44 def __init__(self, CommandLineOption=True, IsInit=True, SourceFileList=None, \
\r
45 IncludeDirList=None, DecFileList=None, GuidList=None, LogFile=None,
\r
46 FvFileList="", MapFileList="", Report='Report.html'):
\r
47 # Version and Copyright
\r
48 self.VersionNumber = "0.02"
\r
49 self.Version = "%prog Version " + self.VersionNumber
\r
50 self.Copyright = "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved."
\r
51 self.Report = Report
\r
53 self.IsInit = IsInit
\r
54 self.SourceFileList = SourceFileList
\r
55 self.IncludeDirList = IncludeDirList
\r
56 self.DecFileList = DecFileList
\r
57 self.GuidList = GuidList
\r
58 self.LogFile = LogFile
\r
59 self.FvFileList = FvFileList
\r
60 self.MapFileList = MapFileList
\r
62 # Check workspace environment
\r
63 if "EFI_SOURCE" not in os.environ:
\r
64 if "EDK_SOURCE" not in os.environ:
\r
67 EotGlobalData.gEDK_SOURCE = os.path.normpath(os.getenv("EDK_SOURCE"))
\r
69 EotGlobalData.gEFI_SOURCE = os.path.normpath(os.getenv("EFI_SOURCE"))
\r
70 EotGlobalData.gEDK_SOURCE = os.path.join(EotGlobalData.gEFI_SOURCE, 'Edk')
\r
72 if "WORKSPACE" not in os.environ:
\r
73 EdkLogger.error("EOT", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",
\r
74 ExtraData="WORKSPACE")
\r
76 EotGlobalData.gWORKSPACE = os.path.normpath(os.getenv("WORKSPACE"))
\r
78 EotGlobalData.gMACRO['WORKSPACE'] = EotGlobalData.gWORKSPACE
\r
79 EotGlobalData.gMACRO['EFI_SOURCE'] = EotGlobalData.gEFI_SOURCE
\r
80 EotGlobalData.gMACRO['EDK_SOURCE'] = EotGlobalData.gEDK_SOURCE
\r
82 # Parse the options and args
\r
83 if CommandLineOption:
\r
87 for FvFile in GetSplitValueList(self.FvFileList, ' '):
\r
88 FvFile = os.path.normpath(FvFile)
\r
89 if not os.path.isfile(FvFile):
\r
90 EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % FvFile)
\r
91 EotGlobalData.gFV_FILE.append(FvFile)
\r
93 EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "The fv file list of target platform was not specified")
\r
95 if self.MapFileList:
\r
96 for MapFile in GetSplitValueList(self.MapFileList, ' '):
\r
97 MapFile = os.path.normpath(MapFile)
\r
98 if not os.path.isfile(MapFile):
\r
99 EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % MapFile)
\r
100 EotGlobalData.gMAP_FILE.append(MapFile)
\r
102 # Generate source file list
\r
103 self.GenerateSourceFileList(self.SourceFileList, self.IncludeDirList)
\r
105 # Generate guid list of dec file list
\r
106 self.ParseDecFile(self.DecFileList)
\r
108 # Generate guid list from GUID list file
\r
109 self.ParseGuidList(self.GuidList)
\r
111 # Init Eot database
\r
112 EotGlobalData.gDb = Database.Database(Database.DATABASE_PATH)
\r
113 EotGlobalData.gDb.InitDatabase(self.IsInit)
\r
115 # Build ECC database
\r
116 self.BuildDatabase()
\r
118 # Parse Ppi/Protocol
\r
119 self.ParseExecutionOrder()
\r
121 # Merge Identifier tables
\r
122 self.GenerateQueryTable()
\r
124 # Generate report database
\r
125 self.GenerateReportDatabase()
\r
134 self.GenerateReport()
\r
137 self.ConvertLogFile(self.LogFile)
\r
140 EdkLogger.quiet("EOT FINISHED!")
\r
143 EotGlobalData.gDb.Close()
\r
145 ## ParseDecFile() method
\r
147 # parse DEC file and get all GUID names with GUID values as {GuidName : GuidValue}
\r
148 # The Dict is stored in EotGlobalData.gGuidDict
\r
150 # @param self: The object pointer
\r
151 # @param DecFileList: A list of all DEC files
\r
153 def ParseDecFile(self, DecFileList):
\r
155 path = os.path.normpath(DecFileList)
\r
156 lfr = open(path, 'rb')
\r
158 path = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))
\r
159 if os.path.exists(path):
\r
160 dfr = open(path, 'rb')
\r
162 line = CleanString(line)
\r
163 list = line.split('=')
\r
165 EotGlobalData.gGuidDict[list[0].strip()] = GuidStructureStringToGuidString(list[1].strip())
\r
168 ## ParseGuidList() method
\r
170 # Parse Guid list and get all GUID names with GUID values as {GuidName : GuidValue}
\r
171 # The Dict is stored in EotGlobalData.gGuidDict
\r
173 # @param self: The object pointer
\r
174 # @param GuidList: A list of all GUID and its value
\r
176 def ParseGuidList(self, GuidList):
\r
177 Path = os.path.join(EotGlobalData.gWORKSPACE, GuidList)
\r
178 if os.path.isfile(Path):
\r
179 for Line in open(Path):
\r
180 (GuidName, GuidValue) = Line.split()
\r
181 EotGlobalData.gGuidDict[GuidName] = GuidValue
\r
183 ## ConvertLogFile() method
\r
185 # Parse a real running log file to get real dispatch order
\r
186 # The result is saved to old file name + '.new'
\r
188 # @param self: The object pointer
\r
189 # @param LogFile: A real running log file name
\r
191 def ConvertLogFile(self, LogFile):
\r
196 lfr = open(LogFile, 'rb')
\r
197 lfw = open(LogFile + '.new', 'wb')
\r
199 line = line.strip()
\r
200 line = line.replace('.efi', '')
\r
201 index = line.find("Loading PEIM at ")
\r
203 newline.append(line[index + 55 : ])
\r
205 index = line.find("Loading driver at ")
\r
207 newline.append(line[index + 57 : ])
\r
210 for line in newline:
\r
211 lfw.write(line + '\r\n')
\r
218 ## GenerateSourceFileList() method
\r
220 # Generate a list of all source files
\r
221 # 1. Search the file list one by one
\r
222 # 2. Store inf file name with source file names under it like
\r
223 # { INF file name: [source file1, source file2, ...]}
\r
224 # 3. Search the include list to find all .h files
\r
225 # 4. Store source file list to EotGlobalData.gSOURCE_FILES
\r
226 # 5. Store INF file list to EotGlobalData.gINF_FILES
\r
228 # @param self: The object pointer
\r
229 # @param SourceFileList: A list of all source files
\r
230 # @param IncludeFileList: A list of all include files
\r
232 def GenerateSourceFileList(self, SourceFileList, IncludeFileList):
\r
233 EdkLogger.quiet("Generating source files list ... ")
\r
234 mSourceFileList = []
\r
238 mCurrentInfFile = ''
\r
239 mCurrentSourceFileList = []
\r
242 sfl = open(SourceFileList, 'rb')
\r
244 line = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))
\r
245 if line[-2:].upper() == '.C' or line[-2:].upper() == '.H':
\r
246 if line not in mCurrentSourceFileList:
\r
247 mCurrentSourceFileList.append(line)
\r
248 mSourceFileList.append(line)
\r
249 EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % line)
\r
250 if line[-4:].upper() == '.INF':
\r
251 if mCurrentInfFile != '':
\r
252 mFileList[mCurrentInfFile] = mCurrentSourceFileList
\r
253 mCurrentSourceFileList = []
\r
254 mCurrentInfFile = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line))
\r
255 EotGlobalData.gOP_INF.write('%s\n' % mCurrentInfFile)
\r
256 if mCurrentInfFile not in mFileList:
\r
257 mFileList[mCurrentInfFile] = mCurrentSourceFileList
\r
259 # Get all include files from packages
\r
260 if IncludeFileList:
\r
261 ifl = open(IncludeFileList, 'rb')
\r
263 if not line.strip():
\r
265 newline = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))
\r
266 for Root, Dirs, Files in os.walk(str(newline)):
\r
268 FullPath = os.path.normpath(os.path.join(Root, File))
\r
269 if FullPath not in mSourceFileList and File[-2:].upper() == '.H':
\r
270 mSourceFileList.append(FullPath)
\r
271 EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % FullPath)
\r
272 if FullPath not in mDecFileList and File.upper().find('.DEC') > -1:
\r
273 mDecFileList.append(FullPath)
\r
275 EotGlobalData.gSOURCE_FILES = mSourceFileList
\r
276 EotGlobalData.gOP_SOURCE_FILES.close()
\r
278 EotGlobalData.gINF_FILES = mFileList
\r
279 EotGlobalData.gOP_INF.close()
\r
281 EotGlobalData.gDEC_FILES = mDecFileList
\r
284 ## GenerateReport() method
\r
286 # Generate final HTML report
\r
288 # @param self: The object pointer
\r
290 def GenerateReport(self):
\r
291 EdkLogger.quiet("Generating report file ... ")
\r
292 Rep = Report('Report.html', EotGlobalData.gFV)
\r
293 Rep.GenerateReport()
\r
295 ## LoadMapInfo() method
\r
297 # Load map files and parse them
\r
299 # @param self: The object pointer
\r
301 def LoadMapInfo(self):
\r
302 if EotGlobalData.gMAP_FILE != []:
\r
303 EdkLogger.quiet("Parsing Map file ... ")
\r
304 EotGlobalData.gMap = ParseMapFile(EotGlobalData.gMAP_FILE)
\r
306 ## LoadFvInfo() method
\r
308 # Load FV binary files and parse them
\r
310 # @param self: The object pointer
\r
312 def LoadFvInfo(self):
\r
313 EdkLogger.quiet("Parsing FV file ... ")
\r
314 EotGlobalData.gFV = MultipleFv(EotGlobalData.gFV_FILE)
\r
315 EotGlobalData.gFV.Dispatch(EotGlobalData.gDb)
\r
317 for Protocol in EotGlobalData.gProtocolList:
\r
318 EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s\n' %Protocol)
\r
320 ## GenerateReportDatabase() method
\r
322 # Generate data for the information needed by report
\r
323 # 1. Update name, macro and value of all found PPI/PROTOCOL GUID
\r
324 # 2. Install hard coded PPI/PROTOCOL
\r
326 # @param self: The object pointer
\r
328 def GenerateReportDatabase(self):
\r
329 EdkLogger.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")
\r
331 # Update Protocol/Ppi Guid
\r
332 SqlCommand = """select DISTINCT GuidName from Report"""
\r
333 RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
334 for Record in RecordSet:
\r
335 GuidName = Record[0]
\r
340 # Find value for hardcode guid macro
\r
341 if GuidName in EotGlobalData.gGuidMacroDict:
\r
342 GuidMacro = EotGlobalData.gGuidMacroDict[GuidName][0]
\r
343 GuidValue = EotGlobalData.gGuidMacroDict[GuidName][1]
\r
344 SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)
\r
345 EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
348 # Find guid value defined in Dec file
\r
349 if GuidName in EotGlobalData.gGuidDict:
\r
350 GuidValue = EotGlobalData.gGuidDict[GuidName]
\r
351 SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)
\r
352 EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
355 # Search defined Macros for guid name
\r
356 SqlCommand ="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName
\r
357 GuidMacroSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
358 # Ignore NULL result
\r
359 if not GuidMacroSet:
\r
361 GuidMacro = GuidMacroSet[0][0].strip()
\r
364 # Find Guid value of Guid Macro
\r
365 SqlCommand ="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro, MODEL_IDENTIFIER_MACRO_DEFINE)
\r
366 GuidValueSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
367 if GuidValueSet != []:
\r
368 GuidValue = GuidValueSet[0][0]
\r
369 GuidValue = GuidValue[GuidValue.find(GuidMacro) + len(GuidMacro) :]
\r
370 GuidValue = GuidValue.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()
\r
371 GuidValue = GuidStructureStringToGuidString(GuidValue)
\r
372 SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)
\r
373 EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
376 # Update Hard Coded Ppi/Protocol
\r
377 SqlCommand = """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""
\r
378 RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
379 for Record in RecordSet:
\r
380 if Record[1] == 'Ppi':
\r
381 EotGlobalData.gPpiList[Record[0].lower()] = -2
\r
382 if Record[1] == 'Protocol':
\r
383 EotGlobalData.gProtocolList[Record[0].lower()] = -2
\r
385 ## GenerateQueryTable() method
\r
387 # Generate two tables improve query performance
\r
389 # @param self: The object pointer
\r
391 def GenerateQueryTable(self):
\r
392 EdkLogger.quiet("Generating temp query table for analysis ... ")
\r
393 for Identifier in EotGlobalData.gIdentifierTableList:
\r
394 SqlCommand = """insert into Query (Name, Modifier, Value, Model)
\r
395 select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \
\r
396 % (Identifier[0], MODEL_IDENTIFIER_VARIABLE, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION)
\r
397 EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
398 SqlCommand = """insert into Query2 (Name, Modifier, Value, Model)
\r
399 select Name, Modifier, Value, Model from %s where Model = %s""" \
\r
400 % (Identifier[0], MODEL_IDENTIFIER_MACRO_DEFINE)
\r
401 EotGlobalData.gDb.TblReport.Exec(SqlCommand)
\r
403 ## ParseExecutionOrder() method
\r
405 # Get final execution order
\r
406 # 1. Search all PPI
\r
407 # 2. Search all PROTOCOL
\r
409 # @param self: The object pointer
\r
411 def ParseExecutionOrder(self):
\r
412 EdkLogger.quiet("Searching Ppi/Protocol ... ")
\r
413 for Identifier in EotGlobalData.gIdentifierTableList:
\r
414 ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled = \
\r
415 -1, '', '', -1, '', '', '', '', '', '', '', '', 0
\r
417 SourceFileID = Identifier[0].replace('Identifier', '')
\r
418 SourceFileFullPath = Identifier[1]
\r
419 Identifier = Identifier[0]
\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%%' or Name like '%%%s%%') and Model = %s""" \
\r
425 % (Identifier, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
426 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)
\r
428 ItemMode = 'Produced'
\r
429 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
\r
430 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
\r
431 % (Identifier, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
432 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)
\r
434 SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode)
\r
436 ItemMode = 'Consumed'
\r
437 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
\r
438 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
\r
439 % (Identifier, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
440 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)
\r
442 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Ppi', ItemMode)
\r
444 ItemMode = 'Callback'
\r
445 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
\r
446 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
\r
447 % (Identifier, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
448 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)
\r
451 ItemMode = 'Produced'
\r
452 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
\r
453 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
\r
454 % (Identifier, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
455 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)
\r
457 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
\r
458 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
\r
459 % (Identifier, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
460 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)
\r
462 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)
\r
464 ItemMode = 'Consumed'
\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, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
468 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)
\r
470 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
\r
471 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
\r
472 % (Identifier, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
473 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)
\r
475 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)
\r
477 ItemMode = 'Callback'
\r
478 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
\r
479 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
\r
480 % (Identifier, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING)
\r
481 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)
\r
483 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)
\r
486 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)
\r
487 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)
\r
488 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)
\r
489 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)
\r
490 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)
\r
491 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)
\r
492 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)
\r
493 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)
\r
494 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)
\r
496 EotGlobalData.gDb.Conn.commit()
\r
499 ## BuildDatabase() methoc
\r
501 # Build the database for target
\r
503 # @param self: The object pointer
\r
505 def BuildDatabase(self):
\r
506 # Clean report table
\r
507 EotGlobalData.gDb.TblReport.Drop()
\r
508 EotGlobalData.gDb.TblReport.Create()
\r
512 self.BuildMetaDataFileDatabase(EotGlobalData.gINF_FILES)
\r
513 EdkLogger.quiet("Building database for source code ...")
\r
514 c.CreateCCodeDB(EotGlobalData.gSOURCE_FILES)
\r
515 EdkLogger.quiet("Building database for source code done!")
\r
517 EotGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EotGlobalData.gDb)
\r
519 ## BuildMetaDataFileDatabase() method
\r
521 # Build the database for meta data files
\r
523 # @param self: The object pointer
\r
524 # @param Inf_Files: A list for all INF files
\r
526 def BuildMetaDataFileDatabase(self, Inf_Files):
\r
527 EdkLogger.quiet("Building database for meta data files ...")
\r
528 for InfFile in Inf_Files:
\r
529 EdkLogger.quiet("Parsing %s ..." % str(InfFile))
\r
530 EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile], '')
\r
532 EotGlobalData.gDb.Conn.commit()
\r
533 EdkLogger.quiet("Building database for meta data files done!")
\r
535 ## ParseOption() method
\r
537 # Parse command line options
\r
539 # @param self: The object pointer
\r
541 def ParseOption(self):
\r
542 (Options, Target) = self.EotOptionParser()
\r
545 self.SetLogLevel(Options)
\r
547 if Options.FvFileList:
\r
548 self.FvFileList = Options.FvFileList
\r
550 if Options.MapFileList:
\r
551 self.MapFileList = Options.FvMapFileList
\r
553 if Options.SourceFileList:
\r
554 self.SourceFileList = Options.SourceFileList
\r
556 if Options.IncludeDirList:
\r
557 self.IncludeDirList = Options.IncludeDirList
\r
559 if Options.DecFileList:
\r
560 self.DecFileList = Options.DecFileList
\r
562 if Options.GuidList:
\r
563 self.GuidList = Options.GuidList
\r
565 if Options.LogFile:
\r
566 self.LogFile = Options.LogFile
\r
568 if Options.keepdatabase:
\r
569 self.IsInit = False
\r
571 ## SetLogLevel() method
\r
573 # Set current log level of the tool based on args
\r
575 # @param self: The object pointer
\r
576 # @param Option: The option list including log level setting
\r
578 def SetLogLevel(self, Option):
\r
579 if Option.verbose != None:
\r
580 EdkLogger.SetLevel(EdkLogger.VERBOSE)
\r
581 elif Option.quiet != None:
\r
582 EdkLogger.SetLevel(EdkLogger.QUIET)
\r
583 elif Option.debug != None:
\r
584 EdkLogger.SetLevel(Option.debug + 1)
\r
586 EdkLogger.SetLevel(EdkLogger.INFO)
\r
588 ## EotOptionParser() method
\r
590 # Using standard Python module optparse to parse command line option of this tool.
\r
592 # @param self: The object pointer
\r
594 # @retval Opt A optparse.Values object containing the parsed options
\r
595 # @retval Args Target of build command
\r
597 def EotOptionParser(self):
\r
598 Parser = OptionParser(description = self.Copyright, version = self.Version, prog = "Eot.exe", usage = "%prog [options]")
\r
599 Parser.add_option("-m", "--makefile filename", action="store", type="string", dest='MakeFile',
\r
600 help="Specify a makefile for the platform.")
\r
601 Parser.add_option("-c", "--dsc filename", action="store", type="string", dest="DscFile",
\r
602 help="Specify a dsc file for the platform.")
\r
603 Parser.add_option("-f", "--fv filename", action="store", type="string", dest="FvFileList",
\r
604 help="Specify fv file list, quoted by \"\".")
\r
605 Parser.add_option("-a", "--map filename", action="store", type="string", dest="MapFileList",
\r
606 help="Specify map file list, quoted by \"\".")
\r
607 Parser.add_option("-s", "--source files", action="store", type="string", dest="SourceFileList",
\r
608 help="Specify source file list by a file")
\r
609 Parser.add_option("-i", "--include dirs", action="store", type="string", dest="IncludeDirList",
\r
610 help="Specify include dir list by a file")
\r
611 Parser.add_option("-e", "--dec files", action="store", type="string", dest="DecFileList",
\r
612 help="Specify dec file list by a file")
\r
613 Parser.add_option("-g", "--guid list", action="store", type="string", dest="GuidList",
\r
614 help="Specify guid file list by a file")
\r
615 Parser.add_option("-l", "--log filename", action="store", type="string", dest="LogFile",
\r
616 help="Specify real execution log file")
\r
618 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
620 Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
\r
621 Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\
\r
622 "including library instances selected, final dependency expression, "\
\r
623 "and warning messages, etc.")
\r
624 Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")
\r
626 (Opt, Args)=Parser.parse_args()
\r
632 # This acts like the main() function for the script, unless it is 'import'ed into another
\r
635 if __name__ == '__main__':
\r
636 # Initialize log system
\r
637 EdkLogger.Initialize()
\r
638 EdkLogger.IsRaiseError = False
\r
639 EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime()) + "[00:00]" + "\n")
\r
641 StartTime = time.clock()
\r
643 FinishTime = time.clock()
\r
645 BuildDuration = time.strftime("%M:%S", time.gmtime(int(round(FinishTime - StartTime))))
\r
646 EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration))
\r