BaseTools/Ecc/EOT: Add Python 3 support on ECC and EOT tools.

1. Add Python 3 support on ECC and EOT tools
2. Add C grammar file of ANTLR4 and fix some bugs

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Hess Chen
2018-10-09 12:44:35 +08:00
committed by Yonghong Zhu
parent 472eb3b896
commit 22c4de1ac8
20 changed files with 14963 additions and 47753 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,672 @@
# Generated from C.g4 by ANTLR 4.7.1
from antlr4 import *
if __name__ is not None and "." in __name__:
from .CParser import CParser
else:
from CParser import CParser
## @file
# The file defines the parser for C source files.
#
# THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE.
# This file is generated by running:
# java org.antlr.Tool C.g
#
# Copyright (c) 2009 - 2010, Intel Corporation All rights reserved.
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
# distribution. The full text of the license may be found at:
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
import Ecc.CodeFragment as CodeFragment
import Ecc.FileProfile as FileProfile
# This class defines a complete listener for a parse tree produced by CParser.
class CListener(ParseTreeListener):
# Enter a parse tree produced by CParser#translation_unit.
def enterTranslation_unit(self, ctx:CParser.Translation_unitContext):
pass
# Exit a parse tree produced by CParser#translation_unit.
def exitTranslation_unit(self, ctx:CParser.Translation_unitContext):
pass
# Enter a parse tree produced by CParser#external_declaration.
def enterExternal_declaration(self, ctx:CParser.External_declarationContext):
pass
# Exit a parse tree produced by CParser#external_declaration.
def exitExternal_declaration(self, ctx:CParser.External_declarationContext):
pass
# Enter a parse tree produced by CParser#function_definition.
def enterFunction_definition(self, ctx:CParser.Function_definitionContext):
pass
# Exit a parse tree produced by CParser#function_definition.
def exitFunction_definition(self, ctx:CParser.Function_definitionContext):
pass
# Enter a parse tree produced by CParser#declaration_specifiers.
def enterDeclaration_specifiers(self, ctx:CParser.Declaration_specifiersContext):
pass
# Exit a parse tree produced by CParser#declaration_specifiers.
def exitDeclaration_specifiers(self, ctx:CParser.Declaration_specifiersContext):
pass
# Enter a parse tree produced by CParser#declaration.
def enterDeclaration(self, ctx:CParser.DeclarationContext):
pass
# Exit a parse tree produced by CParser#declaration.
def exitDeclaration(self, ctx:CParser.DeclarationContext):
pass
# Enter a parse tree produced by CParser#init_declarator_list.
def enterInit_declarator_list(self, ctx:CParser.Init_declarator_listContext):
pass
# Exit a parse tree produced by CParser#init_declarator_list.
def exitInit_declarator_list(self, ctx:CParser.Init_declarator_listContext):
pass
# Enter a parse tree produced by CParser#init_declarator.
def enterInit_declarator(self, ctx:CParser.Init_declaratorContext):
pass
# Exit a parse tree produced by CParser#init_declarator.
def exitInit_declarator(self, ctx:CParser.Init_declaratorContext):
pass
# Enter a parse tree produced by CParser#storage_class_specifier.
def enterStorage_class_specifier(self, ctx:CParser.Storage_class_specifierContext):
pass
# Exit a parse tree produced by CParser#storage_class_specifier.
def exitStorage_class_specifier(self, ctx:CParser.Storage_class_specifierContext):
pass
# Enter a parse tree produced by CParser#type_specifier.
def enterType_specifier(self, ctx:CParser.Type_specifierContext):
pass
# Exit a parse tree produced by CParser#type_specifier.
def exitType_specifier(self, ctx:CParser.Type_specifierContext):
pass
# Enter a parse tree produced by CParser#type_id.
def enterType_id(self, ctx:CParser.Type_idContext):
pass
# Exit a parse tree produced by CParser#type_id.
def exitType_id(self, ctx:CParser.Type_idContext):
pass
# Enter a parse tree produced by CParser#struct_or_union_specifier.
def enterStruct_or_union_specifier(self, ctx:CParser.Struct_or_union_specifierContext):
pass
# Exit a parse tree produced by CParser#struct_or_union_specifier.
def exitStruct_or_union_specifier(self, ctx:CParser.Struct_or_union_specifierContext):
pass
# Enter a parse tree produced by CParser#struct_or_union.
def enterStruct_or_union(self, ctx:CParser.Struct_or_unionContext):
pass
# Exit a parse tree produced by CParser#struct_or_union.
def exitStruct_or_union(self, ctx:CParser.Struct_or_unionContext):
pass
# Enter a parse tree produced by CParser#struct_declaration_list.
def enterStruct_declaration_list(self, ctx:CParser.Struct_declaration_listContext):
pass
# Exit a parse tree produced by CParser#struct_declaration_list.
def exitStruct_declaration_list(self, ctx:CParser.Struct_declaration_listContext):
pass
# Enter a parse tree produced by CParser#struct_declaration.
def enterStruct_declaration(self, ctx:CParser.Struct_declarationContext):
pass
# Exit a parse tree produced by CParser#struct_declaration.
def exitStruct_declaration(self, ctx:CParser.Struct_declarationContext):
pass
# Enter a parse tree produced by CParser#specifier_qualifier_list.
def enterSpecifier_qualifier_list(self, ctx:CParser.Specifier_qualifier_listContext):
pass
# Exit a parse tree produced by CParser#specifier_qualifier_list.
def exitSpecifier_qualifier_list(self, ctx:CParser.Specifier_qualifier_listContext):
pass
# Enter a parse tree produced by CParser#struct_declarator_list.
def enterStruct_declarator_list(self, ctx:CParser.Struct_declarator_listContext):
pass
# Exit a parse tree produced by CParser#struct_declarator_list.
def exitStruct_declarator_list(self, ctx:CParser.Struct_declarator_listContext):
pass
# Enter a parse tree produced by CParser#struct_declarator.
def enterStruct_declarator(self, ctx:CParser.Struct_declaratorContext):
pass
# Exit a parse tree produced by CParser#struct_declarator.
def exitStruct_declarator(self, ctx:CParser.Struct_declaratorContext):
pass
# Enter a parse tree produced by CParser#enum_specifier.
def enterEnum_specifier(self, ctx:CParser.Enum_specifierContext):
pass
# Exit a parse tree produced by CParser#enum_specifier.
def exitEnum_specifier(self, ctx:CParser.Enum_specifierContext):
pass
# Enter a parse tree produced by CParser#enumerator_list.
def enterEnumerator_list(self, ctx:CParser.Enumerator_listContext):
pass
# Exit a parse tree produced by CParser#enumerator_list.
def exitEnumerator_list(self, ctx:CParser.Enumerator_listContext):
pass
# Enter a parse tree produced by CParser#enumerator.
def enterEnumerator(self, ctx:CParser.EnumeratorContext):
pass
# Exit a parse tree produced by CParser#enumerator.
def exitEnumerator(self, ctx:CParser.EnumeratorContext):
pass
# Enter a parse tree produced by CParser#type_qualifier.
def enterType_qualifier(self, ctx:CParser.Type_qualifierContext):
pass
# Exit a parse tree produced by CParser#type_qualifier.
def exitType_qualifier(self, ctx:CParser.Type_qualifierContext):
pass
# Enter a parse tree produced by CParser#declarator.
def enterDeclarator(self, ctx:CParser.DeclaratorContext):
pass
# Exit a parse tree produced by CParser#declarator.
def exitDeclarator(self, ctx:CParser.DeclaratorContext):
pass
# Enter a parse tree produced by CParser#direct_declarator.
def enterDirect_declarator(self, ctx:CParser.Direct_declaratorContext):
pass
# Exit a parse tree produced by CParser#direct_declarator.
def exitDirect_declarator(self, ctx:CParser.Direct_declaratorContext):
pass
# Enter a parse tree produced by CParser#declarator_suffix.
def enterDeclarator_suffix(self, ctx:CParser.Declarator_suffixContext):
pass
# Exit a parse tree produced by CParser#declarator_suffix.
def exitDeclarator_suffix(self, ctx:CParser.Declarator_suffixContext):
pass
# Enter a parse tree produced by CParser#pointer.
def enterPointer(self, ctx:CParser.PointerContext):
pass
# Exit a parse tree produced by CParser#pointer.
def exitPointer(self, ctx:CParser.PointerContext):
pass
# Enter a parse tree produced by CParser#parameter_type_list.
def enterParameter_type_list(self, ctx:CParser.Parameter_type_listContext):
pass
# Exit a parse tree produced by CParser#parameter_type_list.
def exitParameter_type_list(self, ctx:CParser.Parameter_type_listContext):
pass
# Enter a parse tree produced by CParser#parameter_list.
def enterParameter_list(self, ctx:CParser.Parameter_listContext):
pass
# Exit a parse tree produced by CParser#parameter_list.
def exitParameter_list(self, ctx:CParser.Parameter_listContext):
pass
# Enter a parse tree produced by CParser#parameter_declaration.
def enterParameter_declaration(self, ctx:CParser.Parameter_declarationContext):
pass
# Exit a parse tree produced by CParser#parameter_declaration.
def exitParameter_declaration(self, ctx:CParser.Parameter_declarationContext):
pass
# Enter a parse tree produced by CParser#identifier_list.
def enterIdentifier_list(self, ctx:CParser.Identifier_listContext):
pass
# Exit a parse tree produced by CParser#identifier_list.
def exitIdentifier_list(self, ctx:CParser.Identifier_listContext):
pass
# Enter a parse tree produced by CParser#type_name.
def enterType_name(self, ctx:CParser.Type_nameContext):
pass
# Exit a parse tree produced by CParser#type_name.
def exitType_name(self, ctx:CParser.Type_nameContext):
pass
# Enter a parse tree produced by CParser#abstract_declarator.
def enterAbstract_declarator(self, ctx:CParser.Abstract_declaratorContext):
pass
# Exit a parse tree produced by CParser#abstract_declarator.
def exitAbstract_declarator(self, ctx:CParser.Abstract_declaratorContext):
pass
# Enter a parse tree produced by CParser#direct_abstract_declarator.
def enterDirect_abstract_declarator(self, ctx:CParser.Direct_abstract_declaratorContext):
pass
# Exit a parse tree produced by CParser#direct_abstract_declarator.
def exitDirect_abstract_declarator(self, ctx:CParser.Direct_abstract_declaratorContext):
pass
# Enter a parse tree produced by CParser#abstract_declarator_suffix.
def enterAbstract_declarator_suffix(self, ctx:CParser.Abstract_declarator_suffixContext):
pass
# Exit a parse tree produced by CParser#abstract_declarator_suffix.
def exitAbstract_declarator_suffix(self, ctx:CParser.Abstract_declarator_suffixContext):
pass
# Enter a parse tree produced by CParser#initializer.
def enterInitializer(self, ctx:CParser.InitializerContext):
pass
# Exit a parse tree produced by CParser#initializer.
def exitInitializer(self, ctx:CParser.InitializerContext):
pass
# Enter a parse tree produced by CParser#initializer_list.
def enterInitializer_list(self, ctx:CParser.Initializer_listContext):
pass
# Exit a parse tree produced by CParser#initializer_list.
def exitInitializer_list(self, ctx:CParser.Initializer_listContext):
pass
# Enter a parse tree produced by CParser#argument_expression_list.
def enterArgument_expression_list(self, ctx:CParser.Argument_expression_listContext):
pass
# Exit a parse tree produced by CParser#argument_expression_list.
def exitArgument_expression_list(self, ctx:CParser.Argument_expression_listContext):
pass
# Enter a parse tree produced by CParser#additive_expression.
def enterAdditive_expression(self, ctx:CParser.Additive_expressionContext):
pass
# Exit a parse tree produced by CParser#additive_expression.
def exitAdditive_expression(self, ctx:CParser.Additive_expressionContext):
pass
# Enter a parse tree produced by CParser#multiplicative_expression.
def enterMultiplicative_expression(self, ctx:CParser.Multiplicative_expressionContext):
pass
# Exit a parse tree produced by CParser#multiplicative_expression.
def exitMultiplicative_expression(self, ctx:CParser.Multiplicative_expressionContext):
pass
# Enter a parse tree produced by CParser#cast_expression.
def enterCast_expression(self, ctx:CParser.Cast_expressionContext):
pass
# Exit a parse tree produced by CParser#cast_expression.
def exitCast_expression(self, ctx:CParser.Cast_expressionContext):
pass
# Enter a parse tree produced by CParser#unary_expression.
def enterUnary_expression(self, ctx:CParser.Unary_expressionContext):
pass
# Exit a parse tree produced by CParser#unary_expression.
def exitUnary_expression(self, ctx:CParser.Unary_expressionContext):
pass
# Enter a parse tree produced by CParser#postfix_expression.
def enterPostfix_expression(self, ctx:CParser.Postfix_expressionContext):
pass
# Exit a parse tree produced by CParser#postfix_expression.
def exitPostfix_expression(self, ctx:CParser.Postfix_expressionContext):
pass
# Enter a parse tree produced by CParser#macro_parameter_list.
def enterMacro_parameter_list(self, ctx:CParser.Macro_parameter_listContext):
pass
# Exit a parse tree produced by CParser#macro_parameter_list.
def exitMacro_parameter_list(self, ctx:CParser.Macro_parameter_listContext):
pass
# Enter a parse tree produced by CParser#unary_operator.
def enterUnary_operator(self, ctx:CParser.Unary_operatorContext):
pass
# Exit a parse tree produced by CParser#unary_operator.
def exitUnary_operator(self, ctx:CParser.Unary_operatorContext):
pass
# Enter a parse tree produced by CParser#primary_expression.
def enterPrimary_expression(self, ctx:CParser.Primary_expressionContext):
pass
# Exit a parse tree produced by CParser#primary_expression.
def exitPrimary_expression(self, ctx:CParser.Primary_expressionContext):
pass
# Enter a parse tree produced by CParser#constant.
def enterConstant(self, ctx:CParser.ConstantContext):
pass
# Exit a parse tree produced by CParser#constant.
def exitConstant(self, ctx:CParser.ConstantContext):
pass
# Enter a parse tree produced by CParser#expression.
def enterExpression(self, ctx:CParser.ExpressionContext):
pass
# Exit a parse tree produced by CParser#expression.
def exitExpression(self, ctx:CParser.ExpressionContext):
pass
# Enter a parse tree produced by CParser#constant_expression.
def enterConstant_expression(self, ctx:CParser.Constant_expressionContext):
pass
# Exit a parse tree produced by CParser#constant_expression.
def exitConstant_expression(self, ctx:CParser.Constant_expressionContext):
pass
# Enter a parse tree produced by CParser#assignment_expression.
def enterAssignment_expression(self, ctx:CParser.Assignment_expressionContext):
pass
# Exit a parse tree produced by CParser#assignment_expression.
def exitAssignment_expression(self, ctx:CParser.Assignment_expressionContext):
pass
# Enter a parse tree produced by CParser#lvalue.
def enterLvalue(self, ctx:CParser.LvalueContext):
pass
# Exit a parse tree produced by CParser#lvalue.
def exitLvalue(self, ctx:CParser.LvalueContext):
pass
# Enter a parse tree produced by CParser#assignment_operator.
def enterAssignment_operator(self, ctx:CParser.Assignment_operatorContext):
pass
# Exit a parse tree produced by CParser#assignment_operator.
def exitAssignment_operator(self, ctx:CParser.Assignment_operatorContext):
pass
# Enter a parse tree produced by CParser#conditional_expression.
def enterConditional_expression(self, ctx:CParser.Conditional_expressionContext):
pass
# Exit a parse tree produced by CParser#conditional_expression.
def exitConditional_expression(self, ctx:CParser.Conditional_expressionContext):
pass
# Enter a parse tree produced by CParser#logical_or_expression.
def enterLogical_or_expression(self, ctx:CParser.Logical_or_expressionContext):
pass
# Exit a parse tree produced by CParser#logical_or_expression.
def exitLogical_or_expression(self, ctx:CParser.Logical_or_expressionContext):
pass
# Enter a parse tree produced by CParser#logical_and_expression.
def enterLogical_and_expression(self, ctx:CParser.Logical_and_expressionContext):
pass
# Exit a parse tree produced by CParser#logical_and_expression.
def exitLogical_and_expression(self, ctx:CParser.Logical_and_expressionContext):
pass
# Enter a parse tree produced by CParser#inclusive_or_expression.
def enterInclusive_or_expression(self, ctx:CParser.Inclusive_or_expressionContext):
pass
# Exit a parse tree produced by CParser#inclusive_or_expression.
def exitInclusive_or_expression(self, ctx:CParser.Inclusive_or_expressionContext):
pass
# Enter a parse tree produced by CParser#exclusive_or_expression.
def enterExclusive_or_expression(self, ctx:CParser.Exclusive_or_expressionContext):
pass
# Exit a parse tree produced by CParser#exclusive_or_expression.
def exitExclusive_or_expression(self, ctx:CParser.Exclusive_or_expressionContext):
pass
# Enter a parse tree produced by CParser#and_expression.
def enterAnd_expression(self, ctx:CParser.And_expressionContext):
pass
# Exit a parse tree produced by CParser#and_expression.
def exitAnd_expression(self, ctx:CParser.And_expressionContext):
pass
# Enter a parse tree produced by CParser#equality_expression.
def enterEquality_expression(self, ctx:CParser.Equality_expressionContext):
pass
# Exit a parse tree produced by CParser#equality_expression.
def exitEquality_expression(self, ctx:CParser.Equality_expressionContext):
pass
# Enter a parse tree produced by CParser#relational_expression.
def enterRelational_expression(self, ctx:CParser.Relational_expressionContext):
pass
# Exit a parse tree produced by CParser#relational_expression.
def exitRelational_expression(self, ctx:CParser.Relational_expressionContext):
pass
# Enter a parse tree produced by CParser#shift_expression.
def enterShift_expression(self, ctx:CParser.Shift_expressionContext):
pass
# Exit a parse tree produced by CParser#shift_expression.
def exitShift_expression(self, ctx:CParser.Shift_expressionContext):
pass
# Enter a parse tree produced by CParser#statement.
def enterStatement(self, ctx:CParser.StatementContext):
pass
# Exit a parse tree produced by CParser#statement.
def exitStatement(self, ctx:CParser.StatementContext):
pass
# Enter a parse tree produced by CParser#asm2_statement.
def enterAsm2_statement(self, ctx:CParser.Asm2_statementContext):
pass
# Exit a parse tree produced by CParser#asm2_statement.
def exitAsm2_statement(self, ctx:CParser.Asm2_statementContext):
pass
# Enter a parse tree produced by CParser#asm1_statement.
def enterAsm1_statement(self, ctx:CParser.Asm1_statementContext):
pass
# Exit a parse tree produced by CParser#asm1_statement.
def exitAsm1_statement(self, ctx:CParser.Asm1_statementContext):
pass
# Enter a parse tree produced by CParser#asm_statement.
def enterAsm_statement(self, ctx:CParser.Asm_statementContext):
pass
# Exit a parse tree produced by CParser#asm_statement.
def exitAsm_statement(self, ctx:CParser.Asm_statementContext):
pass
# Enter a parse tree produced by CParser#macro_statement.
def enterMacro_statement(self, ctx:CParser.Macro_statementContext):
pass
# Exit a parse tree produced by CParser#macro_statement.
def exitMacro_statement(self, ctx:CParser.Macro_statementContext):
pass
# Enter a parse tree produced by CParser#labeled_statement.
def enterLabeled_statement(self, ctx:CParser.Labeled_statementContext):
pass
# Exit a parse tree produced by CParser#labeled_statement.
def exitLabeled_statement(self, ctx:CParser.Labeled_statementContext):
pass
# Enter a parse tree produced by CParser#compound_statement.
def enterCompound_statement(self, ctx:CParser.Compound_statementContext):
pass
# Exit a parse tree produced by CParser#compound_statement.
def exitCompound_statement(self, ctx:CParser.Compound_statementContext):
pass
# Enter a parse tree produced by CParser#statement_list.
def enterStatement_list(self, ctx:CParser.Statement_listContext):
pass
# Exit a parse tree produced by CParser#statement_list.
def exitStatement_list(self, ctx:CParser.Statement_listContext):
pass
# Enter a parse tree produced by CParser#expression_statement.
def enterExpression_statement(self, ctx:CParser.Expression_statementContext):
pass
# Exit a parse tree produced by CParser#expression_statement.
def exitExpression_statement(self, ctx:CParser.Expression_statementContext):
pass
# Enter a parse tree produced by CParser#selection_statement.
def enterSelection_statement(self, ctx:CParser.Selection_statementContext):
pass
# Exit a parse tree produced by CParser#selection_statement.
def exitSelection_statement(self, ctx:CParser.Selection_statementContext):
pass
# Enter a parse tree produced by CParser#iteration_statement.
def enterIteration_statement(self, ctx:CParser.Iteration_statementContext):
pass
# Exit a parse tree produced by CParser#iteration_statement.
def exitIteration_statement(self, ctx:CParser.Iteration_statementContext):
pass
# Enter a parse tree produced by CParser#jump_statement.
def enterJump_statement(self, ctx:CParser.Jump_statementContext):
pass
# Exit a parse tree produced by CParser#jump_statement.
def exitJump_statement(self, ctx:CParser.Jump_statementContext):
pass

