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 Common
.BuildVersion
import gBUILD_VERSION
32 from Parser
import ConvertGuid
36 # This class is used to define Eot main entrance
38 # @param object: Inherited from object class
43 # @param self: The object pointer
45 def __init__(self
, CommandLineOption
=True, IsInit
=True, SourceFileList
=None, \
46 IncludeDirList
=None, DecFileList
=None, GuidList
=None, LogFile
=None,
47 FvFileList
="", MapFileList
="", Report
='Report.html', Dispatch
=None):
48 # Version and Copyright
49 self
.VersionNumber
= ("0.02" + " " + gBUILD_VERSION
)
50 self
.Version
= "%prog Version " + self
.VersionNumber
51 self
.Copyright
= "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved."
55 self
.SourceFileList
= SourceFileList
56 self
.IncludeDirList
= IncludeDirList
57 self
.DecFileList
= DecFileList
58 self
.GuidList
= GuidList
59 self
.LogFile
= LogFile
60 self
.FvFileList
= FvFileList
61 self
.MapFileList
= MapFileList
62 self
.Dispatch
= Dispatch
64 # Check workspace environment
65 if "EFI_SOURCE" not in os
.environ
:
66 if "EDK_SOURCE" not in os
.environ
:
69 EotGlobalData
.gEDK_SOURCE
= os
.path
.normpath(os
.getenv("EDK_SOURCE"))
71 EotGlobalData
.gEFI_SOURCE
= os
.path
.normpath(os
.getenv("EFI_SOURCE"))
72 EotGlobalData
.gEDK_SOURCE
= os
.path
.join(EotGlobalData
.gEFI_SOURCE
, 'Edk')
74 if "WORKSPACE" not in os
.environ
:
75 EdkLogger
.error("EOT", BuildToolError
.ATTRIBUTE_NOT_AVAILABLE
, "Environment variable not found",
76 ExtraData
="WORKSPACE")
78 EotGlobalData
.gWORKSPACE
= os
.path
.normpath(os
.getenv("WORKSPACE"))
80 EotGlobalData
.gMACRO
['WORKSPACE'] = EotGlobalData
.gWORKSPACE
81 EotGlobalData
.gMACRO
['EFI_SOURCE'] = EotGlobalData
.gEFI_SOURCE
82 EotGlobalData
.gMACRO
['EDK_SOURCE'] = EotGlobalData
.gEDK_SOURCE
84 # Parse the options and args
89 for FvFile
in GetSplitValueList(self
.FvFileList
, ' '):
90 FvFile
= os
.path
.normpath(FvFile
)
91 if not os
.path
.isfile(FvFile
):
92 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "Can not find file %s " % FvFile
)
93 EotGlobalData
.gFV_FILE
.append(FvFile
)
95 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "The fv file list of target platform was not specified")
98 for MapFile
in GetSplitValueList(self
.MapFileList
, ' '):
99 MapFile
= os
.path
.normpath(MapFile
)
100 if not os
.path
.isfile(MapFile
):
101 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "Can not find file %s " % MapFile
)
102 EotGlobalData
.gMAP_FILE
.append(MapFile
)
104 # Generate source file list
105 self
.GenerateSourceFileList(self
.SourceFileList
, self
.IncludeDirList
)
107 # Generate guid list of dec file list
108 self
.ParseDecFile(self
.DecFileList
)
110 # Generate guid list from GUID list file
111 self
.ParseGuidList(self
.GuidList
)
114 EotGlobalData
.gDb
= Database
.Database(Database
.DATABASE_PATH
)
115 EotGlobalData
.gDb
.InitDatabase(self
.IsInit
)
121 self
.ParseExecutionOrder()
123 # Merge Identifier tables
124 self
.GenerateQueryTable()
126 # Generate report database
127 self
.GenerateReportDatabase()
136 self
.GenerateReport()
139 self
.ConvertLogFile(self
.LogFile
)
142 EdkLogger
.quiet("EOT FINISHED!")
145 EotGlobalData
.gDb
.Close()
147 ## ParseDecFile() method
149 # parse DEC file and get all GUID names with GUID values as {GuidName : GuidValue}
150 # The Dict is stored in EotGlobalData.gGuidDict
152 # @param self: The object pointer
153 # @param DecFileList: A list of all DEC files
155 def ParseDecFile(self
, DecFileList
):
157 path
= os
.path
.normpath(DecFileList
)
158 lfr
= open(path
, 'rb')
160 path
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
161 if os
.path
.exists(path
):
162 dfr
= open(path
, 'rb')
164 line
= CleanString(line
)
165 list = line
.split('=')
167 EotGlobalData
.gGuidDict
[list[0].strip()] = GuidStructureStringToGuidString(list[1].strip())
170 ## ParseGuidList() method
172 # Parse Guid list and get all GUID names with GUID values as {GuidName : GuidValue}
173 # The Dict is stored in EotGlobalData.gGuidDict
175 # @param self: The object pointer
176 # @param GuidList: A list of all GUID and its value
178 def ParseGuidList(self
, GuidList
):
179 Path
= os
.path
.join(EotGlobalData
.gWORKSPACE
, GuidList
)
180 if os
.path
.isfile(Path
):
181 for Line
in open(Path
):
182 (GuidName
, GuidValue
) = Line
.split()
183 EotGlobalData
.gGuidDict
[GuidName
] = GuidValue
185 ## ConvertLogFile() method
187 # Parse a real running log file to get real dispatch order
188 # The result is saved to old file name + '.new'
190 # @param self: The object pointer
191 # @param LogFile: A real running log file name
193 def ConvertLogFile(self
, LogFile
):
198 lfr
= open(LogFile
, 'rb')
199 lfw
= open(LogFile
+ '.new', 'wb')
202 line
= line
.replace('.efi', '')
203 index
= line
.find("Loading PEIM at ")
205 newline
.append(line
[index
+ 55 : ])
207 index
= line
.find("Loading driver at ")
209 newline
.append(line
[index
+ 57 : ])
213 lfw
.write(line
+ '\r\n')
220 ## GenerateSourceFileList() method
222 # Generate a list of all source files
223 # 1. Search the file list one by one
224 # 2. Store inf file name with source file names under it like
225 # { INF file name: [source file1, source file2, ...]}
226 # 3. Search the include list to find all .h files
227 # 4. Store source file list to EotGlobalData.gSOURCE_FILES
228 # 5. Store INF file list to EotGlobalData.gINF_FILES
230 # @param self: The object pointer
231 # @param SourceFileList: A list of all source files
232 # @param IncludeFileList: A list of all include files
234 def GenerateSourceFileList(self
, SourceFileList
, IncludeFileList
):
235 EdkLogger
.quiet("Generating source files list ... ")
241 mCurrentSourceFileList
= []
244 sfl
= open(SourceFileList
, 'rb')
246 line
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
247 if line
[-2:].upper() == '.C' or line
[-2:].upper() == '.H':
248 if line
not in mCurrentSourceFileList
:
249 mCurrentSourceFileList
.append(line
)
250 mSourceFileList
.append(line
)
251 EotGlobalData
.gOP_SOURCE_FILES
.write('%s\n' % line
)
252 if line
[-4:].upper() == '.INF':
253 if mCurrentInfFile
!= '':
254 mFileList
[mCurrentInfFile
] = mCurrentSourceFileList
255 mCurrentSourceFileList
= []
256 mCurrentInfFile
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
))
257 EotGlobalData
.gOP_INF
.write('%s\n' % mCurrentInfFile
)
258 if mCurrentInfFile
not in mFileList
:
259 mFileList
[mCurrentInfFile
] = mCurrentSourceFileList
261 # Get all include files from packages
263 ifl
= open(IncludeFileList
, 'rb')
267 newline
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
268 for Root
, Dirs
, Files
in os
.walk(str(newline
)):
270 FullPath
= os
.path
.normpath(os
.path
.join(Root
, File
))
271 if FullPath
not in mSourceFileList
and File
[-2:].upper() == '.H':
272 mSourceFileList
.append(FullPath
)
273 EotGlobalData
.gOP_SOURCE_FILES
.write('%s\n' % FullPath
)
274 if FullPath
not in mDecFileList
and File
.upper().find('.DEC') > -1:
275 mDecFileList
.append(FullPath
)
277 EotGlobalData
.gSOURCE_FILES
= mSourceFileList
278 EotGlobalData
.gOP_SOURCE_FILES
.close()
280 EotGlobalData
.gINF_FILES
= mFileList
281 EotGlobalData
.gOP_INF
.close()
283 EotGlobalData
.gDEC_FILES
= mDecFileList
286 ## GenerateReport() method
288 # Generate final HTML report
290 # @param self: The object pointer
292 def GenerateReport(self
):
293 EdkLogger
.quiet("Generating report file ... ")
294 Rep
= Report(self
.Report
, EotGlobalData
.gFV
, self
.Dispatch
)
297 ## LoadMapInfo() method
299 # Load map files and parse them
301 # @param self: The object pointer
303 def LoadMapInfo(self
):
304 if EotGlobalData
.gMAP_FILE
!= []:
305 EdkLogger
.quiet("Parsing Map file ... ")
306 EotGlobalData
.gMap
= ParseMapFile(EotGlobalData
.gMAP_FILE
)
308 ## LoadFvInfo() method
310 # Load FV binary files and parse them
312 # @param self: The object pointer
314 def LoadFvInfo(self
):
315 EdkLogger
.quiet("Parsing FV file ... ")
316 EotGlobalData
.gFV
= MultipleFv(EotGlobalData
.gFV_FILE
)
317 EotGlobalData
.gFV
.Dispatch(EotGlobalData
.gDb
)
319 for Protocol
in EotGlobalData
.gProtocolList
:
320 EotGlobalData
.gOP_UN_MATCHED_IN_LIBRARY_CALLING
.write('%s\n' %Protocol
)
322 ## GenerateReportDatabase() method
324 # Generate data for the information needed by report
325 # 1. Update name, macro and value of all found PPI/PROTOCOL GUID
326 # 2. Install hard coded PPI/PROTOCOL
328 # @param self: The object pointer
330 def GenerateReportDatabase(self
):
331 EdkLogger
.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")
333 # Update Protocol/Ppi Guid
334 SqlCommand
= """select DISTINCT GuidName from Report"""
335 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
336 for Record
in RecordSet
:
342 # Find value for hardcode guid macro
343 if GuidName
in EotGlobalData
.gGuidMacroDict
:
344 GuidMacro
= EotGlobalData
.gGuidMacroDict
[GuidName
][0]
345 GuidValue
= EotGlobalData
.gGuidMacroDict
[GuidName
][1]
346 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
347 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
350 # Find guid value defined in Dec file
351 if GuidName
in EotGlobalData
.gGuidDict
:
352 GuidValue
= EotGlobalData
.gGuidDict
[GuidName
]
353 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
354 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
357 # Search defined Macros for guid name
358 SqlCommand
="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName
359 GuidMacroSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
363 GuidMacro
= GuidMacroSet
[0][0].strip()
366 # Find Guid value of Guid Macro
367 SqlCommand
="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro
, MODEL_IDENTIFIER_MACRO_DEFINE
)
368 GuidValueSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
369 if GuidValueSet
!= []:
370 GuidValue
= GuidValueSet
[0][0]
371 GuidValue
= GuidValue
[GuidValue
.find(GuidMacro
) + len(GuidMacro
) :]
372 GuidValue
= GuidValue
.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()
373 GuidValue
= GuidStructureStringToGuidString(GuidValue
)
374 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
375 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
378 # Update Hard Coded Ppi/Protocol
379 SqlCommand
= """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""
380 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
381 for Record
in RecordSet
:
382 if Record
[1] == 'Ppi':
383 EotGlobalData
.gPpiList
[Record
[0].lower()] = -2
384 if Record
[1] == 'Protocol':
385 EotGlobalData
.gProtocolList
[Record
[0].lower()] = -2
387 ## GenerateQueryTable() method
389 # Generate two tables improve query performance
391 # @param self: The object pointer
393 def GenerateQueryTable(self
):
394 EdkLogger
.quiet("Generating temp query table for analysis ... ")
395 for Identifier
in EotGlobalData
.gIdentifierTableList
:
396 SqlCommand
= """insert into Query (Name, Modifier, Value, Model)
397 select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \
398 % (Identifier
[0], MODEL_IDENTIFIER_VARIABLE
, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION
)
399 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
400 SqlCommand
= """insert into Query2 (Name, Modifier, Value, Model)
401 select Name, Modifier, Value, Model from %s where Model = %s""" \
402 % (Identifier
[0], MODEL_IDENTIFIER_MACRO_DEFINE
)
403 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
405 ## ParseExecutionOrder() method
407 # Get final execution order
409 # 2. Search all PROTOCOL
411 # @param self: The object pointer
413 def ParseExecutionOrder(self
):
414 EdkLogger
.quiet("Searching Ppi/Protocol ... ")
415 for Identifier
in EotGlobalData
.gIdentifierTableList
:
416 ModuleID
, ModuleName
, ModuleGuid
, SourceFileID
, SourceFileFullPath
, ItemName
, ItemType
, ItemMode
, GuidName
, GuidMacro
, GuidValue
, BelongsToFunction
, Enabled
= \
417 -1, '', '', -1, '', '', '', '', '', '', '', '', 0
419 SourceFileID
= Identifier
[0].replace('Identifier', '')
420 SourceFileFullPath
= Identifier
[1]
421 Identifier
= Identifier
[0]
424 ItemMode
= 'Produced'
425 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
426 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
427 % (Identifier
, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
428 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
430 ItemMode
= 'Produced'
431 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
432 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
433 % (Identifier
, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
434 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
436 SearchPpiCallFunction(Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
438 ItemMode
= 'Consumed'
439 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
440 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
441 % (Identifier
, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
442 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
444 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Ppi', ItemMode
)
446 ItemMode
= 'Callback'
447 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
448 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
449 % (Identifier
, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
450 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
453 ItemMode
= 'Produced'
454 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
455 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
456 % (Identifier
, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING
)
457 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
459 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
460 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
461 % (Identifier
, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING
)
462 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
464 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
466 ItemMode
= 'Consumed'
467 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
468 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
469 % (Identifier
, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
470 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
472 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
473 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
474 % (Identifier
, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
475 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
477 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
479 ItemMode
= 'Callback'
480 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
481 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
482 % (Identifier
, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING
)
483 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
485 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
488 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)
489 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)
490 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)
491 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)
492 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)
493 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)
494 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)
495 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)
496 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)
498 EotGlobalData
.gDb
.Conn
.commit()
501 ## BuildDatabase() methoc
503 # Build the database for target
505 # @param self: The object pointer
507 def BuildDatabase(self
):
509 EotGlobalData
.gDb
.TblReport
.Drop()
510 EotGlobalData
.gDb
.TblReport
.Create()
514 self
.BuildMetaDataFileDatabase(EotGlobalData
.gINF_FILES
)
515 EdkLogger
.quiet("Building database for source code ...")
516 c
.CreateCCodeDB(EotGlobalData
.gSOURCE_FILES
)
517 EdkLogger
.quiet("Building database for source code done!")
519 EotGlobalData
.gIdentifierTableList
= GetTableList((MODEL_FILE_C
, MODEL_FILE_H
), 'Identifier', EotGlobalData
.gDb
)
521 ## BuildMetaDataFileDatabase() method
523 # Build the database for meta data files
525 # @param self: The object pointer
526 # @param Inf_Files: A list for all INF files
528 def BuildMetaDataFileDatabase(self
, Inf_Files
):
529 EdkLogger
.quiet("Building database for meta data files ...")
530 for InfFile
in Inf_Files
:
531 EdkLogger
.quiet("Parsing %s ..." % str(InfFile
))
532 EdkInfParser(InfFile
, EotGlobalData
.gDb
, Inf_Files
[InfFile
], '')
534 EotGlobalData
.gDb
.Conn
.commit()
535 EdkLogger
.quiet("Building database for meta data files done!")
537 ## ParseOption() method
539 # Parse command line options
541 # @param self: The object pointer
543 def ParseOption(self
):
544 (Options
, Target
) = self
.EotOptionParser()
547 self
.SetLogLevel(Options
)
549 if Options
.FvFileList
:
550 self
.FvFileList
= Options
.FvFileList
552 if Options
.MapFileList
:
553 self
.MapFileList
= Options
.FvMapFileList
555 if Options
.SourceFileList
:
556 self
.SourceFileList
= Options
.SourceFileList
558 if Options
.IncludeDirList
:
559 self
.IncludeDirList
= Options
.IncludeDirList
561 if Options
.DecFileList
:
562 self
.DecFileList
= Options
.DecFileList
565 self
.GuidList
= Options
.GuidList
568 self
.LogFile
= Options
.LogFile
570 if Options
.keepdatabase
:
573 ## SetLogLevel() method
575 # Set current log level of the tool based on args
577 # @param self: The object pointer
578 # @param Option: The option list including log level setting
580 def SetLogLevel(self
, Option
):
581 if Option
.verbose
!= None:
582 EdkLogger
.SetLevel(EdkLogger
.VERBOSE
)
583 elif Option
.quiet
!= None:
584 EdkLogger
.SetLevel(EdkLogger
.QUIET
)
585 elif Option
.debug
!= None:
586 EdkLogger
.SetLevel(Option
.debug
+ 1)
588 EdkLogger
.SetLevel(EdkLogger
.INFO
)
590 ## EotOptionParser() method
592 # Using standard Python module optparse to parse command line option of this tool.
594 # @param self: The object pointer
596 # @retval Opt A optparse.Values object containing the parsed options
597 # @retval Args Target of build command
599 def EotOptionParser(self
):
600 Parser
= OptionParser(description
= self
.Copyright
, version
= self
.Version
, prog
= "Eot.exe", usage
= "%prog [options]")
601 Parser
.add_option("-m", "--makefile filename", action
="store", type="string", dest
='MakeFile',
602 help="Specify a makefile for the platform.")
603 Parser
.add_option("-c", "--dsc filename", action
="store", type="string", dest
="DscFile",
604 help="Specify a dsc file for the platform.")
605 Parser
.add_option("-f", "--fv filename", action
="store", type="string", dest
="FvFileList",
606 help="Specify fv file list, quoted by \"\".")
607 Parser
.add_option("-a", "--map filename", action
="store", type="string", dest
="MapFileList",
608 help="Specify map file list, quoted by \"\".")
609 Parser
.add_option("-s", "--source files", action
="store", type="string", dest
="SourceFileList",
610 help="Specify source file list by a file")
611 Parser
.add_option("-i", "--include dirs", action
="store", type="string", dest
="IncludeDirList",
612 help="Specify include dir list by a file")
613 Parser
.add_option("-e", "--dec files", action
="store", type="string", dest
="DecFileList",
614 help="Specify dec file list by a file")
615 Parser
.add_option("-g", "--guid list", action
="store", type="string", dest
="GuidList",
616 help="Specify guid file list by a file")
617 Parser
.add_option("-l", "--log filename", action
="store", type="string", dest
="LogFile",
618 help="Specify real execution log file")
620 Parser
.add_option("-k", "--keepdatabase", action
="store_true", type=None, help="The existing Eot database will not be cleaned except report information if this option is specified.")
622 Parser
.add_option("-q", "--quiet", action
="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
623 Parser
.add_option("-v", "--verbose", action
="store_true", type=None, help="Turn on verbose output with informational messages printed, "\
624 "including library instances selected, final dependency expression, "\
625 "and warning messages, etc.")
626 Parser
.add_option("-d", "--debug", action
="store", type="int", help="Enable debug messages at specified level.")
628 (Opt
, Args
)=Parser
.parse_args()
634 # This acts like the main() function for the script, unless it is 'import'ed into another
637 if __name__
== '__main__':
638 # Initialize log system
639 EdkLogger
.Initialize()
640 EdkLogger
.IsRaiseError
= False
641 EdkLogger
.quiet(time
.strftime("%H:%M:%S, %b.%d %Y ", time
.localtime()) + "[00:00]" + "\n")
643 StartTime
= time
.clock()
645 FinishTime
= time
.clock()
647 BuildDuration
= time
.strftime("%M:%S", time
.gmtime(int(round(FinishTime
- StartTime
))))
648 EdkLogger
.quiet("\n%s [%s]" % (time
.strftime("%H:%M:%S, %b.%d %Y", time
.localtime()), BuildDuration
))