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