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