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