2 # This file is used to be the main entrance of EOT tool
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
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.
18 import Common
.EdkLogger
as EdkLogger
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 *
28 from array
import array
29 from Report
import Report
30 from Common
.Misc
import ParseConsoleLog
31 from Parser
import ConvertGuid
35 # This class is used to define Eot main entrance
37 # @param object: Inherited from object class
42 # @param self: The object pointer
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."
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
63 # Check workspace environment
64 if "EFI_SOURCE" not in os
.environ
:
65 if "EDK_SOURCE" not in os
.environ
:
68 EotGlobalData
.gEDK_SOURCE
= os
.path
.normpath(os
.getenv("EDK_SOURCE"))
70 EotGlobalData
.gEFI_SOURCE
= os
.path
.normpath(os
.getenv("EFI_SOURCE"))
71 EotGlobalData
.gEDK_SOURCE
= os
.path
.join(EotGlobalData
.gEFI_SOURCE
, 'Edk')
73 if "WORKSPACE" not in os
.environ
:
74 EdkLogger
.error("EOT", BuildToolError
.ATTRIBUTE_NOT_AVAILABLE
, "Environment variable not found",
75 ExtraData
="WORKSPACE")
77 EotGlobalData
.gWORKSPACE
= os
.path
.normpath(os
.getenv("WORKSPACE"))
79 EotGlobalData
.gMACRO
['WORKSPACE'] = EotGlobalData
.gWORKSPACE
80 EotGlobalData
.gMACRO
['EFI_SOURCE'] = EotGlobalData
.gEFI_SOURCE
81 EotGlobalData
.gMACRO
['EDK_SOURCE'] = EotGlobalData
.gEDK_SOURCE
83 # Parse the options and args
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
)
94 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "The fv file list of target platform was not specified")
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
)
103 # Generate source file list
104 self
.GenerateSourceFileList(self
.SourceFileList
, self
.IncludeDirList
)
106 # Generate guid list of dec file list
107 self
.ParseDecFile(self
.DecFileList
)
109 # Generate guid list from GUID list file
110 self
.ParseGuidList(self
.GuidList
)
113 EotGlobalData
.gDb
= Database
.Database(Database
.DATABASE_PATH
)
114 EotGlobalData
.gDb
.InitDatabase(self
.IsInit
)
120 self
.ParseExecutionOrder()
122 # Merge Identifier tables
123 self
.GenerateQueryTable()
125 # Generate report database
126 self
.GenerateReportDatabase()
135 self
.GenerateReport()
138 self
.ConvertLogFile(self
.LogFile
)
141 EdkLogger
.quiet("EOT FINISHED!")
144 EotGlobalData
.gDb
.Close()
146 ## ParseDecFile() method
148 # parse DEC file and get all GUID names with GUID values as {GuidName : GuidValue}
149 # The Dict is stored in EotGlobalData.gGuidDict
151 # @param self: The object pointer
152 # @param DecFileList: A list of all DEC files
154 def ParseDecFile(self
, DecFileList
):
156 path
= os
.path
.normpath(DecFileList
)
157 lfr
= open(path
, 'rb')
159 path
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
160 if os
.path
.exists(path
):
161 dfr
= open(path
, 'rb')
163 line
= CleanString(line
)
164 list = line
.split('=')
166 EotGlobalData
.gGuidDict
[list[0].strip()] = GuidStructureStringToGuidString(list[1].strip())
169 ## ParseGuidList() method
171 # Parse Guid list and get all GUID names with GUID values as {GuidName : GuidValue}
172 # The Dict is stored in EotGlobalData.gGuidDict
174 # @param self: The object pointer
175 # @param GuidList: A list of all GUID and its value
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
184 ## ConvertLogFile() method
186 # Parse a real running log file to get real dispatch order
187 # The result is saved to old file name + '.new'
189 # @param self: The object pointer
190 # @param LogFile: A real running log file name
192 def ConvertLogFile(self
, LogFile
):
197 lfr
= open(LogFile
, 'rb')
198 lfw
= open(LogFile
+ '.new', 'wb')
201 line
= line
.replace('.efi', '')
202 index
= line
.find("Loading PEIM at ")
204 newline
.append(line
[index
+ 55 : ])
206 index
= line
.find("Loading driver at ")
208 newline
.append(line
[index
+ 57 : ])
212 lfw
.write(line
+ '\r\n')
219 ## GenerateSourceFileList() method
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
229 # @param self: The object pointer
230 # @param SourceFileList: A list of all source files
231 # @param IncludeFileList: A list of all include files
233 def GenerateSourceFileList(self
, SourceFileList
, IncludeFileList
):
234 EdkLogger
.quiet("Generating source files list ... ")
240 mCurrentSourceFileList
= []
243 sfl
= open(SourceFileList
, 'rb')
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
260 # Get all include files from packages
262 ifl
= open(IncludeFileList
, 'rb')
266 newline
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
267 for Root
, Dirs
, Files
in os
.walk(str(newline
)):
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
)
276 EotGlobalData
.gSOURCE_FILES
= mSourceFileList
277 EotGlobalData
.gOP_SOURCE_FILES
.close()
279 EotGlobalData
.gINF_FILES
= mFileList
280 EotGlobalData
.gOP_INF
.close()
282 EotGlobalData
.gDEC_FILES
= mDecFileList
285 ## GenerateReport() method
287 # Generate final HTML report
289 # @param self: The object pointer
291 def GenerateReport(self
):
292 EdkLogger
.quiet("Generating report file ... ")
293 Rep
= Report(self
.Report
, EotGlobalData
.gFV
, self
.Dispatch
)
296 ## LoadMapInfo() method
298 # Load map files and parse them
300 # @param self: The object pointer
302 def LoadMapInfo(self
):
303 if EotGlobalData
.gMAP_FILE
!= []:
304 EdkLogger
.quiet("Parsing Map file ... ")
305 EotGlobalData
.gMap
= ParseMapFile(EotGlobalData
.gMAP_FILE
)
307 ## LoadFvInfo() method
309 # Load FV binary files and parse them
311 # @param self: The object pointer
313 def LoadFvInfo(self
):
314 EdkLogger
.quiet("Parsing FV file ... ")
315 EotGlobalData
.gFV
= MultipleFv(EotGlobalData
.gFV_FILE
)
316 EotGlobalData
.gFV
.Dispatch(EotGlobalData
.gDb
)
318 for Protocol
in EotGlobalData
.gProtocolList
:
319 EotGlobalData
.gOP_UN_MATCHED_IN_LIBRARY_CALLING
.write('%s\n' %Protocol
)
321 ## GenerateReportDatabase() method
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
327 # @param self: The object pointer
329 def GenerateReportDatabase(self
):
330 EdkLogger
.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")
332 # Update Protocol/Ppi Guid
333 SqlCommand
= """select DISTINCT GuidName from Report"""
334 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
335 for Record
in RecordSet
:
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
)
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
)
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
)
362 GuidMacro
= GuidMacroSet
[0][0].strip()
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
)
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
386 ## GenerateQueryTable() method
388 # Generate two tables improve query performance
390 # @param self: The object pointer
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
)
404 ## ParseExecutionOrder() method
406 # Get final execution order
408 # 2. Search all PROTOCOL
410 # @param self: The object pointer
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
418 SourceFileID
= Identifier
[0].replace('Identifier', '')
419 SourceFileFullPath
= Identifier
[1]
420 Identifier
= Identifier
[0]
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
)
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)
435 SearchPpiCallFunction(Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
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
)
443 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Ppi', ItemMode
)
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
)
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)
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)
463 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
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)
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)
476 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
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)
484 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
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)
497 EotGlobalData
.gDb
.Conn
.commit()
500 ## BuildDatabase() methoc
502 # Build the database for target
504 # @param self: The object pointer
506 def BuildDatabase(self
):
508 EotGlobalData
.gDb
.TblReport
.Drop()
509 EotGlobalData
.gDb
.TblReport
.Create()
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!")
518 EotGlobalData
.gIdentifierTableList
= GetTableList((MODEL_FILE_C
, MODEL_FILE_H
), 'Identifier', EotGlobalData
.gDb
)
520 ## BuildMetaDataFileDatabase() method
522 # Build the database for meta data files
524 # @param self: The object pointer
525 # @param Inf_Files: A list for all INF files
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
], '')
533 EotGlobalData
.gDb
.Conn
.commit()
534 EdkLogger
.quiet("Building database for meta data files done!")
536 ## ParseOption() method
538 # Parse command line options
540 # @param self: The object pointer
542 def ParseOption(self
):
543 (Options
, Target
) = self
.EotOptionParser()
546 self
.SetLogLevel(Options
)
548 if Options
.FvFileList
:
549 self
.FvFileList
= Options
.FvFileList
551 if Options
.MapFileList
:
552 self
.MapFileList
= Options
.FvMapFileList
554 if Options
.SourceFileList
:
555 self
.SourceFileList
= Options
.SourceFileList
557 if Options
.IncludeDirList
:
558 self
.IncludeDirList
= Options
.IncludeDirList
560 if Options
.DecFileList
:
561 self
.DecFileList
= Options
.DecFileList
564 self
.GuidList
= Options
.GuidList
567 self
.LogFile
= Options
.LogFile
569 if Options
.keepdatabase
:
572 ## SetLogLevel() method
574 # Set current log level of the tool based on args
576 # @param self: The object pointer
577 # @param Option: The option list including log level setting
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)
587 EdkLogger
.SetLevel(EdkLogger
.INFO
)
589 ## EotOptionParser() method
591 # Using standard Python module optparse to parse command line option of this tool.
593 # @param self: The object pointer
595 # @retval Opt A optparse.Values object containing the parsed options
596 # @retval Args Target of build command
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")
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.")
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.")
627 (Opt
, Args
)=Parser
.parse_args()
633 # This acts like the main() function for the script, unless it is 'import'ed into another
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")
642 StartTime
= time
.clock()
644 FinishTime
= time
.clock()
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
))