File diff suppressed because it is too large Load Diff

View File

@@ -21,7 +21,7 @@ import re
import Common.LongFilePathOs as os
import sys
import antlr3
import antlr4
from .CLexer import CLexer
from .CParser import CParser

View File

@@ -17,18 +17,20 @@
from __future__ import absolute_import
import Common.LongFilePathOs as os, time, glob
import Common.EdkLogger as EdkLogger
from . import EotGlobalData
from Eot import EotGlobalData
from optparse import OptionParser
from Common.StringUtils import NormPath
from Common import BuildToolError
from Common.Misc import GuidStructureStringToGuidString, sdict
from .InfParserLite import *
from . import c
from . import Database
from Eot.Parser import *
from Eot.InfParserLite import EdkInfParser
from Common.StringUtils import GetSplitValueList
from Eot import c
from Eot import Database
from array import array
from .Report import Report
from Eot.Report import Report
from Common.BuildVersion import gBUILD_VERSION
from .Parser import ConvertGuid
from Eot.Parser import ConvertGuid
from Common.LongFilePathSupport import OpenLongFilePath as open
import struct
import uuid
@@ -58,14 +60,14 @@ class Image(array):
self._SubImages = sdict() # {offset: Image()}
array.__init__(self, 'B')
array.__init__(self)
def __repr__(self):
return self._ID_
def __len__(self):
Len = array.__len__(self)
for Offset in self._SubImages:
for Offset in self._SubImages.keys():
Len += len(self._SubImages[Offset])
return Len
@@ -154,19 +156,11 @@ class CompressedImage(Image):
def _GetSections(self):
try:
from . import EfiCompressor
TmpData = EfiCompressor.FrameworkDecompress(
self[self._HEADER_SIZE_:],
len(self) - self._HEADER_SIZE_
)
TmpData = DeCompress('Efi', self[self._HEADER_SIZE_:])
DecData = array('B')
DecData.fromstring(TmpData)
except:
from . import EfiCompressor
TmpData = EfiCompressor.UefiDecompress(
self[self._HEADER_SIZE_:],
len(self) - self._HEADER_SIZE_
)
TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:])
DecData = array('B')
DecData.fromstring(TmpData)
@@ -297,7 +291,7 @@ class Depex(Image):
Expression = property(_GetExpression)
## FirmwareVolume() class
# # FirmwareVolume() class
#
# A class for Firmware Volume
#
@@ -308,12 +302,12 @@ class FirmwareVolume(Image):
_FfsGuid = "8C8CE578-8A3D-4F1C-9935-896185C32DD3"
_GUID_ = struct.Struct("16x 1I2H8B")
_LENGTH_ = struct.Struct("16x 16x 1Q")
_SIG_ = struct.Struct("16x 16x 8x 1I")
_ATTR_ = struct.Struct("16x 16x 8x 4x 1I")
_HLEN_ = struct.Struct("16x 16x 8x 4x 4x 1H")
_CHECKSUM_ = struct.Struct("16x 16x 8x 4x 4x 2x 1H")
_GUID_ = struct.Struct("16x 1I2H8B")
_LENGTH_ = struct.Struct("16x 16x 1Q")
_SIG_ = struct.Struct("16x 16x 8x 1I")
_ATTR_ = struct.Struct("16x 16x 8x 4x 1I")
_HLEN_ = struct.Struct("16x 16x 8x 4x 4x 1H")
_CHECKSUM_ = struct.Struct("16x 16x 8x 4x 4x 2x 1H")
def __init__(self, Name=''):
Image.__init__(self)
@@ -387,7 +381,7 @@ class FirmwareVolume(Image):
DepexString = DepexList[0].strip()
return (CouldBeLoaded, DepexString, FileDepex)
def Dispatch(self, Db = None):
def Dispatch(self, Db=None):
if Db is None:
return False
self.UnDispatchedFfsDict = copy.copy(self.FfsDict)
@@ -397,7 +391,7 @@ class FirmwareVolume(Image):
FfsDxeCoreGuid = None
FfsPeiPrioriGuid = None
FfsDxePrioriGuid = None
for FfsID in self.UnDispatchedFfsDict:
for FfsID in self.UnDispatchedFfsDict.keys():
Ffs = self.UnDispatchedFfsDict[FfsID]
if Ffs.Type == 0x03:
FfsSecCoreGuid = FfsID
@@ -439,6 +433,7 @@ class FirmwareVolume(Image):
if GuidString in self.UnDispatchedFfsDict:
self.OrderedFfsDict[GuidString] = self.UnDispatchedFfsDict.pop(GuidString)
self.LoadPpi(Db, GuidString)
self.DisPatchPei(Db)
# Parse DXE then
@@ -460,6 +455,7 @@ class FirmwareVolume(Image):
if GuidString in self.UnDispatchedFfsDict:
self.OrderedFfsDict[GuidString] = self.UnDispatchedFfsDict.pop(GuidString)
self.LoadProtocol(Db, GuidString)
self.DisPatchDxe(Db)
def LoadProtocol(self, Db, ModuleGuid):
@@ -501,7 +497,7 @@ class FirmwareVolume(Image):
def DisPatchDxe(self, Db):
IsInstalled = False
ScheduleList = sdict()
for FfsID in self.UnDispatchedFfsDict:
for FfsID in self.UnDispatchedFfsDict.keys():
CouldBeLoaded = False
DepexString = ''
FileDepex = None
@@ -548,7 +544,7 @@ class FirmwareVolume(Image):
else:
self.UnDispatchedFfsDict[FfsID].Depex = DepexString
for FfsID in ScheduleList:
for FfsID in ScheduleList.keys():
NewFfs = ScheduleList.pop(FfsID)
FfsName = 'UnKnown'
self.OrderedFfsDict[FfsID] = NewFfs
@@ -560,12 +556,13 @@ class FirmwareVolume(Image):
RecordSet = Db.TblReport.Exec(SqlCommand)
if RecordSet != []:
FfsName = RecordSet[0][0]
if IsInstalled:
self.DisPatchDxe(Db)
def DisPatchPei(self, Db):
IsInstalled = False
for FfsID in self.UnDispatchedFfsDict:
for FfsID in self.UnDispatchedFfsDict.keys():
CouldBeLoaded = True
DepexString = ''
FileDepex = None
@@ -576,7 +573,6 @@ class FirmwareVolume(Image):
if Section.Type == 0x1B:
CouldBeLoaded, DepexString, FileDepex = self.ParseDepex(Section._SubImages[4], 'Ppi')
break
if Section.Type == 0x01:
CompressSections = Section._SubImages[4]
for CompressSection in CompressSections.Sections:
@@ -603,11 +599,12 @@ class FirmwareVolume(Image):
if IsInstalled:
self.DisPatchPei(Db)
def __str__(self):
global gIndention
gIndention += 4
FvInfo = '\n' + ' ' * gIndention
FvInfo += "[FV:%s] file_system=%s size=%x checksum=%s\n" % (self.Name, self.FileSystemGuid, self.Size, self.Checksum)
FvInfo += "[FV:%s] file_system=%s size=%x checksum=%s\n" % (self.Name, self.FileSystemGuid, self.Size, self.Checksum)
FfsInfo = "\n".join([str(self.FfsDict[FfsId]) for FfsId in self.FfsDict])
gIndention -= 4
return FvInfo + FfsInfo
@@ -615,7 +612,7 @@ class FirmwareVolume(Image):
def _Unpack(self):
Size = self._LENGTH_.unpack_from(self._BUF_, self._OFF_)[0]
self.empty()
self.extend(self._BUF_[self._OFF_:self._OFF_+Size])
self.extend(self._BUF_[self._OFF_:self._OFF_ + Size])
# traverse the FFS
EndOfFv = Size
@@ -743,10 +740,9 @@ class GuidDefinedImage(Image):
SectionList.append(Sec)
elif Guid == self.TIANO_COMPRESS_GUID:
try:
from . import EfiCompressor
# skip the header
Offset = self.DataOffset - 4
TmpData = EfiCompressor.FrameworkDecompress(self[Offset:], len(self)-Offset)
TmpData = DeCompress('Framework', self[self.Offset:])
DecData = array('B')
DecData.fromstring(TmpData)
Offset = 0
@@ -764,10 +760,10 @@ class GuidDefinedImage(Image):
pass
elif Guid == self.LZMA_COMPRESS_GUID:
try:
from . import LzmaCompressor
# skip the header
Offset = self.DataOffset - 4
TmpData = LzmaCompressor.LzmaDecompress(self[Offset:], len(self)-Offset)
TmpData = DeCompress('Lzma', self[self.Offset:])
DecData = array('B')
DecData.fromstring(TmpData)
Offset = 0
@@ -848,7 +844,7 @@ class Section(Image):
SectionInfo += "[SECTION:%s] offset=%x size=%x" % (self._TypeName[self.Type], self._OFF_, self.Size)
else:
SectionInfo += "[SECTION:%x<unknown>] offset=%x size=%x " % (self.Type, self._OFF_, self.Size)
for Offset in self._SubImages:
for Offset in self._SubImages.keys():
SectionInfo += ", " + str(self._SubImages[Offset])
gIndention -= 4
return SectionInfo
@@ -982,7 +978,7 @@ class Ffs(Image):
FfsInfo = Indention
FfsInfo += "[FFS:%s] offset=%x size=%x guid=%s free_space=%x alignment=%s\n" % \
(Ffs._TypeName[self.Type], self._OFF_, self.Size, self.Guid, self.FreeSpace, self.Alignment)
SectionInfo = '\n'.join([str(self.Sections[Offset]) for Offset in self.Sections])
SectionInfo = '\n'.join([str(self.Sections[Offset]) for Offset in self.Sections.keys()])
gIndention -= 4
return FfsInfo + SectionInfo + "\n"
@@ -1087,379 +1083,6 @@ class Ffs(Image):
Alignment = property(_GetAlignment)
State = property(_GetState, _SetState)
## FirmwareVolume() class
#
# A class for Firmware Volume
#
class FirmwareVolume(Image):
# Read FvLength, Attributes, HeaderLength, Checksum
_HEADER_ = struct.Struct("16x 1I2H8B 1Q 4x 1I 1H 1H")
_HEADER_SIZE_ = _HEADER_.size
_FfsGuid = "8C8CE578-8A3D-4F1C-9935-896185C32DD3"
_GUID_ = struct.Struct("16x 1I2H8B")
_LENGTH_ = struct.Struct("16x 16x 1Q")
_SIG_ = struct.Struct("16x 16x 8x 1I")
_ATTR_ = struct.Struct("16x 16x 8x 4x 1I")
_HLEN_ = struct.Struct("16x 16x 8x 4x 4x 1H")
_CHECKSUM_ = struct.Struct("16x 16x 8x 4x 4x 2x 1H")
def __init__(self, Name=''):
Image.__init__(self)
self.Name = Name
self.FfsDict = sdict()
self.OrderedFfsDict = sdict()
self.UnDispatchedFfsDict = sdict()
self.ProtocolList = sdict()
def CheckArchProtocol(self):
for Item in EotGlobalData.gArchProtocolGuids:
if Item.lower() not in EotGlobalData.gProtocolList:
return False
return True
def ParseDepex(self, Depex, Type):
List = None
if Type == 'Ppi':
List = EotGlobalData.gPpiList
if Type == 'Protocol':
List = EotGlobalData.gProtocolList
DepexStack = []
DepexList = []
DepexString = ''
FileDepex = None
CouldBeLoaded = True
for Index in range(0, len(Depex.Expression)):
Item = Depex.Expression[Index]
if Item == 0x00:
Index = Index + 1
Guid = gGuidStringFormat % Depex.Expression[Index]
if Guid in self.OrderedFfsDict and Depex.Expression[Index + 1] == 0x08:
return (True, 'BEFORE %s' % Guid, [Guid, 'BEFORE'])
elif Item == 0x01:
Index = Index + 1
Guid = gGuidStringFormat % Depex.Expression[Index]
if Guid in self.OrderedFfsDict and Depex.Expression[Index + 1] == 0x08:
return (True, 'AFTER %s' % Guid, [Guid, 'AFTER'])
elif Item == 0x02:
Index = Index + 1
Guid = gGuidStringFormat % Depex.Expression[Index]
if Guid.lower() in List:
DepexStack.append(True)
DepexList.append(Guid)
else:
DepexStack.append(False)
DepexList.append(Guid)
continue
elif Item == 0x03 or Item == 0x04:
DepexStack.append(eval(str(DepexStack.pop()) + ' ' + Depex._OPCODE_STRING_[Item].lower() + ' ' + str(DepexStack.pop())))
DepexList.append(str(DepexList.pop()) + ' ' + Depex._OPCODE_STRING_[Item].upper() + ' ' + str(DepexList.pop()))
elif Item == 0x05:
DepexStack.append(eval(Depex._OPCODE_STRING_[Item].lower() + ' ' + str(DepexStack.pop())))
DepexList.append(Depex._OPCODE_STRING_[Item].lower() + ' ' + str(DepexList.pop()))
elif Item == 0x06:
DepexStack.append(True)
DepexList.append('TRUE')
DepexString = DepexString + 'TRUE' + ' '
elif Item == 0x07:
DepexStack.append(False)
DepexList.append('False')
DepexString = DepexString + 'FALSE' + ' '
elif Item == 0x08:
if Index != len(Depex.Expression) - 1:
CouldBeLoaded = False
else:
CouldBeLoaded = DepexStack.pop()
else:
CouldBeLoaded = False
if DepexList != []:
DepexString = DepexList[0].strip()
return (CouldBeLoaded, DepexString, FileDepex)
def Dispatch(self, Db = None):
if Db is None:
return False
self.UnDispatchedFfsDict = copy.copy(self.FfsDict)
# Find PeiCore, DexCore, PeiPriori, DxePriori first
FfsSecCoreGuid = None
FfsPeiCoreGuid = None
FfsDxeCoreGuid = None
FfsPeiPrioriGuid = None
FfsDxePrioriGuid = None
for FfsID in self.UnDispatchedFfsDict:
Ffs = self.UnDispatchedFfsDict[FfsID]
if Ffs.Type == 0x03:
FfsSecCoreGuid = FfsID
continue
if Ffs.Type == 0x04:
FfsPeiCoreGuid = FfsID
continue
if Ffs.Type == 0x05:
FfsDxeCoreGuid = FfsID
continue
if Ffs.Guid.lower() == gPeiAprioriFileNameGuid:
FfsPeiPrioriGuid = FfsID
continue
if Ffs.Guid.lower() == gAprioriGuid:
FfsDxePrioriGuid = FfsID
continue
# Parse SEC_CORE first
if FfsSecCoreGuid is not None:
self.OrderedFfsDict[FfsSecCoreGuid] = self.UnDispatchedFfsDict.pop(FfsSecCoreGuid)
self.LoadPpi(Db, FfsSecCoreGuid)
# Parse PEI first
if FfsPeiCoreGuid is not None:
self.OrderedFfsDict[FfsPeiCoreGuid] = self.UnDispatchedFfsDict.pop(FfsPeiCoreGuid)
self.LoadPpi(Db, FfsPeiCoreGuid)
if FfsPeiPrioriGuid is not None:
# Load PEIM described in priori file
FfsPeiPriori = self.UnDispatchedFfsDict.pop(FfsPeiPrioriGuid)
if len(FfsPeiPriori.Sections) == 1:
Section = FfsPeiPriori.Sections.popitem()[1]
if Section.Type == 0x19:
GuidStruct = struct.Struct('1I2H8B')
Start = 4
while len(Section) > Start:
Guid = GuidStruct.unpack_from(Section[Start : Start + 16])
GuidString = gGuidStringFormat % Guid
Start = Start + 16
if GuidString in self.UnDispatchedFfsDict:
self.OrderedFfsDict[GuidString] = self.UnDispatchedFfsDict.pop(GuidString)
self.LoadPpi(Db, GuidString)
self.DisPatchPei(Db)
# Parse DXE then
if FfsDxeCoreGuid is not None:
self.OrderedFfsDict[FfsDxeCoreGuid] = self.UnDispatchedFfsDict.pop(FfsDxeCoreGuid)
self.LoadProtocol(Db, FfsDxeCoreGuid)
if FfsDxePrioriGuid is not None:
# Load PEIM described in priori file
FfsDxePriori = self.UnDispatchedFfsDict.pop(FfsDxePrioriGuid)
if len(FfsDxePriori.Sections) == 1:
Section = FfsDxePriori.Sections.popitem()[1]
if Section.Type == 0x19:
GuidStruct = struct.Struct('1I2H8B')
Start = 4
while len(Section) > Start:
Guid = GuidStruct.unpack_from(Section[Start : Start + 16])
GuidString = gGuidStringFormat % Guid
Start = Start + 16
if GuidString in self.UnDispatchedFfsDict:
self.OrderedFfsDict[GuidString] = self.UnDispatchedFfsDict.pop(GuidString)
self.LoadProtocol(Db, GuidString)
self.DisPatchDxe(Db)
def LoadProtocol(self, Db, ModuleGuid):
SqlCommand = """select GuidValue from Report
where SourceFileFullPath in
(select Value1 from Inf where BelongsToFile =
(select BelongsToFile from Inf
where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
and Model = %s)
and ItemType = 'Protocol' and ItemMode = 'Produced'""" \
% (ModuleGuid, 5001, 3007)
RecordSet = Db.TblReport.Exec(SqlCommand)
for Record in RecordSet:
SqlCommand = """select Value2 from Inf where BelongsToFile =
(select DISTINCT BelongsToFile from Inf
where Value1 =
(select SourceFileFullPath from Report
where GuidValue like '%s' and ItemMode = 'Callback'))
and Value1 = 'FILE_GUID'""" % Record[0]
CallBackSet = Db.TblReport.Exec(SqlCommand)
if CallBackSet != []:
EotGlobalData.gProtocolList[Record[0].lower()] = ModuleGuid
else:
EotGlobalData.gProtocolList[Record[0].lower()] = ModuleGuid
def LoadPpi(self, Db, ModuleGuid):
SqlCommand = """select GuidValue from Report
where SourceFileFullPath in
(select Value1 from Inf where BelongsToFile =
(select BelongsToFile from Inf
where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
and Model = %s)
and ItemType = 'Ppi' and ItemMode = 'Produced'""" \
% (ModuleGuid, 5001, 3007)
RecordSet = Db.TblReport.Exec(SqlCommand)
for Record in RecordSet:
EotGlobalData.gPpiList[Record[0].lower()] = ModuleGuid
def DisPatchDxe(self, Db):
IsInstalled = False
ScheduleList = sdict()
for FfsID in self.UnDispatchedFfsDict:
CouldBeLoaded = False
DepexString = ''
FileDepex = None
Ffs = self.UnDispatchedFfsDict[FfsID]
if Ffs.Type == 0x07:
# Get Depex
IsFoundDepex = False
for Section in Ffs.Sections.values():
# Find Depex
if Section.Type == 0x13:
IsFoundDepex = True
CouldBeLoaded, DepexString, FileDepex = self.ParseDepex(Section._SubImages[4], 'Protocol')
break
if Section.Type == 0x01:
CompressSections = Section._SubImages[4]
for CompressSection in CompressSections.Sections:
if CompressSection.Type == 0x13:
IsFoundDepex = True
CouldBeLoaded, DepexString, FileDepex = self.ParseDepex(CompressSection._SubImages[4], 'Protocol')
break
if CompressSection.Type == 0x02:
NewSections = CompressSection._SubImages[4]
for NewSection in NewSections.Sections:
if NewSection.Type == 0x13:
IsFoundDepex = True
CouldBeLoaded, DepexString, FileDepex = self.ParseDepex(NewSection._SubImages[4], 'Protocol')
break
# Not find Depex
if not IsFoundDepex:
CouldBeLoaded = self.CheckArchProtocol()
DepexString = ''
FileDepex = None
# Append New Ffs
if CouldBeLoaded:
IsInstalled = True
NewFfs = self.UnDispatchedFfsDict.pop(FfsID)
NewFfs.Depex = DepexString
if FileDepex is not None:
ScheduleList.insert(FileDepex[1], FfsID, NewFfs, FileDepex[0])
else:
ScheduleList[FfsID] = NewFfs
else:
self.UnDispatchedFfsDict[FfsID].Depex = DepexString
for FfsID in ScheduleList:
NewFfs = ScheduleList.pop(FfsID)
FfsName = 'UnKnown'
self.OrderedFfsDict[FfsID] = NewFfs
self.LoadProtocol(Db, FfsID)
SqlCommand = """select Value2 from Inf
where BelongsToFile = (select BelongsToFile from Inf where Value1 = 'FILE_GUID' and lower(Value2) = lower('%s') and Model = %s)
and Model = %s and Value1='BASE_NAME'""" % (FfsID, 5001, 5001)
RecordSet = Db.TblReport.Exec(SqlCommand)
if RecordSet != []:
FfsName = RecordSet[0][0]
if IsInstalled:
self.DisPatchDxe(Db)
def DisPatchPei(self, Db):
IsInstalled = False
for FfsID in self.UnDispatchedFfsDict:
CouldBeLoaded = True
DepexString = ''
FileDepex = None
Ffs = self.UnDispatchedFfsDict[FfsID]
if Ffs.Type == 0x06 or Ffs.Type == 0x08:
# Get Depex
for Section in Ffs.Sections.values():
if Section.Type == 0x1B:
CouldBeLoaded, DepexString, FileDepex = self.ParseDepex(Section._SubImages[4], 'Ppi')
break
if Section.Type == 0x01:
CompressSections = Section._SubImages[4]
for CompressSection in CompressSections.Sections:
if CompressSection.Type == 0x1B:
CouldBeLoaded, DepexString, FileDepex = self.ParseDepex(CompressSection._SubImages[4], 'Ppi')
break
if CompressSection.Type == 0x02:
NewSections = CompressSection._SubImages[4]
for NewSection in NewSections.Sections:
if NewSection.Type == 0x1B:
CouldBeLoaded, DepexString, FileDepex = self.ParseDepex(NewSection._SubImages[4], 'Ppi')
break
# Append New Ffs
if CouldBeLoaded:
IsInstalled = True
NewFfs = self.UnDispatchedFfsDict.pop(FfsID)
NewFfs.Depex = DepexString
self.OrderedFfsDict[FfsID] = NewFfs
self.LoadPpi(Db, FfsID)
else:
self.UnDispatchedFfsDict[FfsID].Depex = DepexString
if IsInstalled:
self.DisPatchPei(Db)
def __str__(self):
global gIndention
gIndention += 4
FvInfo = '\n' + ' ' * gIndention
FvInfo += "[FV:%s] file_system=%s size=%x checksum=%s\n" % (self.Name, self.FileSystemGuid, self.Size, self.Checksum)
FfsInfo = "\n".join([str(self.FfsDict[FfsId]) for FfsId in self.FfsDict])
gIndention -= 4
return FvInfo + FfsInfo
def _Unpack(self):
Size = self._LENGTH_.unpack_from(self._BUF_, self._OFF_)[0]
self.empty()
self.extend(self._BUF_[self._OFF_:self._OFF_+Size])
# traverse the FFS
EndOfFv = Size
FfsStartAddress = self.HeaderSize
LastFfsObj = None
while FfsStartAddress < EndOfFv:
FfsObj = Ffs()
FfsObj.frombuffer(self, FfsStartAddress)
FfsId = repr(FfsObj)
if ((self.Attributes & 0x00000800) != 0 and len(FfsObj) == 0xFFFFFF) \
or ((self.Attributes & 0x00000800) == 0 and len(FfsObj) == 0):
if LastFfsObj is not None:
LastFfsObj.FreeSpace = EndOfFv - LastFfsObj._OFF_ - len(LastFfsObj)
else:
if FfsId in self.FfsDict:
EdkLogger.error("FV", 0, "Duplicate GUID in FFS",
ExtraData="\t%s @ %s\n\t%s @ %s" \
% (FfsObj.Guid, FfsObj.Offset,
self.FfsDict[FfsId].Guid, self.FfsDict[FfsId].Offset))
self.FfsDict[FfsId] = FfsObj
if LastFfsObj is not None:
LastFfsObj.FreeSpace = FfsStartAddress - LastFfsObj._OFF_ - len(LastFfsObj)
FfsStartAddress += len(FfsObj)
#
# align to next 8-byte aligned address: A = (A + 8 - 1) & (~(8 - 1))
# The next FFS must be at the latest next 8-byte aligned address
#
FfsStartAddress = (FfsStartAddress + 7) & (~7)
LastFfsObj = FfsObj
def _GetAttributes(self):
return self.GetField(self._ATTR_, 0)[0]
def _GetSize(self):
return self.GetField(self._LENGTH_, 0)[0]
def _GetChecksum(self):
return self.GetField(self._CHECKSUM_, 0)[0]
def _GetHeaderLength(self):
return self.GetField(self._HLEN_, 0)[0]
def _GetFileSystemGuid(self):
return gGuidStringFormat % self.GetField(self._GUID_, 0)
Attributes = property(_GetAttributes)
Size = property(_GetSize)
Checksum = property(_GetChecksum)
HeaderSize = property(_GetHeaderLength)
FileSystemGuid = property(_GetFileSystemGuid)
## MultipleFv() class
#
@@ -1470,8 +1093,10 @@ class MultipleFv(FirmwareVolume):
FirmwareVolume.__init__(self)
self.BasicInfo = []
for FvPath in FvList:
Fd = None
FvName = os.path.splitext(os.path.split(FvPath)[1])[0]
Fd = open(FvPath, 'rb')
if FvPath.strip():
Fd = open(FvPath, 'rb')
Buf = array('B')
try:
Buf.fromfile(Fd, os.path.getsize(FvPath))
@@ -1632,8 +1257,9 @@ class Eot(object):
Path = os.path.join(EotGlobalData.gWORKSPACE, GuidList)
if os.path.isfile(Path):
for Line in open(Path):
(GuidName, GuidValue) = Line.split()
EotGlobalData.gGuidDict[GuidName] = GuidValue
if Line.strip():
(GuidName, GuidValue) = Line.split()
EotGlobalData.gGuidDict[GuidName] = GuidValue
## ConvertLogFile() method
#
@@ -1694,7 +1320,7 @@ class Eot(object):
mCurrentSourceFileList = []
if SourceFileList:
sfl = open(SourceFileList, 'rb')
sfl = open(SourceFileList, 'r')
for line in sfl:
line = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))
if line[-2:].upper() == '.C' or line[-2:].upper() == '.H':
@@ -1970,6 +1596,8 @@ class Eot(object):
def BuildMetaDataFileDatabase(self, Inf_Files):
EdkLogger.quiet("Building database for meta data files ...")
for InfFile in Inf_Files:
if not InfFile:
continue
EdkLogger.quiet("Parsing %s ..." % str(InfFile))
EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile], '')
@@ -2083,7 +1711,10 @@ if __name__ == '__main__':
EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime()) + "[00:00]" + "\n")
StartTime = time.clock()
Eot = Eot()
Eot = Eot(CommandLineOption=False,
SourceFileList=r'C:\TestEot\Source.txt',
GuidList=r'C:\TestEot\Guid.txt',
FvFileList=r'C:\TestEot\FVRECOVERY.Fv')
FinishTime = time.clock()
BuildDuration = time.strftime("%M:%S", time.gmtime(int(round(FinishTime - StartTime))))

