2 # This file is used to be the main entrance of EOT tool
4 # Copyright (c) 2008 - 2014, 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.
17 import Common
.LongFilePathOs
as os
, time
, glob
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
.BuildVersion
import gBUILD_VERSION
31 from Parser
import ConvertGuid
32 from Common
.LongFilePathSupport
import OpenLongFilePath
as open
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 guid value defined in Dec file
343 if GuidName
in EotGlobalData
.gGuidDict
:
344 GuidValue
= EotGlobalData
.gGuidDict
[GuidName
]
345 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
346 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
349 # Search defined Macros for guid name
350 SqlCommand
="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName
351 GuidMacroSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
355 GuidMacro
= GuidMacroSet
[0][0].strip()
358 # Find Guid value of Guid Macro
359 SqlCommand
="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro
, MODEL_IDENTIFIER_MACRO_DEFINE
)
360 GuidValueSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
361 if GuidValueSet
!= []:
362 GuidValue
= GuidValueSet
[0][0]
363 GuidValue
= GuidValue
[GuidValue
.find(GuidMacro
) + len(GuidMacro
) :]
364 GuidValue
= GuidValue
.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()
365 GuidValue
= GuidStructureStringToGuidString(GuidValue
)
366 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
367 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
370 # Update Hard Coded Ppi/Protocol
371 SqlCommand
= """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""
372 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
373 for Record
in RecordSet
:
374 if Record
[1] == 'Ppi':
375 EotGlobalData
.gPpiList
[Record
[0].lower()] = -2
376 if Record
[1] == 'Protocol':
377 EotGlobalData
.gProtocolList
[Record
[0].lower()] = -2
379 ## GenerateQueryTable() method
381 # Generate two tables improve query performance
383 # @param self: The object pointer
385 def GenerateQueryTable(self
):
386 EdkLogger
.quiet("Generating temp query table for analysis ... ")
387 for Identifier
in EotGlobalData
.gIdentifierTableList
:
388 SqlCommand
= """insert into Query (Name, Modifier, Value, Model)
389 select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \
390 % (Identifier
[0], MODEL_IDENTIFIER_VARIABLE
, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION
)
391 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
392 SqlCommand
= """insert into Query2 (Name, Modifier, Value, Model)
393 select Name, Modifier, Value, Model from %s where Model = %s""" \
394 % (Identifier
[0], MODEL_IDENTIFIER_MACRO_DEFINE
)
395 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
397 ## ParseExecutionOrder() method
399 # Get final execution order
401 # 2. Search all PROTOCOL
403 # @param self: The object pointer
405 def ParseExecutionOrder(self
):
406 EdkLogger
.quiet("Searching Ppi/Protocol ... ")
407 for Identifier
in EotGlobalData
.gIdentifierTableList
:
408 ModuleID
, ModuleName
, ModuleGuid
, SourceFileID
, SourceFileFullPath
, ItemName
, ItemType
, ItemMode
, GuidName
, GuidMacro
, GuidValue
, BelongsToFunction
, Enabled
= \
409 -1, '', '', -1, '', '', '', '', '', '', '', '', 0
411 SourceFileID
= Identifier
[0].replace('Identifier', '')
412 SourceFileFullPath
= Identifier
[1]
413 Identifier
= Identifier
[0]
416 ItemMode
= 'Produced'
417 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
418 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
419 % (Identifier
, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
420 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
422 ItemMode
= 'Produced'
423 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
424 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
425 % (Identifier
, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
426 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
428 SearchPpiCallFunction(Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
430 ItemMode
= 'Consumed'
431 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
432 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
433 % (Identifier
, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
434 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
436 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Ppi', ItemMode
)
438 ItemMode
= 'Callback'
439 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
440 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
441 % (Identifier
, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
442 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
445 ItemMode
= 'Produced'
446 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
447 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
448 % (Identifier
, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING
)
449 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
451 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
452 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
453 % (Identifier
, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING
)
454 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
456 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
458 ItemMode
= 'Consumed'
459 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
460 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
461 % (Identifier
, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
462 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
464 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
465 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
466 % (Identifier
, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
467 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
469 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
471 ItemMode
= 'Callback'
472 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
473 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
474 % (Identifier
, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING
)
475 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
477 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
480 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)
481 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)
482 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)
483 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)
484 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)
485 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)
486 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)
487 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)
488 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)
490 EotGlobalData
.gDb
.Conn
.commit()
493 ## BuildDatabase() methoc
495 # Build the database for target
497 # @param self: The object pointer
499 def BuildDatabase(self
):
501 EotGlobalData
.gDb
.TblReport
.Drop()
502 EotGlobalData
.gDb
.TblReport
.Create()
506 self
.BuildMetaDataFileDatabase(EotGlobalData
.gINF_FILES
)
507 EdkLogger
.quiet("Building database for source code ...")
508 c
.CreateCCodeDB(EotGlobalData
.gSOURCE_FILES
)
509 EdkLogger
.quiet("Building database for source code done!")
511 EotGlobalData
.gIdentifierTableList
= GetTableList((MODEL_FILE_C
, MODEL_FILE_H
), 'Identifier', EotGlobalData
.gDb
)
513 ## BuildMetaDataFileDatabase() method
515 # Build the database for meta data files
517 # @param self: The object pointer
518 # @param Inf_Files: A list for all INF files
520 def BuildMetaDataFileDatabase(self
, Inf_Files
):
521 EdkLogger
.quiet("Building database for meta data files ...")
522 for InfFile
in Inf_Files
:
523 EdkLogger
.quiet("Parsing %s ..." % str(InfFile
))
524 EdkInfParser(InfFile
, EotGlobalData
.gDb
, Inf_Files
[InfFile
], '')
526 EotGlobalData
.gDb
.Conn
.commit()
527 EdkLogger
.quiet("Building database for meta data files done!")
529 ## ParseOption() method
531 # Parse command line options
533 # @param self: The object pointer
535 def ParseOption(self
):
536 (Options
, Target
) = self
.EotOptionParser()
539 self
.SetLogLevel(Options
)
541 if Options
.FvFileList
:
542 self
.FvFileList
= Options
.FvFileList
544 if Options
.MapFileList
:
545 self
.MapFileList
= Options
.FvMapFileList
547 if Options
.SourceFileList
:
548 self
.SourceFileList
= Options
.SourceFileList
550 if Options
.IncludeDirList
:
551 self
.IncludeDirList
= Options
.IncludeDirList
553 if Options
.DecFileList
:
554 self
.DecFileList
= Options
.DecFileList
557 self
.GuidList
= Options
.GuidList
560 self
.LogFile
= Options
.LogFile
562 if Options
.keepdatabase
:
565 ## SetLogLevel() method
567 # Set current log level of the tool based on args
569 # @param self: The object pointer
570 # @param Option: The option list including log level setting
572 def SetLogLevel(self
, Option
):
573 if Option
.verbose
is not None:
574 EdkLogger
.SetLevel(EdkLogger
.VERBOSE
)
575 elif Option
.quiet
is not None:
576 EdkLogger
.SetLevel(EdkLogger
.QUIET
)
577 elif Option
.debug
is not None:
578 EdkLogger
.SetLevel(Option
.debug
+ 1)
580 EdkLogger
.SetLevel(EdkLogger
.INFO
)
582 ## EotOptionParser() method
584 # Using standard Python module optparse to parse command line option of this tool.
586 # @param self: The object pointer
588 # @retval Opt A optparse.Values object containing the parsed options
589 # @retval Args Target of build command
591 def EotOptionParser(self
):
592 Parser
= OptionParser(description
= self
.Copyright
, version
= self
.Version
, prog
= "Eot.exe", usage
= "%prog [options]")
593 Parser
.add_option("-m", "--makefile filename", action
="store", type="string", dest
='MakeFile',
594 help="Specify a makefile for the platform.")
595 Parser
.add_option("-c", "--dsc filename", action
="store", type="string", dest
="DscFile",
596 help="Specify a dsc file for the platform.")
597 Parser
.add_option("-f", "--fv filename", action
="store", type="string", dest
="FvFileList",
598 help="Specify fv file list, quoted by \"\".")
599 Parser
.add_option("-a", "--map filename", action
="store", type="string", dest
="MapFileList",
600 help="Specify map file list, quoted by \"\".")
601 Parser
.add_option("-s", "--source files", action
="store", type="string", dest
="SourceFileList",
602 help="Specify source file list by a file")
603 Parser
.add_option("-i", "--include dirs", action
="store", type="string", dest
="IncludeDirList",
604 help="Specify include dir list by a file")
605 Parser
.add_option("-e", "--dec files", action
="store", type="string", dest
="DecFileList",
606 help="Specify dec file list by a file")
607 Parser
.add_option("-g", "--guid list", action
="store", type="string", dest
="GuidList",
608 help="Specify guid file list by a file")
609 Parser
.add_option("-l", "--log filename", action
="store", type="string", dest
="LogFile",
610 help="Specify real execution log file")
612 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.")
614 Parser
.add_option("-q", "--quiet", action
="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
615 Parser
.add_option("-v", "--verbose", action
="store_true", type=None, help="Turn on verbose output with informational messages printed, "\
616 "including library instances selected, final dependency expression, "\
617 "and warning messages, etc.")
618 Parser
.add_option("-d", "--debug", action
="store", type="int", help="Enable debug messages at specified level.")
620 (Opt
, Args
)=Parser
.parse_args()
626 # This acts like the main() function for the script, unless it is 'import'ed into another
629 if __name__
== '__main__':
630 # Initialize log system
631 EdkLogger
.Initialize()
632 EdkLogger
.IsRaiseError
= False
633 EdkLogger
.quiet(time
.strftime("%H:%M:%S, %b.%d %Y ", time
.localtime()) + "[00:00]" + "\n")
635 StartTime
= time
.clock()
637 FinishTime
= time
.clock()
639 BuildDuration
= time
.strftime("%M:%S", time
.gmtime(int(round(FinishTime
- StartTime
))))
640 EdkLogger
.quiet("\n%s [%s]" % (time
.strftime("%H:%M:%S, %b.%d %Y", time
.localtime()), BuildDuration
))