2 # This file is used to be the main entrance of EOT tool
4 # Copyright (c) 2008 - 2018, 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 *
27 from array
import array
28 from Report
import Report
29 from Common
.BuildVersion
import gBUILD_VERSION
30 from Parser
import ConvertGuid
31 from Common
.LongFilePathSupport
import OpenLongFilePath
as open
35 # A class for Multiple FV
37 class MultipleFv(FirmwareVolume
):
38 def __init__(self
, FvList
):
39 FirmwareVolume
.__init
__(self
)
42 FvName
= os
.path
.splitext(os
.path
.split(FvPath
)[1])[0]
43 Fd
= open(FvPath
, 'rb')
46 Buf
.fromfile(Fd
, os
.path
.getsize(FvPath
))
50 Fv
= FirmwareVolume(FvName
)
51 Fv
.frombuffer(Buf
, 0, len(Buf
))
53 self
.BasicInfo
.append([Fv
.Name
, Fv
.FileSystemGuid
, Fv
.Size
])
54 self
.FfsDict
.append(Fv
.FfsDict
)
58 # This class is used to define Eot main entrance
60 # @param object: Inherited from object class
65 # @param self: The object pointer
67 def __init__(self
, CommandLineOption
=True, IsInit
=True, SourceFileList
=None, \
68 IncludeDirList
=None, DecFileList
=None, GuidList
=None, LogFile
=None,
69 FvFileList
="", MapFileList
="", Report
='Report.html', Dispatch
=None):
70 # Version and Copyright
71 self
.VersionNumber
= ("0.02" + " " + gBUILD_VERSION
)
72 self
.Version
= "%prog Version " + self
.VersionNumber
73 self
.Copyright
= "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved."
77 self
.SourceFileList
= SourceFileList
78 self
.IncludeDirList
= IncludeDirList
79 self
.DecFileList
= DecFileList
80 self
.GuidList
= GuidList
81 self
.LogFile
= LogFile
82 self
.FvFileList
= FvFileList
83 self
.MapFileList
= MapFileList
84 self
.Dispatch
= Dispatch
86 # Check workspace environment
87 if "EFI_SOURCE" not in os
.environ
:
88 if "EDK_SOURCE" not in os
.environ
:
91 EotGlobalData
.gEDK_SOURCE
= os
.path
.normpath(os
.getenv("EDK_SOURCE"))
93 EotGlobalData
.gEFI_SOURCE
= os
.path
.normpath(os
.getenv("EFI_SOURCE"))
94 EotGlobalData
.gEDK_SOURCE
= os
.path
.join(EotGlobalData
.gEFI_SOURCE
, 'Edk')
96 if "WORKSPACE" not in os
.environ
:
97 EdkLogger
.error("EOT", BuildToolError
.ATTRIBUTE_NOT_AVAILABLE
, "Environment variable not found",
98 ExtraData
="WORKSPACE")
100 EotGlobalData
.gWORKSPACE
= os
.path
.normpath(os
.getenv("WORKSPACE"))
102 EotGlobalData
.gMACRO
['WORKSPACE'] = EotGlobalData
.gWORKSPACE
103 EotGlobalData
.gMACRO
['EFI_SOURCE'] = EotGlobalData
.gEFI_SOURCE
104 EotGlobalData
.gMACRO
['EDK_SOURCE'] = EotGlobalData
.gEDK_SOURCE
106 # Parse the options and args
107 if CommandLineOption
:
111 for FvFile
in GetSplitValueList(self
.FvFileList
, ' '):
112 FvFile
= os
.path
.normpath(FvFile
)
113 if not os
.path
.isfile(FvFile
):
114 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "Can not find file %s " % FvFile
)
115 EotGlobalData
.gFV_FILE
.append(FvFile
)
117 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "The fv file list of target platform was not specified")
120 for MapFile
in GetSplitValueList(self
.MapFileList
, ' '):
121 MapFile
= os
.path
.normpath(MapFile
)
122 if not os
.path
.isfile(MapFile
):
123 EdkLogger
.error("Eot", EdkLogger
.EOT_ERROR
, "Can not find file %s " % MapFile
)
124 EotGlobalData
.gMAP_FILE
.append(MapFile
)
126 # Generate source file list
127 self
.GenerateSourceFileList(self
.SourceFileList
, self
.IncludeDirList
)
129 # Generate guid list of dec file list
130 self
.ParseDecFile(self
.DecFileList
)
132 # Generate guid list from GUID list file
133 self
.ParseGuidList(self
.GuidList
)
136 EotGlobalData
.gDb
= Database
.Database(Database
.DATABASE_PATH
)
137 EotGlobalData
.gDb
.InitDatabase(self
.IsInit
)
143 self
.ParseExecutionOrder()
145 # Merge Identifier tables
146 self
.GenerateQueryTable()
148 # Generate report database
149 self
.GenerateReportDatabase()
158 self
.GenerateReport()
161 self
.ConvertLogFile(self
.LogFile
)
164 EdkLogger
.quiet("EOT FINISHED!")
167 EotGlobalData
.gDb
.Close()
169 ## ParseDecFile() method
171 # parse DEC file 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 DecFileList: A list of all DEC files
177 def ParseDecFile(self
, DecFileList
):
179 path
= os
.path
.normpath(DecFileList
)
180 lfr
= open(path
, 'rb')
182 path
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
183 if os
.path
.exists(path
):
184 dfr
= open(path
, 'rb')
186 line
= CleanString(line
)
187 list = line
.split('=')
189 EotGlobalData
.gGuidDict
[list[0].strip()] = GuidStructureStringToGuidString(list[1].strip())
192 ## ParseGuidList() method
194 # Parse Guid list and get all GUID names with GUID values as {GuidName : GuidValue}
195 # The Dict is stored in EotGlobalData.gGuidDict
197 # @param self: The object pointer
198 # @param GuidList: A list of all GUID and its value
200 def ParseGuidList(self
, GuidList
):
201 Path
= os
.path
.join(EotGlobalData
.gWORKSPACE
, GuidList
)
202 if os
.path
.isfile(Path
):
203 for Line
in open(Path
):
204 (GuidName
, GuidValue
) = Line
.split()
205 EotGlobalData
.gGuidDict
[GuidName
] = GuidValue
207 ## ConvertLogFile() method
209 # Parse a real running log file to get real dispatch order
210 # The result is saved to old file name + '.new'
212 # @param self: The object pointer
213 # @param LogFile: A real running log file name
215 def ConvertLogFile(self
, LogFile
):
220 lfr
= open(LogFile
, 'rb')
221 lfw
= open(LogFile
+ '.new', 'wb')
224 line
= line
.replace('.efi', '')
225 index
= line
.find("Loading PEIM at ")
227 newline
.append(line
[index
+ 55 : ])
229 index
= line
.find("Loading driver at ")
231 newline
.append(line
[index
+ 57 : ])
235 lfw
.write(line
+ '\r\n')
242 ## GenerateSourceFileList() method
244 # Generate a list of all source files
245 # 1. Search the file list one by one
246 # 2. Store inf file name with source file names under it like
247 # { INF file name: [source file1, source file2, ...]}
248 # 3. Search the include list to find all .h files
249 # 4. Store source file list to EotGlobalData.gSOURCE_FILES
250 # 5. Store INF file list to EotGlobalData.gINF_FILES
252 # @param self: The object pointer
253 # @param SourceFileList: A list of all source files
254 # @param IncludeFileList: A list of all include files
256 def GenerateSourceFileList(self
, SourceFileList
, IncludeFileList
):
257 EdkLogger
.quiet("Generating source files list ... ")
263 mCurrentSourceFileList
= []
266 sfl
= open(SourceFileList
, 'rb')
268 line
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
269 if line
[-2:].upper() == '.C' or line
[-2:].upper() == '.H':
270 if line
not in mCurrentSourceFileList
:
271 mCurrentSourceFileList
.append(line
)
272 mSourceFileList
.append(line
)
273 EotGlobalData
.gOP_SOURCE_FILES
.write('%s\n' % line
)
274 if line
[-4:].upper() == '.INF':
275 if mCurrentInfFile
!= '':
276 mFileList
[mCurrentInfFile
] = mCurrentSourceFileList
277 mCurrentSourceFileList
= []
278 mCurrentInfFile
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
))
279 EotGlobalData
.gOP_INF
.write('%s\n' % mCurrentInfFile
)
280 if mCurrentInfFile
not in mFileList
:
281 mFileList
[mCurrentInfFile
] = mCurrentSourceFileList
283 # Get all include files from packages
285 ifl
= open(IncludeFileList
, 'rb')
289 newline
= os
.path
.normpath(os
.path
.join(EotGlobalData
.gWORKSPACE
, line
.strip()))
290 for Root
, Dirs
, Files
in os
.walk(str(newline
)):
292 FullPath
= os
.path
.normpath(os
.path
.join(Root
, File
))
293 if FullPath
not in mSourceFileList
and File
[-2:].upper() == '.H':
294 mSourceFileList
.append(FullPath
)
295 EotGlobalData
.gOP_SOURCE_FILES
.write('%s\n' % FullPath
)
296 if FullPath
not in mDecFileList
and File
.upper().find('.DEC') > -1:
297 mDecFileList
.append(FullPath
)
299 EotGlobalData
.gSOURCE_FILES
= mSourceFileList
300 EotGlobalData
.gOP_SOURCE_FILES
.close()
302 EotGlobalData
.gINF_FILES
= mFileList
303 EotGlobalData
.gOP_INF
.close()
305 ## GenerateReport() method
307 # Generate final HTML report
309 # @param self: The object pointer
311 def GenerateReport(self
):
312 EdkLogger
.quiet("Generating report file ... ")
313 Rep
= Report(self
.Report
, EotGlobalData
.gFV
, self
.Dispatch
)
316 ## LoadMapInfo() method
318 # Load map files and parse them
320 # @param self: The object pointer
322 def LoadMapInfo(self
):
323 if EotGlobalData
.gMAP_FILE
!= []:
324 EdkLogger
.quiet("Parsing Map file ... ")
325 EotGlobalData
.gMap
= ParseMapFile(EotGlobalData
.gMAP_FILE
)
327 ## LoadFvInfo() method
329 # Load FV binary files and parse them
331 # @param self: The object pointer
333 def LoadFvInfo(self
):
334 EdkLogger
.quiet("Parsing FV file ... ")
335 EotGlobalData
.gFV
= MultipleFv(EotGlobalData
.gFV_FILE
)
336 EotGlobalData
.gFV
.Dispatch(EotGlobalData
.gDb
)
338 for Protocol
in EotGlobalData
.gProtocolList
:
339 EotGlobalData
.gOP_UN_MATCHED_IN_LIBRARY_CALLING
.write('%s\n' %Protocol
)
341 ## GenerateReportDatabase() method
343 # Generate data for the information needed by report
344 # 1. Update name, macro and value of all found PPI/PROTOCOL GUID
345 # 2. Install hard coded PPI/PROTOCOL
347 # @param self: The object pointer
349 def GenerateReportDatabase(self
):
350 EdkLogger
.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")
352 # Update Protocol/Ppi Guid
353 SqlCommand
= """select DISTINCT GuidName from Report"""
354 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
355 for Record
in RecordSet
:
361 # Find guid value defined in Dec file
362 if GuidName
in EotGlobalData
.gGuidDict
:
363 GuidValue
= EotGlobalData
.gGuidDict
[GuidName
]
364 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
365 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
368 # Search defined Macros for guid name
369 SqlCommand
="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName
370 GuidMacroSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
374 GuidMacro
= GuidMacroSet
[0][0].strip()
377 # Find Guid value of Guid Macro
378 SqlCommand
="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro
, MODEL_IDENTIFIER_MACRO_DEFINE
)
379 GuidValueSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
380 if GuidValueSet
!= []:
381 GuidValue
= GuidValueSet
[0][0]
382 GuidValue
= GuidValue
[GuidValue
.find(GuidMacro
) + len(GuidMacro
) :]
383 GuidValue
= GuidValue
.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()
384 GuidValue
= GuidStructureStringToGuidString(GuidValue
)
385 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
386 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
389 # Update Hard Coded Ppi/Protocol
390 SqlCommand
= """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""
391 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
392 for Record
in RecordSet
:
393 if Record
[1] == 'Protocol':
394 EotGlobalData
.gProtocolList
[Record
[0].lower()] = -2
396 ## GenerateQueryTable() method
398 # Generate two tables improve query performance
400 # @param self: The object pointer
402 def GenerateQueryTable(self
):
403 EdkLogger
.quiet("Generating temp query table for analysis ... ")
404 for Identifier
in EotGlobalData
.gIdentifierTableList
:
405 SqlCommand
= """insert into Query (Name, Modifier, Value, Model)
406 select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \
407 % (Identifier
[0], MODEL_IDENTIFIER_VARIABLE
, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION
)
408 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
409 SqlCommand
= """insert into Query2 (Name, Modifier, Value, Model)
410 select Name, Modifier, Value, Model from %s where Model = %s""" \
411 % (Identifier
[0], MODEL_IDENTIFIER_MACRO_DEFINE
)
412 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
414 ## ParseExecutionOrder() method
416 # Get final execution order
418 # 2. Search all PROTOCOL
420 # @param self: The object pointer
422 def ParseExecutionOrder(self
):
423 EdkLogger
.quiet("Searching Ppi/Protocol ... ")
424 for Identifier
in EotGlobalData
.gIdentifierTableList
:
425 ModuleID
, ModuleName
, ModuleGuid
, SourceFileID
, SourceFileFullPath
, ItemName
, ItemType
, ItemMode
, GuidName
, GuidMacro
, GuidValue
, BelongsToFunction
, Enabled
= \
426 -1, '', '', -1, '', '', '', '', '', '', '', '', 0
428 SourceFileID
= Identifier
[0].replace('Identifier', '')
429 SourceFileFullPath
= Identifier
[1]
430 Identifier
= Identifier
[0]
433 ItemMode
= 'Produced'
434 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
435 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
436 % (Identifier
, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
437 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
439 ItemMode
= 'Produced'
440 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
441 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
442 % (Identifier
, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
443 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
445 SearchPpiCallFunction(Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
447 ItemMode
= 'Consumed'
448 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
449 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
450 % (Identifier
, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
451 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
453 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Ppi', ItemMode
)
455 ItemMode
= 'Callback'
456 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
457 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
458 % (Identifier
, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
459 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
462 ItemMode
= 'Produced'
463 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
464 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
465 % (Identifier
, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING
)
466 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
468 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
469 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
470 % (Identifier
, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING
)
471 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
473 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
475 ItemMode
= 'Consumed'
476 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
477 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
478 % (Identifier
, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
479 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
481 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
482 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
483 % (Identifier
, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
484 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
486 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
488 ItemMode
= 'Callback'
489 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
490 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
491 % (Identifier
, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING
)
492 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
494 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
497 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)
498 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)
499 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)
500 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)
501 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)
502 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)
503 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)
504 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)
505 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)
507 EotGlobalData
.gDb
.Conn
.commit()
510 ## BuildDatabase() methoc
512 # Build the database for target
514 # @param self: The object pointer
516 def BuildDatabase(self
):
518 EotGlobalData
.gDb
.TblReport
.Drop()
519 EotGlobalData
.gDb
.TblReport
.Create()
523 self
.BuildMetaDataFileDatabase(EotGlobalData
.gINF_FILES
)
524 EdkLogger
.quiet("Building database for source code ...")
525 c
.CreateCCodeDB(EotGlobalData
.gSOURCE_FILES
)
526 EdkLogger
.quiet("Building database for source code done!")
528 EotGlobalData
.gIdentifierTableList
= GetTableList((MODEL_FILE_C
, MODEL_FILE_H
), 'Identifier', EotGlobalData
.gDb
)
530 ## BuildMetaDataFileDatabase() method
532 # Build the database for meta data files
534 # @param self: The object pointer
535 # @param Inf_Files: A list for all INF files
537 def BuildMetaDataFileDatabase(self
, Inf_Files
):
538 EdkLogger
.quiet("Building database for meta data files ...")
539 for InfFile
in Inf_Files
:
540 EdkLogger
.quiet("Parsing %s ..." % str(InfFile
))
541 EdkInfParser(InfFile
, EotGlobalData
.gDb
, Inf_Files
[InfFile
], '')
543 EotGlobalData
.gDb
.Conn
.commit()
544 EdkLogger
.quiet("Building database for meta data files done!")
546 ## ParseOption() method
548 # Parse command line options
550 # @param self: The object pointer
552 def ParseOption(self
):
553 (Options
, Target
) = self
.EotOptionParser()
556 self
.SetLogLevel(Options
)
558 if Options
.FvFileList
:
559 self
.FvFileList
= Options
.FvFileList
561 if Options
.MapFileList
:
562 self
.MapFileList
= Options
.FvMapFileList
564 if Options
.SourceFileList
:
565 self
.SourceFileList
= Options
.SourceFileList
567 if Options
.IncludeDirList
:
568 self
.IncludeDirList
= Options
.IncludeDirList
570 if Options
.DecFileList
:
571 self
.DecFileList
= Options
.DecFileList
574 self
.GuidList
= Options
.GuidList
577 self
.LogFile
= Options
.LogFile
579 if Options
.keepdatabase
:
582 ## SetLogLevel() method
584 # Set current log level of the tool based on args
586 # @param self: The object pointer
587 # @param Option: The option list including log level setting
589 def SetLogLevel(self
, Option
):
590 if Option
.verbose
is not None:
591 EdkLogger
.SetLevel(EdkLogger
.VERBOSE
)
592 elif Option
.quiet
is not None:
593 EdkLogger
.SetLevel(EdkLogger
.QUIET
)
594 elif Option
.debug
is not None:
595 EdkLogger
.SetLevel(Option
.debug
+ 1)
597 EdkLogger
.SetLevel(EdkLogger
.INFO
)
599 ## EotOptionParser() method
601 # Using standard Python module optparse to parse command line option of this tool.
603 # @param self: The object pointer
605 # @retval Opt A optparse.Values object containing the parsed options
606 # @retval Args Target of build command
608 def EotOptionParser(self
):
609 Parser
= OptionParser(description
= self
.Copyright
, version
= self
.Version
, prog
= "Eot.exe", usage
= "%prog [options]")
610 Parser
.add_option("-m", "--makefile filename", action
="store", type="string", dest
='MakeFile',
611 help="Specify a makefile for the platform.")
612 Parser
.add_option("-c", "--dsc filename", action
="store", type="string", dest
="DscFile",
613 help="Specify a dsc file for the platform.")
614 Parser
.add_option("-f", "--fv filename", action
="store", type="string", dest
="FvFileList",
615 help="Specify fv file list, quoted by \"\".")
616 Parser
.add_option("-a", "--map filename", action
="store", type="string", dest
="MapFileList",
617 help="Specify map file list, quoted by \"\".")
618 Parser
.add_option("-s", "--source files", action
="store", type="string", dest
="SourceFileList",
619 help="Specify source file list by a file")
620 Parser
.add_option("-i", "--include dirs", action
="store", type="string", dest
="IncludeDirList",
621 help="Specify include dir list by a file")
622 Parser
.add_option("-e", "--dec files", action
="store", type="string", dest
="DecFileList",
623 help="Specify dec file list by a file")
624 Parser
.add_option("-g", "--guid list", action
="store", type="string", dest
="GuidList",
625 help="Specify guid file list by a file")
626 Parser
.add_option("-l", "--log filename", action
="store", type="string", dest
="LogFile",
627 help="Specify real execution log file")
629 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.")
631 Parser
.add_option("-q", "--quiet", action
="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
632 Parser
.add_option("-v", "--verbose", action
="store_true", type=None, help="Turn on verbose output with informational messages printed, "\
633 "including library instances selected, final dependency expression, "\
634 "and warning messages, etc.")
635 Parser
.add_option("-d", "--debug", action
="store", type="int", help="Enable debug messages at specified level.")
637 (Opt
, Args
)=Parser
.parse_args()
643 # This acts like the main() function for the script, unless it is 'import'ed into another
646 if __name__
== '__main__':
647 # Initialize log system
648 EdkLogger
.Initialize()
649 EdkLogger
.IsRaiseError
= False
650 EdkLogger
.quiet(time
.strftime("%H:%M:%S, %b.%d %Y ", time
.localtime()) + "[00:00]" + "\n")
652 StartTime
= time
.clock()
654 FinishTime
= time
.clock()
656 BuildDuration
= time
.strftime("%M:%S", time
.gmtime(int(round(FinishTime
- StartTime
))))
657 EdkLogger
.quiet("\n%s [%s]" % (time
.strftime("%H:%M:%S, %b.%d %Y", time
.localtime()), BuildDuration
))