View File

@@ -22,8 +22,8 @@ from Common.DataType import *
from CommonDataClass.DataClass import *
from Common.Identification import *
from Common.StringUtils import *
from .Parser import *
from . import Database
from Eot.Parser import *
from Eot import Database
## EdkInfParser() class
#
@@ -153,21 +153,3 @@ class EdkInfParser(object):
self.ParserSource(CurrentSection, SectionItemList, ArchList, ThirdList)
#End of For
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
#
if __name__ == '__main__':
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.QUIET)
Db = Database.Database('Inf.db')
Db.InitDatabase()
P = EdkInfParser(os.path.normpath("C:\Framework\Edk\Sample\Platform\Nt32\Dxe\PlatformBds\PlatformBds.inf"), Db, '', '')
for Inf in P.Sources:
print(Inf)
for Item in P.Macros:
print(Item, P.Macros[Item])
Db.Close()

View File

@@ -2,7 +2,7 @@
# This file is used to define common parsing related functions used in parsing
# Inf/Dsc/Makefile process
#
# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -25,6 +25,32 @@ from . import EotGlobalData
from Common.StringUtils import GetSplitList
from Common.LongFilePathSupport import OpenLongFilePath as open
import subprocess
## DeCompress
#
# Call external decompress tool to decompress the fv section
#
def DeCompress(Method, Input):
# Write the input to a temp file
open('_Temp.bin', 'wb').write(Input)
cmd = ''
if Method == 'Lzma':
cmd = r'LzmaCompress -o _New.bin -d _Temp.bin'
if Method == 'Efi':
cmd = r'TianoCompress -d --uefi -o _New.bin _Temp.bin'
if Method == 'Framework':
cmd = r'TianoCompress -d -o _New.bin _Temp.bin'
# Call tool to create the decompressed output file
Process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Process.communicate()[0]
# Return the beffer of New.bin
if os.path.exists('New.bin'):
return open('New.bin', 'rb').read()
## PreProcess() method
#
# Pre process a file

View File

@@ -77,7 +77,7 @@ class Report(object):
def GenerateUnDispatchedList(self):
FvObj = self.FvObj
EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.Name)
for Item in FvObj.UnDispatchedFfsDict:
for Item in FvObj.UnDispatchedFfsDict.keys():
EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.UnDispatchedFfsDict[Item])
## GenerateFv() method
@@ -112,7 +112,7 @@ class Report(object):
self.WriteLn(Content)
EotGlobalData.gOP_DISPATCH_ORDER.write('Dispatched:\n')
for FfsId in FvObj.OrderedFfsDict:
for FfsId in FvObj.OrderedFfsDict.keys():
self.GenerateFfs(FvObj.OrderedFfsDict[FfsId])
Content = """ </table></td>
</tr>"""
@@ -125,7 +125,7 @@ class Report(object):
self.WriteLn(Content)
EotGlobalData.gOP_DISPATCH_ORDER.write('\nUnDispatched:\n')
for FfsId in FvObj.UnDispatchedFfsDict:
for FfsId in FvObj.UnDispatchedFfsDict.keys():
self.GenerateFfs(FvObj.UnDispatchedFfsDict[FfsId])
Content = """ </table></td>
</tr>"""