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
.Misc
import ParseConsoleLog
31 from Common
.BuildVersion
import gBUILD_VERSION
32 from Parser
import ConvertGuid
33 from Common
.LongFilePathSupport
import OpenLongFilePath
as open
37 # This class is used to define Eot main entrance
39 # @param object: Inherited from object class
44 # @param self: The object pointer
46 def __init__(self
, CommandLineOption
=True, IsInit
=True, SourceFileList
=None, \
47 IncludeDirList
=None, DecFileList
=None, GuidList
=None, LogFile
=None,
48 FvFileList
="", MapFileList
="", Report
='Report.html', Dispatch
=None):
49 # Version and Copyright
50 self
.VersionNumber
= ("0.02" + " " + gBUILD_VERSION
)
51 self
.Version
= "%prog Version " + self
.VersionNumber
52 self
.Copyright
= "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved."
56 self
.SourceFileList
= SourceFileList
57 self
.IncludeDirList
= IncludeDirList
58 self
.DecFileList
= DecFileList
59 self
.GuidList
= GuidList
60 self
.LogFile
= LogFile
61 self
.FvFileList
= FvFileList
62 self
.MapFileList
= MapFileList
63 self
.Dispatch
= Dispatch
65 # Check workspace environment
66 if "EFI_SOURCE" not in os
.environ
:
67 if "EDK_SOURCE" not in os
.environ
:
70 EotGlobalData
.gEDK_SOURCE
= os
.path
.normpath(os
.getenv("EDK_SOURCE"))
72 EotGlobalData
.gEFI_SOURCE
= os
.path
.normpath(os
.getenv("EFI_SOURCE"))
73 EotGlobalData
.gEDK_SOURCE
= os
.path
.join(EotGlobalData
.gEFI_SOURCE
, 'Edk')
75 if "WORKSPACE" not in os
.environ
:
76 EdkLogger
.error("EOT", BuildToolError
.ATTRIBUTE_NOT_AVAILABLE
, "Environment variable not found",
77 ExtraData
="WORKSPACE")
79 EotGlobalData
.gWORKSPACE
= os
.path
.normpath(os
.getenv("WORKSPACE"))
81 EotGlobalData
.gMACRO
['WORKSPACE'] = EotGlobalData
.gWORKSPACE
82 EotGlobalData
.gMACRO
['EFI_SOURCE'] = EotGlobalData
.gEFI_SOURCE
83 EotGlobalData
.gMACRO
['EDK_SOURCE'] = EotGlobalData
.gEDK_SOURCE
85 # Parse the options and args
90 for FvFile
in GetSplitValueList(self
.FvFileList
, ' '):
91 FvFile
= os
.path
.normpath(FvFile
)
92 if not os
.path
.isfile(FvFile
):
93 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "Can not find file %s " % FvFile
)
94 EotGlobalData
.gFV_FILE
.append(FvFile
)
96 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "The fv file list of target platform was not specified")
99 for MapFile
in GetSplitValueList(self
.MapFileList
, ' '):
100 MapFile
= os
.path
.normpath(MapFile
)
101 if not os
.path
.isfile(MapFile
):
102 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "Can not find file %s " % MapFile
)
103 EotGlobalData
.gMAP_FILE
.append(MapFile
)
105 # Generate source file list
106 self
.GenerateSourceFileList(self
.SourceFileList
, self
.IncludeDirList
)
108 # Generate guid list of dec file list
109 self
.ParseDecFile(self
.DecFileList
)
111 # Generate guid list from GUID list file
112 self
.ParseGuidList(self
.GuidList
)
115 EotGlobalData
.gDb
= Database
.Database(Database
.DATABASE_PATH
)
116 EotGlobalData
.gDb
.InitDatabase(self
.IsInit
)
122 self
.ParseExecutionOrder()
124 # Merge Identifier tables
125 self
.GenerateQueryTable()
127 # Generate report database
128 self
.GenerateReportDatabase()
137 self
.GenerateReport()
140 self
.ConvertLogFile(self
.LogFile
)
143 EdkLogger
.quiet("EOT FINISHED!")
146 EotGlobalData
.gDb
.Close()
148 ## ParseDecFile() method
150 # parse DEC file and get all GUID names with GUID values as {GuidName : GuidValue}
151 # The Dict is stored in EotGlobalData.gGuidDict
153 # @param self: The object pointer
154 # @param DecFileList: A list of all DEC files
156 def ParseDecFile(self
, DecFileList
):
158 path
= os
.path
.normpath(DecFileList
)
159 lfr
= open(path
, 'rb')
161 path
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
162 if os
.path
.exists(path
):
163 dfr
= open(path
, 'rb')
165 line
= CleanString(line
)
166 list = line
.split('=')
168 EotGlobalData
.gGuidDict
[list[0].strip()] = GuidStructureStringToGuidString(list[1].strip())
171 ## ParseGuidList() method
173 # Parse Guid list and get all GUID names with GUID values as {GuidName : GuidValue}
174 # The Dict is stored in EotGlobalData.gGuidDict
176 # @param self: The object pointer
177 # @param GuidList: A list of all GUID and its value
179 def ParseGuidList(self
, GuidList
):
180 Path
= os
.path
.join(EotGlobalData
.gWORKSPACE
, GuidList
)
181 if os
.path
.isfile(Path
):
182 for Line
in open(Path
):
183 (GuidName
, GuidValue
) = Line
.split()
184 EotGlobalData
.gGuidDict
[GuidName
] = GuidValue
186 ## ConvertLogFile() method
188 # Parse a real running log file to get real dispatch order
189 # The result is saved to old file name + '.new'
191 # @param self: The object pointer
192 # @param LogFile: A real running log file name
194 def ConvertLogFile(self
, LogFile
):
199 lfr
= open(LogFile
, 'rb')
200 lfw
= open(LogFile
+ '.new', 'wb')
203 line
= line
.replace('.efi', '')
204 index
= line
.find("Loading PEIM at ")
206 newline
.append(line
[index
+ 55 : ])
208 index
= line
.find("Loading driver at ")
210 newline
.append(line
[index
+ 57 : ])
214 lfw
.write(line
+ '\r\n')
221 ## GenerateSourceFileList() method
223 # Generate a list of all source files
224 # 1. Search the file list one by one
225 # 2. Store inf file name with source file names under it like
226 # { INF file name: [source file1, source file2, ...]}
227 # 3. Search the include list to find all .h files
228 # 4. Store source file list to EotGlobalData.gSOURCE_FILES
229 # 5. Store INF file list to EotGlobalData.gINF_FILES
231 # @param self: The object pointer
232 # @param SourceFileList: A list of all source files
233 # @param IncludeFileList: A list of all include files
235 def GenerateSourceFileList(self
, SourceFileList
, IncludeFileList
):
236 EdkLogger
.quiet("Generating source files list ... ")
242 mCurrentSourceFileList
= []
245 sfl
= open(SourceFileList
, 'rb')
247 line
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
248 if line
[-2:].upper() == '.C' or line
[-2:].upper() == '.H':
249 if line
not in mCurrentSourceFileList
:
250 mCurrentSourceFileList
.append(line
)
251 mSourceFileList
.append(line
)
252 EotGlobalData
.gOP_SOURCE_FILES
.write('%s\n' % line
)
253 if line
[-4:].upper() == '.INF':
254 if mCurrentInfFile
!= '':
255 mFileList
[mCurrentInfFile
] = mCurrentSourceFileList
256 mCurrentSourceFileList
= []
257 mCurrentInfFile
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
))
258 EotGlobalData
.gOP_INF
.write('%s\n' % mCurrentInfFile
)
259 if mCurrentInfFile
not in mFileList
:
260 mFileList
[mCurrentInfFile
] = mCurrentSourceFileList
262 # Get all include files from packages
264 ifl
= open(IncludeFileList
, 'rb')
268 newline
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
269 for Root
, Dirs
, Files
in os
.walk(str(newline
)):
271 FullPath
= os
.path
.normpath(os
.path
.join(Root
, File
))
272 if FullPath
not in mSourceFileList
and File
[-2:].upper() == '.H':
273 mSourceFileList
.append(FullPath
)
274 EotGlobalData
.gOP_SOURCE_FILES
.write('%s\n' % FullPath
)
275 if FullPath
not in mDecFileList
and File
.upper().find('.DEC') > -1:
276 mDecFileList
.append(FullPath
)
278 EotGlobalData
.gSOURCE_FILES
= mSourceFileList
279 EotGlobalData
.gOP_SOURCE_FILES
.close()
281 EotGlobalData
.gINF_FILES
= mFileList
282 EotGlobalData
.gOP_INF
.close()
284 EotGlobalData
.gDEC_FILES
= mDecFileList
287 ## GenerateReport() method
289 # Generate final HTML report
291 # @param self: The object pointer
293 def GenerateReport(self
):
294 EdkLogger
.quiet("Generating report file ... ")
295 Rep
= Report(self
.Report
, EotGlobalData
.gFV
, self
.Dispatch
)
298 ## LoadMapInfo() method
300 # Load map files and parse them
302 # @param self: The object pointer
304 def LoadMapInfo(self
):
305 if EotGlobalData
.gMAP_FILE
!= []:
306 EdkLogger
.quiet("Parsing Map file ... ")
307 EotGlobalData
.gMap
= ParseMapFile(EotGlobalData
.gMAP_FILE
)
309 ## LoadFvInfo() method
311 # Load FV binary files and parse them
313 # @param self: The object pointer
315 def LoadFvInfo(self
):
316 EdkLogger
.quiet("Parsing FV file ... ")
317 EotGlobalData
.gFV
= MultipleFv(EotGlobalData
.gFV_FILE
)
318 EotGlobalData
.gFV
.Dispatch(EotGlobalData
.gDb
)
320 for Protocol
in EotGlobalData
.gProtocolList
:
321 EotGlobalData
.gOP_UN_MATCHED_IN_LIBRARY_CALLING
.write('%s\n' %Protocol
)
323 ## GenerateReportDatabase() method
325 # Generate data for the information needed by report
326 # 1. Update name, macro and value of all found PPI/PROTOCOL GUID
327 # 2. Install hard coded PPI/PROTOCOL
329 # @param self: The object pointer
331 def GenerateReportDatabase(self
):
332 EdkLogger
.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")
334 # Update Protocol/Ppi Guid
335 SqlCommand
= """select DISTINCT GuidName from Report"""
336 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
337 for Record
in RecordSet
:
343 # Find guid value defined in Dec file
344 if GuidName
in EotGlobalData
.gGuidDict
:
345 GuidValue
= EotGlobalData
.gGuidDict
[GuidName
]
346 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
347 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
350 # Search defined Macros for guid name
351 SqlCommand
="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName
352 GuidMacroSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
356 GuidMacro
= GuidMacroSet
[0][0].strip()
359 # Find Guid value of Guid Macro
360 SqlCommand
="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro
, MODEL_IDENTIFIER_MACRO_DEFINE
)
361 GuidValueSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
362 if GuidValueSet
!= []:
363 GuidValue
= GuidValueSet
[0][0]
364 GuidValue
= GuidValue
[GuidValue
.find(GuidMacro
) + len(GuidMacro
) :]
365 GuidValue
= GuidValue
.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()
366 GuidValue
= GuidStructureStringToGuidString(GuidValue
)
367 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
368 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
371 # Update Hard Coded Ppi/Protocol
372 SqlCommand
= """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""
373 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
374 for Record
in RecordSet
:
375 if Record
[1] == 'Ppi':
376 EotGlobalData
.gPpiList
[Record
[0].lower()] = -2
377 if Record
[1] == 'Protocol':
378 EotGlobalData
.gProtocolList
[Record
[0].lower()] = -2
380 ## GenerateQueryTable() method
382 # Generate two tables improve query performance
384 # @param self: The object pointer
386 def GenerateQueryTable(self
):
387 EdkLogger
.quiet("Generating temp query table for analysis ... ")
388 for Identifier
in EotGlobalData
.gIdentifierTableList
:
389 SqlCommand
= """insert into Query (Name, Modifier, Value, Model)
390 select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \
391 % (Identifier
[0], MODEL_IDENTIFIER_VARIABLE
, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION
)
392 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
393 SqlCommand
= """insert into Query2 (Name, Modifier, Value, Model)
394 select Name, Modifier, Value, Model from %s where Model = %s""" \
395 % (Identifier
[0], MODEL_IDENTIFIER_MACRO_DEFINE
)
396 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
398 ## ParseExecutionOrder() method
400 # Get final execution order
402 # 2. Search all PROTOCOL
404 # @param self: The object pointer
406 def ParseExecutionOrder(self
):
407 EdkLogger
.quiet("Searching Ppi/Protocol ... ")
408 for Identifier
in EotGlobalData
.gIdentifierTableList
:
409 ModuleID
, ModuleName
, ModuleGuid
, SourceFileID
, SourceFileFullPath
, ItemName
, ItemType
, ItemMode
, GuidName
, GuidMacro
, GuidValue
, BelongsToFunction
, Enabled
= \
410 -1, '', '', -1, '', '', '', '', '', '', '', '', 0
412 SourceFileID
= Identifier
[0].replace('Identifier', '')
413 SourceFileFullPath
= Identifier
[1]
414 Identifier
= Identifier
[0]
417 ItemMode
= 'Produced'
418 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
419 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
420 % (Identifier
, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
421 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
423 ItemMode
= 'Produced'
424 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
425 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
426 % (Identifier
, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
427 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
429 SearchPpiCallFunction(Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
431 ItemMode
= 'Consumed'
432 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
433 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
434 % (Identifier
, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
435 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
437 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Ppi', ItemMode
)
439 ItemMode
= 'Callback'
440 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
441 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
442 % (Identifier
, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
443 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
446 ItemMode
= 'Produced'
447 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
448 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
449 % (Identifier
, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING
)
450 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
452 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
453 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
454 % (Identifier
, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING
)
455 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
457 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
459 ItemMode
= 'Consumed'
460 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
461 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
462 % (Identifier
, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
463 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
465 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
466 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
467 % (Identifier
, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
468 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
470 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
472 ItemMode
= 'Callback'
473 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
474 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
475 % (Identifier
, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING
)
476 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
478 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
481 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)
482 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)
483 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)
484 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)
485 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)
486 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)
487 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)
488 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)
489 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)
491 EotGlobalData
.gDb
.Conn
.commit()
494 ## BuildDatabase() methoc
496 # Build the database for target
498 # @param self: The object pointer
500 def BuildDatabase(self
):
502 EotGlobalData
.gDb
.TblReport
.Drop()
503 EotGlobalData
.gDb
.TblReport
.Create()
507 self
.BuildMetaDataFileDatabase(EotGlobalData
.gINF_FILES
)
508 EdkLogger
.quiet("Building database for source code ...")
509 c
.CreateCCodeDB(EotGlobalData
.gSOURCE_FILES
)
510 EdkLogger
.quiet("Building database for source code done!")
512 EotGlobalData
.gIdentifierTableList
= GetTableList((MODEL_FILE_C
, MODEL_FILE_H
), 'Identifier', EotGlobalData
.gDb
)
514 ## BuildMetaDataFileDatabase() method
516 # Build the database for meta data files
518 # @param self: The object pointer
519 # @param Inf_Files: A list for all INF files
521 def BuildMetaDataFileDatabase(self
, Inf_Files
):
522 EdkLogger
.quiet("Building database for meta data files ...")
523 for InfFile
in Inf_Files
:
524 EdkLogger
.quiet("Parsing %s ..." % str(InfFile
))
525 EdkInfParser(InfFile
, EotGlobalData
.gDb
, Inf_Files
[InfFile
], '')
527 EotGlobalData
.gDb
.Conn
.commit()
528 EdkLogger
.quiet("Building database for meta data files done!")
530 ## ParseOption() method
532 # Parse command line options
534 # @param self: The object pointer
536 def ParseOption(self
):
537 (Options
, Target
) = self
.EotOptionParser()
540 self
.SetLogLevel(Options
)
542 if Options
.FvFileList
:
543 self
.FvFileList
= Options
.FvFileList
545 if Options
.MapFileList
:
546 self
.MapFileList
= Options
.FvMapFileList
548 if Options
.SourceFileList
:
549 self
.SourceFileList
= Options
.SourceFileList
551 if Options
.IncludeDirList
:
552 self
.IncludeDirList
= Options
.IncludeDirList
554 if Options
.DecFileList
:
555 self
.DecFileList
= Options
.DecFileList
558 self
.GuidList
= Options
.GuidList
561 self
.LogFile
= Options
.LogFile
563 if Options
.keepdatabase
:
566 ## SetLogLevel() method
568 # Set current log level of the tool based on args
570 # @param self: The object pointer
571 # @param Option: The option list including log level setting
573 def SetLogLevel(self
, Option
):
574 if Option
.verbose
is not None:
575 EdkLogger
.SetLevel(EdkLogger
.VERBOSE
)
576 elif Option
.quiet
is not None:
577 EdkLogger
.SetLevel(EdkLogger
.QUIET
)
578 elif Option
.debug
is not None:
579 EdkLogger
.SetLevel(Option
.debug
+ 1)
581 EdkLogger
.SetLevel(EdkLogger
.INFO
)
583 ## EotOptionParser() method
585 # Using standard Python module optparse to parse command line option of this tool.
587 # @param self: The object pointer
589 # @retval Opt A optparse.Values object containing the parsed options
590 # @retval Args Target of build command
592 def EotOptionParser(self
):
593 Parser
= OptionParser(description
= self
.Copyright
, version
= self
.Version
, prog
= "Eot.exe", usage
= "%prog [options]")
594 Parser
.add_option("-m", "--makefile filename", action
="store", type="string", dest
='MakeFile',
595 help="Specify a makefile for the platform.")
596 Parser
.add_option("-c", "--dsc filename", action
="store", type="string", dest
="DscFile",
597 help="Specify a dsc file for the platform.")
598 Parser
.add_option("-f", "--fv filename", action
="store", type="string", dest
="FvFileList",
599 help="Specify fv file list, quoted by \"\".")
600 Parser
.add_option("-a", "--map filename", action
="store", type="string", dest
="MapFileList",
601 help="Specify map file list, quoted by \"\".")
602 Parser
.add_option("-s", "--source files", action
="store", type="string", dest
="SourceFileList",
603 help="Specify source file list by a file")
604 Parser
.add_option("-i", "--include dirs", action
="store", type="string", dest
="IncludeDirList",
605 help="Specify include dir list by a file")
606 Parser
.add_option("-e", "--dec files", action
="store", type="string", dest
="DecFileList",
607 help="Specify dec file list by a file")
608 Parser
.add_option("-g", "--guid list", action
="store", type="string", dest
="GuidList",
609 help="Specify guid file list by a file")
610 Parser
.add_option("-l", "--log filename", action
="store", type="string", dest
="LogFile",
611 help="Specify real execution log file")
613 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.")
615 Parser
.add_option("-q", "--quiet", action
="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
616 Parser
.add_option("-v", "--verbose", action
="store_true", type=None, help="Turn on verbose output with informational messages printed, "\
617 "including library instances selected, final dependency expression, "\
618 "and warning messages, etc.")
619 Parser
.add_option("-d", "--debug", action
="store", type="int", help="Enable debug messages at specified level.")
621 (Opt
, Args
)=Parser
.parse_args()
627 # This acts like the main() function for the script, unless it is 'import'ed into another
630 if __name__
== '__main__':
631 # Initialize log system
632 EdkLogger
.Initialize()
633 EdkLogger
.IsRaiseError
= False
634 EdkLogger
.quiet(time
.strftime("%H:%M:%S, %b.%d %Y ", time
.localtime()) + "[00:00]" + "\n")
636 StartTime
= time
.clock()
638 FinishTime
= time
.clock()
640 BuildDuration
= time
.strftime("%M:%S", time
.gmtime(int(round(FinishTime
- StartTime
))))
641 EdkLogger
.quiet("\n%s [%s]" % (time
.strftime("%H:%M:%S, %b.%d %Y", time
.localtime()), BuildDuration
))