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 EotGlobalData
.gDEC_FILES
= mDecFileList
308 ## GenerateReport() method
310 # Generate final HTML report
312 # @param self: The object pointer
314 def GenerateReport(self
):
315 EdkLogger
.quiet("Generating report file ... ")
316 Rep
= Report(self
.Report
, EotGlobalData
.gFV
, self
.Dispatch
)
319 ## LoadMapInfo() method
321 # Load map files and parse them
323 # @param self: The object pointer
325 def LoadMapInfo(self
):
326 if EotGlobalData
.gMAP_FILE
!= []:
327 EdkLogger
.quiet("Parsing Map file ... ")
328 EotGlobalData
.gMap
= ParseMapFile(EotGlobalData
.gMAP_FILE
)
330 ## LoadFvInfo() method
332 # Load FV binary files and parse them
334 # @param self: The object pointer
336 def LoadFvInfo(self
):
337 EdkLogger
.quiet("Parsing FV file ... ")
338 EotGlobalData
.gFV
= MultipleFv(EotGlobalData
.gFV_FILE
)
339 EotGlobalData
.gFV
.Dispatch(EotGlobalData
.gDb
)
341 for Protocol
in EotGlobalData
.gProtocolList
:
342 EotGlobalData
.gOP_UN_MATCHED_IN_LIBRARY_CALLING
.write('%s\n' %Protocol
)
344 ## GenerateReportDatabase() method
346 # Generate data for the information needed by report
347 # 1. Update name, macro and value of all found PPI/PROTOCOL GUID
348 # 2. Install hard coded PPI/PROTOCOL
350 # @param self: The object pointer
352 def GenerateReportDatabase(self
):
353 EdkLogger
.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")
355 # Update Protocol/Ppi Guid
356 SqlCommand
= """select DISTINCT GuidName from Report"""
357 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
358 for Record
in RecordSet
:
364 # Find guid value defined in Dec file
365 if GuidName
in EotGlobalData
.gGuidDict
:
366 GuidValue
= EotGlobalData
.gGuidDict
[GuidName
]
367 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
368 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
371 # Search defined Macros for guid name
372 SqlCommand
="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName
373 GuidMacroSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
377 GuidMacro
= GuidMacroSet
[0][0].strip()
380 # Find Guid value of Guid Macro
381 SqlCommand
="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro
, MODEL_IDENTIFIER_MACRO_DEFINE
)
382 GuidValueSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
383 if GuidValueSet
!= []:
384 GuidValue
= GuidValueSet
[0][0]
385 GuidValue
= GuidValue
[GuidValue
.find(GuidMacro
) + len(GuidMacro
) :]
386 GuidValue
= GuidValue
.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()
387 GuidValue
= GuidStructureStringToGuidString(GuidValue
)
388 SqlCommand
= """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro
, GuidValue
, GuidName
)
389 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
392 # Update Hard Coded Ppi/Protocol
393 SqlCommand
= """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""
394 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
395 for Record
in RecordSet
:
396 if Record
[1] == 'Ppi':
397 EotGlobalData
.gPpiList
[Record
[0].lower()] = -2
398 if Record
[1] == 'Protocol':
399 EotGlobalData
.gProtocolList
[Record
[0].lower()] = -2
401 ## GenerateQueryTable() method
403 # Generate two tables improve query performance
405 # @param self: The object pointer
407 def GenerateQueryTable(self
):
408 EdkLogger
.quiet("Generating temp query table for analysis ... ")
409 for Identifier
in EotGlobalData
.gIdentifierTableList
:
410 SqlCommand
= """insert into Query (Name, Modifier, Value, Model)
411 select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \
412 % (Identifier
[0], MODEL_IDENTIFIER_VARIABLE
, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION
)
413 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
414 SqlCommand
= """insert into Query2 (Name, Modifier, Value, Model)
415 select Name, Modifier, Value, Model from %s where Model = %s""" \
416 % (Identifier
[0], MODEL_IDENTIFIER_MACRO_DEFINE
)
417 EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
419 ## ParseExecutionOrder() method
421 # Get final execution order
423 # 2. Search all PROTOCOL
425 # @param self: The object pointer
427 def ParseExecutionOrder(self
):
428 EdkLogger
.quiet("Searching Ppi/Protocol ... ")
429 for Identifier
in EotGlobalData
.gIdentifierTableList
:
430 ModuleID
, ModuleName
, ModuleGuid
, SourceFileID
, SourceFileFullPath
, ItemName
, ItemType
, ItemMode
, GuidName
, GuidMacro
, GuidValue
, BelongsToFunction
, Enabled
= \
431 -1, '', '', -1, '', '', '', '', '', '', '', '', 0
433 SourceFileID
= Identifier
[0].replace('Identifier', '')
434 SourceFileFullPath
= Identifier
[1]
435 Identifier
= Identifier
[0]
438 ItemMode
= 'Produced'
439 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
440 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
441 % (Identifier
, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
442 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
444 ItemMode
= 'Produced'
445 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
446 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
447 % (Identifier
, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
448 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
450 SearchPpiCallFunction(Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
452 ItemMode
= 'Consumed'
453 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
454 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
455 % (Identifier
, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
456 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
458 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Ppi', ItemMode
)
460 ItemMode
= 'Callback'
461 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
462 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
463 % (Identifier
, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING
)
464 SearchPpi(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
)
467 ItemMode
= 'Produced'
468 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
469 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
470 % (Identifier
, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING
)
471 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
473 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
474 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
475 % (Identifier
, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING
)
476 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 2)
478 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
480 ItemMode
= 'Consumed'
481 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
482 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
483 % (Identifier
, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
484 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
486 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
487 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
488 % (Identifier
, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING
)
489 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 1)
491 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
493 ItemMode
= 'Callback'
494 SqlCommand
= """select Value, Name, BelongsToFile, StartLine, EndLine from %s
495 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
496 % (Identifier
, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING
)
497 SearchProtocols(SqlCommand
, Identifier
, SourceFileID
, SourceFileFullPath
, ItemMode
, 0)
499 SearchFunctionCalling(Identifier
, SourceFileID
, SourceFileFullPath
, 'Protocol', ItemMode
)
502 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)
503 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)
504 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)
505 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)
506 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)
507 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)
508 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)
509 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)
510 EotGlobalData
.gDb
.TblReport
.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)
512 EotGlobalData
.gDb
.Conn
.commit()
515 ## BuildDatabase() methoc
517 # Build the database for target
519 # @param self: The object pointer
521 def BuildDatabase(self
):
523 EotGlobalData
.gDb
.TblReport
.Drop()
524 EotGlobalData
.gDb
.TblReport
.Create()
528 self
.BuildMetaDataFileDatabase(EotGlobalData
.gINF_FILES
)
529 EdkLogger
.quiet("Building database for source code ...")
530 c
.CreateCCodeDB(EotGlobalData
.gSOURCE_FILES
)
531 EdkLogger
.quiet("Building database for source code done!")
533 EotGlobalData
.gIdentifierTableList
= GetTableList((MODEL_FILE_C
, MODEL_FILE_H
), 'Identifier', EotGlobalData
.gDb
)
535 ## BuildMetaDataFileDatabase() method
537 # Build the database for meta data files
539 # @param self: The object pointer
540 # @param Inf_Files: A list for all INF files
542 def BuildMetaDataFileDatabase(self
, Inf_Files
):
543 EdkLogger
.quiet("Building database for meta data files ...")
544 for InfFile
in Inf_Files
:
545 EdkLogger
.quiet("Parsing %s ..." % str(InfFile
))
546 EdkInfParser(InfFile
, EotGlobalData
.gDb
, Inf_Files
[InfFile
], '')
548 EotGlobalData
.gDb
.Conn
.commit()
549 EdkLogger
.quiet("Building database for meta data files done!")
551 ## ParseOption() method
553 # Parse command line options
555 # @param self: The object pointer
557 def ParseOption(self
):
558 (Options
, Target
) = self
.EotOptionParser()
561 self
.SetLogLevel(Options
)
563 if Options
.FvFileList
:
564 self
.FvFileList
= Options
.FvFileList
566 if Options
.MapFileList
:
567 self
.MapFileList
= Options
.FvMapFileList
569 if Options
.SourceFileList
:
570 self
.SourceFileList
= Options
.SourceFileList
572 if Options
.IncludeDirList
:
573 self
.IncludeDirList
= Options
.IncludeDirList
575 if Options
.DecFileList
:
576 self
.DecFileList
= Options
.DecFileList
579 self
.GuidList
= Options
.GuidList
582 self
.LogFile
= Options
.LogFile
584 if Options
.keepdatabase
:
587 ## SetLogLevel() method
589 # Set current log level of the tool based on args
591 # @param self: The object pointer
592 # @param Option: The option list including log level setting
594 def SetLogLevel(self
, Option
):
595 if Option
.verbose
is not None:
596 EdkLogger
.SetLevel(EdkLogger
.VERBOSE
)
597 elif Option
.quiet
is not None:
598 EdkLogger
.SetLevel(EdkLogger
.QUIET
)
599 elif Option
.debug
is not None:
600 EdkLogger
.SetLevel(Option
.debug
+ 1)
602 EdkLogger
.SetLevel(EdkLogger
.INFO
)
604 ## EotOptionParser() method
606 # Using standard Python module optparse to parse command line option of this tool.
608 # @param self: The object pointer
610 # @retval Opt A optparse.Values object containing the parsed options
611 # @retval Args Target of build command
613 def EotOptionParser(self
):
614 Parser
= OptionParser(description
= self
.Copyright
, version
= self
.Version
, prog
= "Eot.exe", usage
= "%prog [options]")
615 Parser
.add_option("-m", "--makefile filename", action
="store", type="string", dest
='MakeFile',
616 help="Specify a makefile for the platform.")
617 Parser
.add_option("-c", "--dsc filename", action
="store", type="string", dest
="DscFile",
618 help="Specify a dsc file for the platform.")
619 Parser
.add_option("-f", "--fv filename", action
="store", type="string", dest
="FvFileList",
620 help="Specify fv file list, quoted by \"\".")
621 Parser
.add_option("-a", "--map filename", action
="store", type="string", dest
="MapFileList",
622 help="Specify map file list, quoted by \"\".")
623 Parser
.add_option("-s", "--source files", action
="store", type="string", dest
="SourceFileList",
624 help="Specify source file list by a file")
625 Parser
.add_option("-i", "--include dirs", action
="store", type="string", dest
="IncludeDirList",
626 help="Specify include dir list by a file")
627 Parser
.add_option("-e", "--dec files", action
="store", type="string", dest
="DecFileList",
628 help="Specify dec file list by a file")
629 Parser
.add_option("-g", "--guid list", action
="store", type="string", dest
="GuidList",
630 help="Specify guid file list by a file")
631 Parser
.add_option("-l", "--log filename", action
="store", type="string", dest
="LogFile",
632 help="Specify real execution log file")
634 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.")
636 Parser
.add_option("-q", "--quiet", action
="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
637 Parser
.add_option("-v", "--verbose", action
="store_true", type=None, help="Turn on verbose output with informational messages printed, "\
638 "including library instances selected, final dependency expression, "\
639 "and warning messages, etc.")
640 Parser
.add_option("-d", "--debug", action
="store", type="int", help="Enable debug messages at specified level.")
642 (Opt
, Args
)=Parser
.parse_args()
648 # This acts like the main() function for the script, unless it is 'import'ed into another
651 if __name__
== '__main__':
652 # Initialize log system
653 EdkLogger
.Initialize()
654 EdkLogger
.IsRaiseError
= False
655 EdkLogger
.quiet(time
.strftime("%H:%M:%S, %b.%d %Y ", time
.localtime()) + "[00:00]" + "\n")
657 StartTime
= time
.clock()
659 FinishTime
= time
.clock()
661 BuildDuration
= time
.strftime("%M:%S", time
.gmtime(int(round(FinishTime
- StartTime
))))
662 EdkLogger
.quiet("\n%s [%s]" % (time
.strftime("%H:%M:%S, %b.%d %Y", time
.localtime()), BuildDuration
))