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