From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=yunhuax.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 188162264A1F6 for ; Tue, 3 Apr 2018 22:53:19 -0700 (PDT) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 22:53:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,405,1517904000"; d="dat'59?scan'59,208,59";a="47805629" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 03 Apr 2018 22:53:18 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 3 Apr 2018 22:53:18 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 3 Apr 2018 22:53:16 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.61]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.241]) with mapi id 14.03.0319.002; Wed, 4 Apr 2018 13:53:14 +0800 From: "Feng, YunhuaX" To: "edk2-devel@lists.01.org" CC: "Zhu, Yonghong" , "Gao, Liming" Thread-Topic: [PATCH] BaseTools: Remove FdfParserLite.py from soure code Thread-Index: AdPL2RGv7Xg/BhRmT/WqCPXDjgEfZw== Date: Wed, 4 Apr 2018 05:53:13 +0000 Message-ID: <47C64442C08CCD4089DC43B6B5E46BC483DD65@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: <47C64442C08CCD4089DC43B6B5E46BC483DD65@shsmsx102.ccr.corp.intel.com> x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.26 Subject: [PATCH] BaseTools: Remove FdfParserLite.py from soure code X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 05:53:20 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Remove FdfParserLite.py from source code Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/FdfClassObject.py | 2 +- BaseTools/Source/Python/Common/FdfParserLite.py | 3639 ------------------= ---- BaseTools/Source/Python/GenFds/FdfParser.py | 3 +- BaseTools/Source/Python/Makefile | 1 - 4 files changed, 3 insertions(+), 3642 deletions(-) delete mode 100644 BaseTools/Source/Python/Common/FdfParserLite.py diff --git a/BaseTools/Source/Python/Common/FdfClassObject.py b/BaseTools/S= ource/Python/Common/FdfClassObject.py index 9a7d6494d3..0401247351 100644 --- a/BaseTools/Source/Python/Common/FdfClassObject.py +++ b/BaseTools/Source/Python/Common/FdfClassObject.py @@ -12,11 +12,11 @@ # =20 ## # Import Modules # -from FdfParserLite import FdfParser +from GenFds.FdfParser import FdfParser from Table.TableFdf import TableFdf from CommonDataClass.DataClass import MODEL_FILE_FDF, MODEL_PCD, MODEL_MET= A_DATA_COMPONENT from String import NormPath =20 =20 diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/So= urce/Python/Common/FdfParserLite.py deleted file mode 100644 index dd822505d3..0000000000 --- a/BaseTools/Source/Python/Common/FdfParserLite.py +++ /dev/null @@ -1,3639 +0,0 @@ -## @file -# parse FDF file -# -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. -# - -## -# Import Modules -# -import re -import Common.LongFilePathOs as os - -import CommonDataClass.FdfClass -from Common.LongFilePathSupport import OpenLongFilePath as open -from Common.MultipleWorkspace import MultipleWorkspace as mws -from Common.RangeExpression import RangeExpression -from Common.GlobalData import * -import string - -##define T_CHAR_SPACE ' ' -##define T_CHAR_NULL '\0' -##define T_CHAR_CR '\r' -##define T_CHAR_TAB '\t' -##define T_CHAR_LF '\n' -##define T_CHAR_SLASH '/' -##define T_CHAR_BACKSLASH '\\' -##define T_CHAR_DOUBLE_QUOTE '\"' -##define T_CHAR_SINGLE_QUOTE '\'' -##define T_CHAR_STAR '*' -##define T_CHAR_HASH '#' - -(T_CHAR_SPACE, T_CHAR_NULL, T_CHAR_CR, T_CHAR_TAB, T_CHAR_LF, T_CHAR_SLASH= , \ -T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, T= _CHAR_HASH) =3D \ -(' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#') - -SEPERATOR_TUPLE =3D ('=3D', '|', ',', '{', '}')=20 - -IncludeFileList =3D [] -# Macro passed from command line, which has greatest priority and can NOT = be overridden by those in FDF -InputMacroDict =3D {} -# All Macro values when parsing file, not replace existing Macro -AllMacroList =3D [] - -FileExtensionPattern =3D re.compile(r'([a-zA-Z][a-zA-Z0-9]*)') -TokenFindPattern =3D re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-= Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)') - -def GetRealFileLine (File, Line): - =20 - InsertedLines =3D 0 - for Profile in IncludeFileList: - if Line >=3D Profile.InsertStartLineNumber and Line < Profile.Inse= rtStartLineNumber + Profile.InsertAdjust + len(Profile.FileLinesList): - return (Profile.FileName, Line - Profile.InsertStartLineNumber= + 1) - if Line >=3D Profile.InsertStartLineNumber + Profile.InsertAdjust = + len(Profile.FileLinesList): - InsertedLines +=3D Profile.InsertAdjust + len(Profile.FileLine= sList) - =20 - return (File, Line - InsertedLines) - -## The exception class that used to report error messages when parsing FDF -# -# Currently the "ToolName" is set to be "FDF Parser". -# -class Warning (Exception): - ## The constructor - # - # @param self The object pointer - # @param Str The message to record - # @param File The FDF name - # @param Line The Line number that error occurs - # - def __init__(self, Str, File=3DNone, Line=3DNone): - - FileLineTuple =3D GetRealFileLine(File, Line) - self.FileName =3D FileLineTuple[0] - self.LineNumber =3D FileLineTuple[1] - self.message =3D Str + str(self.LineNumber) - self.ToolName =3D 'FDF Parser' - =20 -## The MACRO class that used to record macro value data when parsing inclu= de file -# -# -class MacroProfile : - ## The constructor - # - # @param self The object pointer - # @param FileName The file that to be parsed - # - def __init__(self, FileName, Line): - self.FileName =3D FileName =20 - self.DefinedAtLine =3D Line - self.MacroName =3D None - self.MacroValue =3D None - -## The Include file content class that used to record file data when parsi= ng include file -# -# May raise Exception when opening file. -# -class IncludeFileProfile : - ## The constructor - # - # @param self The object pointer - # @param FileName The file that to be parsed - # - def __init__(self, FileName): - self.FileName =3D FileName - self.FileLinesList =3D [] - try: - fsock =3D open(FileName, "rb", 0) - try: - self.FileLinesList =3D fsock.readlines() - finally: - fsock.close() - - except IOError: - raise Warning("Error when opening file %s" % FileName) - =20 - self.InsertStartLineNumber =3D None - self.InsertAdjust =3D 0 - -## The FDF content class that used to record file data when parsing FDF -# -# May raise Exception when opening file. -# -class FileProfile : - ## The constructor - # - # @param self The object pointer - # @param FileName The file that to be parsed - # - def __init__(self, FileName): - self.FileLinesList =3D [] - try: - fsock =3D open(FileName, "rb", 0) - try: - self.FileLinesList =3D fsock.readlines() - finally: - fsock.close() - - except IOError: - raise Warning("Error when opening file %s" % FileName) - =20 - self.PcdDict =3D {} - self.InfList =3D [] - =20 - self.PcdFileLineDict =3D {} - self.InfFileLineList =3D [] - =20 - self.FdDict =3D {} - self.FvDict =3D {} - self.CapsuleList =3D [] -# self.VtfList =3D [] -# self.RuleDict =3D {} - -## The syntax parser for FDF -# -# PreprocessFile method should be called prior to ParseFile -# CycleReferenceCheck method can detect cycles in FDF contents -# -# GetNext*** procedures mean these procedures will get next token first, t= hen make judgement. -# Get*** procedures mean these procedures will make judgement on current t= oken only. -# =20 -class FdfParser(object): - ## The constructor - # - # @param self The object pointer - # @param FileName The file that to be parsed - # - def __init__(self, FileName): - self.Profile =3D FileProfile(FileName) - self.FileName =3D FileName - self.CurrentLineNumber =3D 1 - self.CurrentOffsetWithinLine =3D 0 - self.CurrentFdName =3D None - self.CurrentFvName =3D None - self.__Token =3D "" - self.__SkippedChars =3D "" - =20 - self.__WipeOffArea =3D [] - - ## __SkipWhiteSpace() method - # - # Skip white spaces from current char, return number of chars skippe= d - # - # @param self The object pointer - # @retval Count The number of chars skipped - # - def __SkipWhiteSpace(self): - Count =3D 0 - while not self.__EndOfFile(): - Count +=3D 1 - if self.__CurrentChar() in (T_CHAR_NULL, T_CHAR_CR, T_CHAR_LF,= T_CHAR_SPACE, T_CHAR_TAB): - self.__SkippedChars +=3D str(self.__CurrentChar()) - self.__GetOneChar() - - else: - Count =3D Count - 1 - return Count - - ## __EndOfFile() method - # - # Judge current buffer pos is at file end - # - # @param self The object pointer - # @retval True Current File buffer position is at file end - # @retval False Current File buffer position is NOT at file en= d - # - def __EndOfFile(self): - NumberOfLines =3D len(self.Profile.FileLinesList) - SizeOfLastLine =3D len(self.Profile.FileLinesList[-1]) - if self.CurrentLineNumber =3D=3D NumberOfLines and self.CurrentOff= setWithinLine >=3D SizeOfLastLine - 1: - return True - elif self.CurrentLineNumber > NumberOfLines: - return True - else: - return False - - ## __EndOfLine() method - # - # Judge current buffer pos is at line end - # - # @param self The object pointer - # @retval True Current File buffer position is at line end - # @retval False Current File buffer position is NOT at line en= d - # - def __EndOfLine(self): - if self.CurrentLineNumber > len(self.Profile.FileLinesList): - return True - SizeOfCurrentLine =3D len(self.Profile.FileLinesList[self.CurrentL= ineNumber - 1]) - if self.CurrentOffsetWithinLine >=3D SizeOfCurrentLine: - return True - else: - return False - =20 - ## Rewind() method - # - # Reset file data buffer to the initial state - # - # @param self The object pointer - # - def Rewind(self): - self.CurrentLineNumber =3D 1 - self.CurrentOffsetWithinLine =3D 0 - =20 - ## __UndoOneChar() method - # - # Go back one char in the file buffer - # - # @param self The object pointer - # @retval True Successfully go back one char - # @retval False Not able to go back one char as file beginning= reached - # =20 - def __UndoOneChar(self): - =20 - if self.CurrentLineNumber =3D=3D 1 and self.CurrentOffsetWithinLin= e =3D=3D 0: - return False - elif self.CurrentOffsetWithinLine =3D=3D 0: - self.CurrentLineNumber -=3D 1 - self.CurrentOffsetWithinLine =3D len(self.__CurrentLine()) - 1 - else: - self.CurrentOffsetWithinLine -=3D 1 - return True - =20 - ## __GetOneChar() method - # - # Move forward one char in the file buffer - # - # @param self The object pointer - # =20 - def __GetOneChar(self): - if self.CurrentOffsetWithinLine =3D=3D len(self.Profile.FileLinesL= ist[self.CurrentLineNumber - 1]) - 1: - self.CurrentLineNumber +=3D 1 - self.CurrentOffsetWithinLine =3D 0 - else: - self.CurrentOffsetWithinLine +=3D 1 - - ## __CurrentChar() method - # - # Get the char pointed to by the file buffer pointer - # - # @param self The object pointer - # @retval Char Current char - # =20 - def __CurrentChar(self): - return self.Profile.FileLinesList[self.CurrentLineNumber - 1][self= .CurrentOffsetWithinLine] - =20 - ## __NextChar() method - # - # Get the one char pass the char pointed to by the file buffer point= er - # - # @param self The object pointer - # @retval Char Next char - # - def __NextChar(self): - if self.CurrentOffsetWithinLine =3D=3D len(self.Profile.FileLinesL= ist[self.CurrentLineNumber - 1]) - 1: - return self.Profile.FileLinesList[self.CurrentLineNumber][0] - else: - return self.Profile.FileLinesList[self.CurrentLineNumber - 1][= self.CurrentOffsetWithinLine + 1] - =20 - ## __SetCurrentCharValue() method - # - # Modify the value of current char - # - # @param self The object pointer - # @param Value The new value of current char - # - def __SetCurrentCharValue(self, Value): - self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.Curren= tOffsetWithinLine] =3D Value - =20 - ## __CurrentLine() method - # - # Get the list that contains current line contents - # - # @param self The object pointer - # @retval List current line contents - # - def __CurrentLine(self): - return self.Profile.FileLinesList[self.CurrentLineNumber - 1] - =20 - def __StringToList(self): - self.Profile.FileLinesList =3D [list(s) for s in self.Profile.File= LinesList] - self.Profile.FileLinesList[-1].append(' ') - - def __ReplaceMacros(self, Str, File, Line): - MacroEnd =3D 0 - while Str.find('$(', MacroEnd) >=3D 0: - MacroStart =3D Str.find('$(', MacroEnd) - if Str.find(')', MacroStart) > 0: - MacroEnd =3D Str.find(')', MacroStart) - Name =3D Str[MacroStart + 2 : MacroEnd] - Value =3D None - if Name in InputMacroDict: - Value =3D InputMacroDict[Name] - =20 - else: - for Profile in AllMacroList: - if Profile.FileName =3D=3D File and Profile.MacroN= ame =3D=3D Name and Profile.DefinedAtLine <=3D Line: - Value =3D Profile.MacroValue - =20 - if Value is not None: - Str =3D Str.replace('$(' + Name + ')', Value) - MacroEnd =3D MacroStart + len(Value)=20 - =20 - else: - raise Warning("Macro not complete At Line ", self.FileName= , self.CurrentLineNumber) - return Str - - def __ReplaceFragment(self, StartPos, EndPos, Value=3D' '): - if StartPos[0] =3D=3D EndPos[0]: - Offset =3D StartPos[1] - while Offset <=3D EndPos[1]: - self.Profile.FileLinesList[StartPos[0]][Offset] =3D Value - Offset +=3D 1 - return - =20 - Offset =3D StartPos[1] - while self.Profile.FileLinesList[StartPos[0]][Offset] not in ('\r'= , '\n'): - self.Profile.FileLinesList[StartPos[0]][Offset] =3D Value - Offset +=3D 1 - =20 - Line =3D StartPos[0] - while Line < EndPos[0]: - Offset =3D 0 - while self.Profile.FileLinesList[Line][Offset] not in ('\r', '= \n'): - self.Profile.FileLinesList[Line][Offset] =3D Value - Offset +=3D 1 - Line +=3D 1 - =20 - Offset =3D 0 - while Offset <=3D EndPos[1]: - self.Profile.FileLinesList[EndPos[0]][Offset] =3D Value - Offset +=3D 1 - - - def __GetMacroName(self): - if not self.__GetNextToken(): - raise Warning("expected Macro name", self.FileName, self.Curre= ntLineNumber) - MacroName =3D self.__Token - NotFlag =3D False - if MacroName.startswith('!'): - NotFlag =3D True - MacroName =3D MacroName[1:].strip() - =20 - if not MacroName.startswith('$(') or not MacroName.endswith(')'): - raise Warning("Macro name expected(Please use '$(%(Token)s)' i= f '%(Token)s' is a macro.)" % {"Token" : MacroName}, - self.FileName, self.CurrentLineNumber) - MacroName =3D MacroName[2:-1] - return MacroName, NotFlag - =20 - ## PreprocessFile() method - # - # Preprocess file contents, replace comments with spaces. - # In the end, rewind the file buffer pointer to the beginning - # BUGBUG: No !include statement processing contained in this procedu= re - # !include statement should be expanded at the same FileLinesList[Cu= rrentLineNumber - 1] - # - # @param self The object pointer - # =20 - def PreprocessFile(self): - =20 - self.Rewind() - InComment =3D False - DoubleSlashComment =3D False - HashComment =3D False - # HashComment in quoted string " " is ignored. - InString =3D False =20 - =20 - while not self.__EndOfFile(): - =20 - if self.__CurrentChar() =3D=3D T_CHAR_DOUBLE_QUOTE and not InC= omment: - InString =3D not InString - # meet new line, then no longer in a comment for // and '#' - if self.__CurrentChar() =3D=3D T_CHAR_LF: - self.CurrentLineNumber +=3D 1 - self.CurrentOffsetWithinLine =3D 0 - if InComment and DoubleSlashComment: - InComment =3D False - DoubleSlashComment =3D False - if InComment and HashComment: - InComment =3D False - HashComment =3D False - # check for */ comment end - elif InComment and not DoubleSlashComment and not HashComment = and self.__CurrentChar() =3D=3D T_CHAR_STAR and self.__NextChar() =3D=3D T_= CHAR_SLASH: - self.__SetCurrentCharValue(T_CHAR_SPACE) - self.__GetOneChar() - self.__SetCurrentCharValue(T_CHAR_SPACE) - self.__GetOneChar() - InComment =3D False - # set comments to spaces - elif InComment: - self.__SetCurrentCharValue(T_CHAR_SPACE) - self.__GetOneChar() - # check for // comment - elif self.__CurrentChar() =3D=3D T_CHAR_SLASH and self.__NextC= har() =3D=3D T_CHAR_SLASH and not self.__EndOfLine(): - InComment =3D True - DoubleSlashComment =3D True - # check for '#' comment - elif self.__CurrentChar() =3D=3D T_CHAR_HASH and not self.__En= dOfLine() and not InString: - InComment =3D True - HashComment =3D True - # check for /* comment start - elif self.__CurrentChar() =3D=3D T_CHAR_SLASH and self.__NextC= har() =3D=3D T_CHAR_STAR: - self.__SetCurrentCharValue( T_CHAR_SPACE) - self.__GetOneChar() - self.__SetCurrentCharValue( T_CHAR_SPACE) - self.__GetOneChar() - InComment =3D True - else: - self.__GetOneChar() - =20 - # restore from ListOfList to ListOfString - self.Profile.FileLinesList =3D ["".join(list) for list in self.Pro= file.FileLinesList] - self.Rewind() - - ## PreprocessIncludeFile() method - # - # Preprocess file contents, replace !include statements with file co= ntents. - # In the end, rewind the file buffer pointer to the beginning - # - # @param self The object pointer - # =20 - def PreprocessIncludeFile(self): - =20 - while self.__GetNextToken(): - =20 - if self.__Token =3D=3D '!include': - IncludeLine =3D self.CurrentLineNumber - IncludeOffset =3D self.CurrentOffsetWithinLine - len('!inc= lude') - if not self.__GetNextToken(): - raise Warning("expected include file name At Line ", s= elf.FileName, self.CurrentLineNumber) - IncFileName =3D self.__Token - if not os.path.isabs(IncFileName): - if IncFileName.startswith('$(WORKSPACE)'): - Str =3D mws.handleWsMacro(IncFileName) - Str =3D Str.replace('$(WORKSPACE)', os.environ.get= ('WORKSPACE')) - if os.path.exists(Str): - if not os.path.isabs(Str): - Str =3D os.path.abspath(Str) - IncFileName =3D Str - else: - # file is in the same dir with FDF file - FullFdf =3D self.FileName - if not os.path.isabs(self.FileName): - FullFdf =3D mws.join(os.environ.get('WORKSPACE= '), self.FileName) - =20 - IncFileName =3D os.path.join(os.path.dirname(FullF= df), IncFileName) - =20 - if not os.path.exists(os.path.normpath(IncFileName)): - raise Warning("Include file not exists At Line ", self= .FileName, self.CurrentLineNumber) - =20 - IncFileProfile =3D IncludeFileProfile(os.path.normpath(Inc= FileName)) - =20 - CurrentLine =3D self.CurrentLineNumber - CurrentOffset =3D self.CurrentOffsetWithinLine - # list index of the insertion, note that line number is 'C= urrentLine + 1' - InsertAtLine =3D CurrentLine - IncFileProfile.InsertStartLineNumber =3D InsertAtLine + 1 - # deal with remaining portions after "!include filename", = if exists. - if self.__GetNextToken(): - if self.CurrentLineNumber =3D=3D CurrentLine: - RemainingLine =3D self.__CurrentLine()[CurrentOffs= et:] - self.Profile.FileLinesList.insert(self.CurrentLine= Number, RemainingLine) - IncFileProfile.InsertAdjust +=3D 1 - self.CurrentLineNumber +=3D 1 - self.CurrentOffsetWithinLine =3D 0 - =20 - for Line in IncFileProfile.FileLinesList: - self.Profile.FileLinesList.insert(InsertAtLine, Line) - self.CurrentLineNumber +=3D 1 - InsertAtLine +=3D 1 =20 - =20 - IncludeFileList.append(IncFileProfile) - =20 - # comment out the processed include file statement - TempList =3D list(self.Profile.FileLinesList[IncludeLine -= 1]) - TempList.insert(IncludeOffset, '#') - self.Profile.FileLinesList[IncludeLine - 1] =3D ''.join(Te= mpList) - =20 - self.Rewind() - - ## PreprocessIncludeFile() method - # - # Preprocess file contents, replace !include statements with file co= ntents. - # In the end, rewind the file buffer pointer to the beginning - # - # @param self The object pointer - # =20 - def PreprocessConditionalStatement(self): - # IfList is a stack of if branches with elements of list [Pos, Con= dSatisfied, BranchDetermined] - IfList =3D [] - while self.__GetNextToken(): - if self.__Token =3D=3D 'DEFINE': - DefineLine =3D self.CurrentLineNumber - 1 - DefineOffset =3D self.CurrentOffsetWithinLine - len('DEFIN= E') - if not self.__GetNextToken(): - raise Warning("expected Macro name At Line ", self.Fil= eName, self.CurrentLineNumber) - Macro =3D self.__Token - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName= , self.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected value At Line ", self.FileName= , self.CurrentLineNumber) - =20 - if self.__GetStringData(): - pass - Value =3D self.__Token - if not Macro in InputMacroDict: - FileLineTuple =3D GetRealFileLine(self.FileName, Defin= eLine + 1) - MacProfile =3D MacroProfile(FileLineTuple[0], FileLine= Tuple[1]) - MacProfile.MacroName =3D Macro - MacProfile.MacroValue =3D Value - AllMacroList.append(MacProfile) - self.__WipeOffArea.append(((DefineLine, DefineOffset), (se= lf.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) - =20 - elif self.__Token in ('!ifdef', '!ifndef', '!if'): - IfStartPos =3D (self.CurrentLineNumber - 1, self.CurrentOf= fsetWithinLine - len(self.__Token)) - IfList.append([IfStartPos, None, None]) - CondLabel =3D self.__Token - =20 - MacroName, NotFlag =3D self.__GetMacroName()=20 - NotDefineFlag =3D False - if CondLabel =3D=3D '!ifndef': - NotDefineFlag =3D True - if CondLabel =3D=3D '!ifdef' or CondLabel =3D=3D '!ifndef'= : - if NotFlag: - raise Warning("'NOT' operation not allowed for Mac= ro name At Line ", self.FileName, self.CurrentLineNumber) - =20 - if CondLabel =3D=3D '!if': - =20 - if not self.__GetNextOp(): - raise Warning("expected !endif At Line ", self.Fil= eName, self.CurrentLineNumber) - =20 - if self.__Token in ('!=3D', '=3D=3D', '>', '<', '>=3D'= , '<=3D'): - Op =3D self.__Token - if not self.__GetNextToken(): - raise Warning("expected value At Line ", self.= FileName, self.CurrentLineNumber) - if self.__GetStringData(): - pass - MacroValue =3D self.__Token - ConditionSatisfied =3D self.__EvaluateConditional(= MacroName, IfList[-1][0][0] + 1, Op, MacroValue) - if NotFlag: - ConditionSatisfied =3D not ConditionSatisfied - BranchDetermined =3D ConditionSatisfied - else: - self.CurrentOffsetWithinLine -=3D len(self.__Token= ) =20 - ConditionSatisfied =3D self.__EvaluateConditional(= MacroName, IfList[-1][0][0] + 1, None, 'Bool') - if NotFlag: - ConditionSatisfied =3D not ConditionSatisfied - BranchDetermined =3D ConditionSatisfied - IfList[-1] =3D [IfList[-1][0], ConditionSatisfied, Bra= nchDetermined] - if ConditionSatisfied: - self.__WipeOffArea.append((IfList[-1][0], (self.Cu= rrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) - =20 - else: - ConditionSatisfied =3D self.__EvaluateConditional(Macr= oName, IfList[-1][0][0] + 1) - if NotDefineFlag: - ConditionSatisfied =3D not ConditionSatisfied - BranchDetermined =3D ConditionSatisfied - IfList[-1] =3D [IfList[-1][0], ConditionSatisfied, Bra= nchDetermined] - if ConditionSatisfied: - self.__WipeOffArea.append((IfStartPos, (self.Curre= ntLineNumber - 1, self.CurrentOffsetWithinLine - 1))) - =20 - elif self.__Token in ('!elseif', '!else'): - ElseStartPos =3D (self.CurrentLineNumber - 1, self.Current= OffsetWithinLine - len(self.__Token)) - if len(IfList) <=3D 0: - raise Warning("Missing !if statement At Line ", self.F= ileName, self.CurrentLineNumber) - if IfList[-1][1]: - IfList[-1] =3D [ElseStartPos, False, True] - self.__WipeOffArea.append((ElseStartPos, (self.Current= LineNumber - 1, self.CurrentOffsetWithinLine - 1))) - else: - self.__WipeOffArea.append((IfList[-1][0], ElseStartPos= )) - IfList[-1] =3D [ElseStartPos, True, IfList[-1][2]] - if self.__Token =3D=3D '!elseif': - MacroName, NotFlag =3D self.__GetMacroName()=20 - if not self.__GetNextOp(): - raise Warning("expected !endif At Line ", self= .FileName, self.CurrentLineNumber) - =20 - if self.__Token in ('!=3D', '=3D=3D', '>', '<', '>= =3D', '<=3D'): - Op =3D self.__Token - if not self.__GetNextToken(): - raise Warning("expected value At Line ", s= elf.FileName, self.CurrentLineNumber) - if self.__GetStringData(): - pass - MacroValue =3D self.__Token - ConditionSatisfied =3D self.__EvaluateConditio= nal(MacroName, IfList[-1][0][0] + 1, Op, MacroValue) - if NotFlag: - ConditionSatisfied =3D not ConditionSatisf= ied - - else: - self.CurrentOffsetWithinLine -=3D len(self.__T= oken) =20 - ConditionSatisfied =3D self.__EvaluateConditio= nal(MacroName, IfList[-1][0][0] + 1, None, 'Bool') - if NotFlag: - ConditionSatisfied =3D not ConditionSatisf= ied - - IfList[-1] =3D [IfList[-1][0], ConditionSatisfied,= IfList[-1][2]] - =20 - if IfList[-1][1]: - if IfList[-1][2]: - IfList[-1][1] =3D False - else: - IfList[-1][2] =3D True - self.__WipeOffArea.append((IfList[-1][0], (sel= f.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) - - =20 - elif self.__Token =3D=3D '!endif': - if IfList[-1][1]: - self.__WipeOffArea.append(((self.CurrentLineNumber - 1= , self.CurrentOffsetWithinLine - len('!endif')), (self.CurrentLineNumber - = 1, self.CurrentOffsetWithinLine - 1))) - else: - self.__WipeOffArea.append((IfList[-1][0], (self.Curren= tLineNumber - 1, self.CurrentOffsetWithinLine - 1))) - =20 - IfList.pop() - =20 - =20 - if len(IfList) > 0: - raise Warning("Missing !endif At Line ", self.FileName, self.C= urrentLineNumber) - self.Rewind() - - def __EvaluateConditional(self, Name, Line, Op =3D None, Value =3D Non= e): - =20 - FileLineTuple =3D GetRealFileLine(self.FileName, Line) - if Name in InputMacroDict: - MacroValue =3D InputMacroDict[Name] - if Op is None: - if Value =3D=3D 'Bool' and MacroValue is None or MacroValu= e.upper() =3D=3D 'FALSE': - return False - return True - elif Op =3D=3D '!=3D': - if Value !=3D MacroValue: - return True - else: - return False - elif Op =3D=3D '=3D=3D': - if Value =3D=3D MacroValue: - return True - else: - return False - else: - if (self.__IsHex(Value) or Value.isdigit()) and (self.__Is= Hex(MacroValue) or (MacroValue is not None and MacroValue.isdigit())): - InputVal =3D long(Value, 0) - MacroVal =3D long(MacroValue, 0) - if Op =3D=3D '>': - if MacroVal > InputVal: - return True - else: - return False - elif Op =3D=3D '>=3D': - if MacroVal >=3D InputVal: - return True - else: - return False - elif Op =3D=3D '<': - if MacroVal < InputVal: - return True - else: - return False - elif Op =3D=3D '<=3D': - if MacroVal <=3D InputVal: - return True - else: - return False - else: - return False - else: - raise Warning("Value %s is not a number At Line ", sel= f.FileName, Line) - =20 - for Profile in AllMacroList: - if Profile.FileName =3D=3D FileLineTuple[0] and Profile.MacroN= ame =3D=3D Name and Profile.DefinedAtLine <=3D FileLineTuple[1]: - if Op is None: - if Value =3D=3D 'Bool' and Profile.MacroValue is None = or Profile.MacroValue.upper() =3D=3D 'FALSE': - return False - return True - elif Op =3D=3D '!=3D': - if Value !=3D Profile.MacroValue: - return True - else: - return False - elif Op =3D=3D '=3D=3D': - if Value =3D=3D Profile.MacroValue: - return True - else: - return False - else: - if (self.__IsHex(Value) or Value.isdigit()) and (self.= __IsHex(Profile.MacroValue) or (Profile.MacroValue is not None and Profile.= MacroValue.isdigit())): - InputVal =3D long(Value, 0) - MacroVal =3D long(Profile.MacroValue, 0) - if Op =3D=3D '>': - if MacroVal > InputVal: - return True - else: - return False - elif Op =3D=3D '>=3D': - if MacroVal >=3D InputVal: - return True - else: - return False - elif Op =3D=3D '<': - if MacroVal < InputVal: - return True - else: - return False - elif Op =3D=3D '<=3D': - if MacroVal <=3D InputVal: - return True - else: - return False - else: - return False - else: - raise Warning("Value %s is not a number At Line ",= self.FileName, Line) - =20 - return False - - ## __IsToken() method - # - # Check whether input string is found from current char position alo= ng - # If found, the string value is put into self.__Token - # - # @param self The object pointer - # @param String The string to search - # @param IgnoreCase Indicate case sensitive/non-sensitive search, = default is case sensitive - # @retval True Successfully find string, file buffer pointer = moved forward - # @retval False Not able to find string, file buffer pointer n= ot changed - # - def __IsToken(self, String, IgnoreCase =3D False): - self.__SkipWhiteSpace() - - # Only consider the same line, no multi-line token allowed - StartPos =3D self.CurrentOffsetWithinLine - index =3D -1 - if IgnoreCase: - index =3D self.__CurrentLine()[self.CurrentOffsetWithinLine : = ].upper().find(String.upper())=20 - else: - index =3D self.__CurrentLine()[self.CurrentOffsetWithinLine : = ].find(String) - if index =3D=3D 0: - self.CurrentOffsetWithinLine +=3D len(String) - self.__Token =3D self.__CurrentLine()[StartPos : self.CurrentO= ffsetWithinLine] - return True - return False - - ## __IsKeyword() method - # - # Check whether input keyword is found from current char position al= ong, whole word only! - # If found, the string value is put into self.__Token - # - # @param self The object pointer - # @param Keyword The string to search - # @param IgnoreCase Indicate case sensitive/non-sensitive search, = default is case sensitive - # @retval True Successfully find string, file buffer pointer = moved forward - # @retval False Not able to find string, file buffer pointer n= ot changed - # - def __IsKeyword(self, KeyWord, IgnoreCase =3D False): - self.__SkipWhiteSpace() - - # Only consider the same line, no multi-line token allowed - StartPos =3D self.CurrentOffsetWithinLine - index =3D -1 - if IgnoreCase: - index =3D self.__CurrentLine()[self.CurrentOffsetWithinLine : = ].upper().find(KeyWord.upper())=20 - else: - index =3D self.__CurrentLine()[self.CurrentOffsetWithinLine : = ].find(KeyWord) - if index =3D=3D 0: - followingChar =3D self.__CurrentLine()[self.CurrentOffsetWithi= nLine + len(KeyWord)] - if not str(followingChar).isspace() and followingChar not in S= EPERATOR_TUPLE: - return False - self.CurrentOffsetWithinLine +=3D len(KeyWord) - self.__Token =3D self.__CurrentLine()[StartPos : self.CurrentO= ffsetWithinLine] - return True - return False - - ## __GetNextWord() method - # - # Get next C name from file lines - # If found, the string value is put into self.__Token - # - # @param self The object pointer - # @retval True Successfully find a C name string, file buffer= pointer moved forward - # @retval False Not able to find a C name string, file buffer = pointer not changed - # - def __GetNextWord(self): - self.__SkipWhiteSpace() - if self.__EndOfFile(): - return False - =20 - TempChar =3D self.__CurrentChar() - StartPos =3D self.CurrentOffsetWithinLine - if (TempChar >=3D 'a' and TempChar <=3D 'z') or (TempChar >=3D 'A'= and TempChar <=3D 'Z') or TempChar =3D=3D '_': - self.__GetOneChar() - while not self.__EndOfLine(): - TempChar =3D self.__CurrentChar() - if (TempChar >=3D 'a' and TempChar <=3D 'z') or (TempChar = >=3D 'A' and TempChar <=3D 'Z') \ - or (TempChar >=3D '0' and TempChar <=3D '9') or TempChar = =3D=3D '_' or TempChar =3D=3D '-': - self.__GetOneChar() - =20 - else: - break - - self.__Token =3D self.__CurrentLine()[StartPos : self.CurrentO= ffsetWithinLine] - return True - =20 - return False - =20 - ## __GetNextToken() method - # - # Get next token unit before a seperator - # If found, the string value is put into self.__Token - # - # @param self The object pointer - # @retval True Successfully find a token unit, file buffer po= inter moved forward - # @retval False Not able to find a token unit, file buffer poi= nter not changed - # - def __GetNextToken(self): - # Skip leading spaces, if exist. - self.__SkipWhiteSpace() - if self.__EndOfFile(): - return False - # Record the token start position, the position of the first non-s= pace char. - StartPos =3D self.CurrentOffsetWithinLine - StartLine =3D self.CurrentLineNumber - while not self.__EndOfLine(): - TempChar =3D self.__CurrentChar() - # Try to find the end char that is not a space and not in sepe= rator tuple. - # That is, when we got a space or any char in the tuple, we go= t the end of token. - if not str(TempChar).isspace() and TempChar not in SEPERATOR_T= UPLE: - self.__GetOneChar() - # if we happen to meet a seperator as the first char, we must = proceed to get it. - # That is, we get a token that is a seperator char. nomally it= is the boundary of other tokens. - elif StartPos =3D=3D self.CurrentOffsetWithinLine and TempChar= in SEPERATOR_TUPLE: - self.__GetOneChar() - break - else: - break -# else: -# return False - - EndPos =3D self.CurrentOffsetWithinLine - if self.CurrentLineNumber !=3D StartLine: - EndPos =3D len(self.Profile.FileLinesList[StartLine-1]) - self.__Token =3D self.Profile.FileLinesList[StartLine-1][StartPos = : EndPos] - if StartPos !=3D self.CurrentOffsetWithinLine: - return True - else: - return False - =20 - def __GetNextOp(self): - # Skip leading spaces, if exist. - self.__SkipWhiteSpace() - if self.__EndOfFile(): - return False - # Record the token start position, the position of the first non-s= pace char. - StartPos =3D self.CurrentOffsetWithinLine - while not self.__EndOfLine(): - TempChar =3D self.__CurrentChar() - # Try to find the end char that is not a space - if not str(TempChar).isspace(): - self.__GetOneChar() - else: - break - else: - return False - =20 - if StartPos !=3D self.CurrentOffsetWithinLine: - self.__Token =3D self.__CurrentLine()[StartPos : self.CurrentO= ffsetWithinLine] - return True - else: - return False - ## __GetNextGuid() method - # - # Get next token unit before a seperator - # If found, the GUID string is put into self.__Token - # - # @param self The object pointer - # @retval True Successfully find a registry format GUID, file= buffer pointer moved forward - # @retval False Not able to find a registry format GUID, file = buffer pointer not changed - # - def __GetNextGuid(self): - =20 - if not self.__GetNextToken(): - return False - if gGuidPattern.match(self.__Token) is not None: - return True - else: - self.__UndoToken() - return False - - ## __UndoToken() method - # - # Go back one token unit in file buffer - # - # @param self The object pointer - # - def __UndoToken(self): - self.__UndoOneChar() - while self.__CurrentChar().isspace(): - if not self.__UndoOneChar(): - self.__GetOneChar() - return - =20 - =20 - StartPos =3D self.CurrentOffsetWithinLine - CurrentLine =3D self.CurrentLineNumber - while CurrentLine =3D=3D self.CurrentLineNumber: - =20 - TempChar =3D self.__CurrentChar() - # Try to find the end char that is not a space and not in sepe= rator tuple. - # That is, when we got a space or any char in the tuple, we go= t the end of token. - if not str(TempChar).isspace() and not TempChar in SEPERATOR_T= UPLE: - if not self.__UndoOneChar(): - break - # if we happen to meet a seperator as the first char, we must = proceed to get it. - # That is, we get a token that is a seperator char. nomally it= is the boundary of other tokens. - elif StartPos =3D=3D self.CurrentOffsetWithinLine and TempChar= in SEPERATOR_TUPLE: - return - else: - break - =20 - self.__GetOneChar() - =20 - def __IsHex(self, HexStr): - if not HexStr.upper().startswith("0X"): - return False - if len(self.__Token) <=3D 2: - return False - return True if all(x in string.hexdigits for x in HexStr[2:]) else= False - - ## __GetNextHexNumber() method - # - # Get next HEX data before a seperator - # If found, the HEX data is put into self.__Token - # - # @param self The object pointer - # @retval True Successfully find a HEX data, file buffer poin= ter moved forward - # @retval False Not able to find a HEX data, file buffer point= er not changed - # - def __GetNextHexNumber(self): - if not self.__GetNextToken(): - return False - if self.__IsHex(self.__Token): - return True - else: - self.__UndoToken() - return False - =20 - ## __GetNextDecimalNumber() method - # - # Get next decimal data before a seperator - # If found, the decimal data is put into self.__Token - # - # @param self The object pointer - # @retval True Successfully find a decimal data, file buffer = pointer moved forward - # @retval False Not able to find a decimal data, file buffer p= ointer not changed - # - def __GetNextDecimalNumber(self): - if not self.__GetNextToken(): - return False - if self.__Token.isdigit(): - return True - else: - self.__UndoToken() - return False - =20 - ## __GetNextPcdName() method - # - # Get next PCD token space C name and PCD C name pair before a seper= ator - # If found, the decimal data is put into self.__Token - # - # @param self The object pointer - # @retval Tuple PCD C name and PCD token space C name pair=20 - # - def __GetNextPcdName(self): - if not self.__GetNextWord(): - raise Warning("expected PcdTokenSpaceCName.PcdCName At Line ",= self.FileName, self.CurrentLineNumber) - pcdTokenSpaceCName =3D self.__Token - =20 - if not self.__IsToken( "."): - raise Warning("expected PcdTokenSpaceCName.PcdCName At Line ",= self.FileName, self.CurrentLineNumber) - =20 - if not self.__GetNextWord(): - raise Warning("expected PcdTokenSpaceCName.PcdCName At Line ",= self.FileName, self.CurrentLineNumber) - pcdCName =3D self.__Token - =20 - return (pcdCName, pcdTokenSpaceCName)=20 - =20 - ## __GetStringData() method - # - # Get string contents quoted in "" - # If found, the decimal data is put into self.__Token - # - # @param self The object pointer - # @retval True Successfully find a string data, file buffer p= ointer moved forward - # @retval False Not able to find a string data, file buffer po= inter not changed - # =20 - def __GetStringData(self): - if self.__Token.startswith("\"") or self.__Token.startswith("L\"")= : - self.__UndoToken() - self.__SkipToToken("\"") - currentLineNumber =3D self.CurrentLineNumber - =20 - if not self.__SkipToToken("\""): - raise Warning("Missing Quote \" for String At Line ", self= .FileName, self.CurrentLineNumber) - if currentLineNumber !=3D self.CurrentLineNumber: - raise Warning("Missing Quote \" for String At Line ", self= .FileName, self.CurrentLineNumber) - self.__Token =3D self.__SkippedChars.rstrip('\"') - return True - =20 - elif self.__Token.startswith("\'") or self.__Token.startswith("L\'= "): - self.__UndoToken() - self.__SkipToToken("\'") - currentLineNumber =3D self.CurrentLineNumber - =20 - if not self.__SkipToToken("\'"): - raise Warning("Missing Quote \' for String At Line ", self= .FileName, self.CurrentLineNumber) - if currentLineNumber !=3D self.CurrentLineNumber: - raise Warning("Missing Quote \' for String At Line ", self= .FileName, self.CurrentLineNumber) - self.__Token =3D self.__SkippedChars.rstrip('\'') - return True - =20 - else: - return False - =20 - ## __SkipToToken() method - # - # Search forward in file buffer for the string - # The skipped chars are put into self.__SkippedChars - # - # @param self The object pointer - # @param String The string to search - # @param IgnoreCase Indicate case sensitive/non-sensitive search, = default is case sensitive - # @retval True Successfully find the string, file buffer poin= ter moved forward - # @retval False Not able to find the string, file buffer point= er not changed - # - def __SkipToToken(self, String, IgnoreCase =3D False): - StartPos =3D self.GetFileBufferPos() - =20 - self.__SkippedChars =3D "" - while not self.__EndOfFile(): - index =3D -1 - if IgnoreCase: - index =3D self.__CurrentLine()[self.CurrentOffsetWithinLin= e : ].upper().find(String.upper())=20 - else: - index =3D self.__CurrentLine()[self.CurrentOffsetWithinLin= e : ].find(String) - if index =3D=3D 0: - self.CurrentOffsetWithinLine +=3D len(String) - self.__SkippedChars +=3D String - return True - self.__SkippedChars +=3D str(self.__CurrentChar()) - self.__GetOneChar() - =20 - self.SetFileBufferPos( StartPos) - self.__SkippedChars =3D "" - return False - - ## GetFileBufferPos() method - # - # Return the tuple of current line and offset within the line - # - # @param self The object pointer - # @retval Tuple Line number and offset pair=20 - # - def GetFileBufferPos(self): - return (self.CurrentLineNumber, self.CurrentOffsetWithinLine) - =20 - ## SetFileBufferPos() method - # - # Restore the file buffer position - # - # @param self The object pointer - # @param Pos The new file buffer position - # - def SetFileBufferPos(self, Pos): - (self.CurrentLineNumber, self.CurrentOffsetWithinLine) =3D Pos - =20 - ## ParseFile() method - # - # Parse the file profile buffer to extract fd, fv ... information - # Exception will be raised if syntax error found - # - # @param self The object pointer - # - def ParseFile(self): - - try: - self.__StringToList() - self.PreprocessFile() - self.PreprocessIncludeFile() - self.__StringToList() - self.PreprocessFile() - self.PreprocessConditionalStatement() - self.__StringToList() - for Pos in self.__WipeOffArea: - self.__ReplaceFragment(Pos[0], Pos[1]) - self.Profile.FileLinesList =3D ["".join(list) for list in self= .Profile.FileLinesList] - =20 - while self.__GetDefines(): - pass - =20 - Index =3D 0 - while Index < len(self.Profile.FileLinesList): - FileLineTuple =3D GetRealFileLine(self.FileName, Index + 1= ) - self.Profile.FileLinesList[Index] =3D self.__ReplaceMacros= (self.Profile.FileLinesList[Index], FileLineTuple[0], FileLineTuple[1]) - Index +=3D 1 - =20 - while self.__GetFd(): - pass - - while self.__GetFv(): - pass - - while self.__GetCapsule(): - pass - -# while self.__GetVtf(): -# pass -# -# while self.__GetRule(): -# pass - =20 - - except Warning, X: - self.__UndoToken() - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - X.message +=3D '\nGot Token: \"%s\" from File %s\n' % (self.__= Token, FileLineTuple[0]) + \ - 'Previous Token: \"%s\" At line: %d, Offset Within Line: %= d\n' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :].rstrip('\n').rstrip('\r'), FileLineTupl= e[1], self.CurrentOffsetWithinLine) - raise - - ## __GetDefines() method - # - # Get Defines section contents and store its data into AllMacrosList - # - # @param self The object pointer - # @retval True Successfully find a Defines - # @retval False Not able to find a Defines - # - def __GetDefines(self): - - if not self.__GetNextToken(): - return False - - S =3D self.__Token.upper() - if S.startswith("[") and not S.startswith("[DEFINES"): - if not S.startswith("[FD.") and not S.startswith("[FV.") and n= ot S.startswith("[CAPSULE.") \ - and not S.startswith("[VTF.") and not S.startswith("[RULE.= ") and not S.startswith("[OPTIONROM."): - raise Warning("Unknown section or section appear sequence = error (The correct sequence should be [DEFINES], [FD.], [FV.], [Capsule.], = [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber) - self.__UndoToken() - return False - - self.__UndoToken() - if not self.__IsToken("[DEFINES", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - #print 'Parsing String: %s in File %s, At line: %d, Offset Wit= hin Line: %d' \ - # % (self.Profile.FileLinesList[self.CurrentLineNumber = - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], s= elf.CurrentOffsetWithinLine) - raise Warning("expected [DEFINES", self.FileName, self.Current= LineNumber) - - if not self.__IsToken( "]"): - raise Warning("expected ']'", self.FileName, self.CurrentLineN= umber) - - while self.__GetNextWord(): - Macro =3D self.__Token - =20 - if not self.__IsToken("=3D"): - raise Warning("expected '=3D'", self.FileName, self.Curren= tLineNumber) - if not self.__GetNextToken() or self.__Token.startswith('['): - raise Warning("expected MACRO value", self.FileName, self.= CurrentLineNumber) - Value =3D self.__Token - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - MacProfile =3D MacroProfile(FileLineTuple[0], FileLineTuple[1]= ) - MacProfile.MacroName =3D Macro - MacProfile.MacroValue =3D Value - AllMacroList.append(MacProfile) - - return False - - ## __GetFd() method - # - # Get FD section contents and store its data into FD dictionary of s= elf.Profile - # - # @param self The object pointer - # @retval True Successfully find a FD - # @retval False Not able to find a FD - # - def __GetFd(self): - - if not self.__GetNextToken(): - return False - =20 - S =3D self.__Token.upper() - if S.startswith("[") and not S.startswith("[FD."): - if not S.startswith("[FV.") and not S.startswith("[CAPSULE.") = \ - and not S.startswith("[VTF.") and not S.startswith("[RULE.= "): - raise Warning("Unknown section At Line ", self.FileName, s= elf.CurrentLineNumber) - self.__UndoToken() - return False - =20 - self.__UndoToken() - if not self.__IsToken("[FD.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning("expected [FD.] At Line ", self.FileName, self.C= urrentLineNumber) - =20 - FdName =3D self.__GetUiName() - self.CurrentFdName =3D FdName.upper() - =20 - if not self.__IsToken( "]"): - raise Warning("expected ']' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - FdObj =3D CommonDataClass.FdfClass.FDClassObject() - FdObj.FdUiName =3D self.CurrentFdName - self.Profile.FdDict[self.CurrentFdName] =3D FdObj - Status =3D self.__GetCreateFile(FdObj) - if not Status: - raise Warning("FD name error At Line ", self.FileName, self.Cu= rrentLineNumber) - =20 - if not self.__GetTokenStatements(FdObj): - return False - =20 - self.__GetDefineStatements(FdObj) - - self.__GetSetStatements(FdObj) - - if not self.__GetRegionLayout(FdObj): - raise Warning("expected region layout At Line ", self.FileName= , self.CurrentLineNumber) - =20 - while self.__GetRegionLayout(FdObj): - pass - return True - =20 - ## __GetUiName() method - # - # Return the UI name of a section - # - # @param self The object pointer - # @retval FdName UI name - # - def __GetUiName(self): - FdName =3D "" - if self.__GetNextWord(): - FdName =3D self.__Token - =20 - return FdName - - ## __GetCreateFile() method - # - # Return the output file name of object - # - # @param self The object pointer - # @param Obj object whose data will be stored in file - # @retval FdName UI name - # - def __GetCreateFile(self, Obj): - - if self.__IsKeyword( "CREATE_FILE"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected file name At Line ", self.FileName= , self.CurrentLineNumber) - =20 - FileName =3D self.__Token - Obj.CreateFileName =3D FileName - - return True - - ## __GetTokenStatements() method - # - # Get token statements - # - # @param self The object pointer - # @param Obj for whom token statement is got - # @retval True Successfully find a token statement - # @retval False Not able to find a token statement - # - def __GetTokenStatements(self, Obj): - if not self.__IsKeyword( "BaseAddress"): - raise Warning("BaseAddress missing At Line ", self.FileName, s= elf.CurrentLineNumber) - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__GetNextHexNumber(): - raise Warning("expected Hex base address At Line ", self.FileN= ame, self.CurrentLineNumber) - =20 - Obj.BaseAddress =3D self.__Token - =20 - if self.__IsToken( "|"): - pcdPair =3D self.__GetNextPcdName() - Obj.BaseAddressPcd =3D pcdPair - self.Profile.PcdDict[pcdPair] =3D long(Obj.BaseAddress, 0) - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - self.Profile.PcdFileLineDict[pcdPair] =3D FileLineTuple - =20 - if not self.__IsKeyword( "Size"): - raise Warning("Size missing At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__GetNextHexNumber(): - raise Warning("expected Hex size At Line ", self.FileName, sel= f.CurrentLineNumber) - =20 - =20 - Obj.Size =3D long(self.__Token, 0) - - if self.__IsToken( "|"): - pcdPair =3D self.__GetNextPcdName() - Obj.SizePcd =3D pcdPair - self.Profile.PcdDict[pcdPair] =3D Obj.Size - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - self.Profile.PcdFileLineDict[pcdPair] =3D FileLineTuple - =20 - if not self.__IsKeyword( "ErasePolarity"): - raise Warning("ErasePolarity missing At Line ", self.FileName,= self.CurrentLineNumber) - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected Erase Polarity At Line ", self.FileNam= e, self.CurrentLineNumber) - =20 - if self.__Token !=3D "1" and self.__Token !=3D "0": - raise Warning("expected 1 or 0 Erase Polarity At Line ", self.= FileName, self.CurrentLineNumber) - =20 - Obj.ErasePolarity =3D self.__Token - - Status =3D self.__GetBlockStatements(Obj) - return Status - =20 - ## __GetAddressStatements() method - # - # Get address statements - # - # @param self The object pointer - # @param Obj for whom address statement is got - # @retval True Successfully find - # @retval False Not able to find - # - def __GetAddressStatements(self, Obj): - =20 - if self.__IsKeyword("BsBaseAddress"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextDecimalNumber() and not self.__GetNextHex= Number(): - raise Warning("expected address At Line ", self.FileName, = self.CurrentLineNumber) - =20 - BsAddress =3D long(self.__Token, 0) - Obj.BsBaseAddress =3D BsAddress - =20 - if self.__IsKeyword("RtBaseAddress"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextDecimalNumber() and not self.__GetNextHex= Number(): - raise Warning("expected address At Line ", self.FileName, = self.CurrentLineNumber) - =20 - RtAddress =3D long(self.__Token, 0) - Obj.RtBaseAddress =3D RtAddress - =20 - ## __GetBlockStatements() method - # - # Get block statements - # - # @param self The object pointer - # @param Obj for whom block statement is got - # @retval True Successfully find - # @retval False Not able to find - # - def __GetBlockStatements(self, Obj): - =20 - if not self.__GetBlockStatement(Obj): - #set default block size is 1 - Obj.BlockSizeList.append((1, Obj.Size, None)) - return True - - while self.__GetBlockStatement(Obj): - pass - =20 - for Item in Obj.BlockSizeList: - if Item[0] is None or Item[1] is None: - raise Warning("expected block statement for Fd Section", s= elf.FileName, self.CurrentLineNumber) - - return True - =20 - ## __GetBlockStatement() method - # - # Get block statement - # - # @param self The object pointer - # @param Obj for whom block statement is got - # @retval True Successfully find - # @retval False Not able to find - # - def __GetBlockStatement(self, Obj): - if not self.__IsKeyword( "BlockSize"): - return False - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__GetNextHexNumber() and not self.__GetNextDecimalNumb= er(): - raise Warning("expected Hex block size At Line ", self.FileNam= e, self.CurrentLineNumber) - - BlockSize =3D long(self.__Token, 0) - BlockSizePcd =3D None - if self.__IsToken( "|"): - PcdPair =3D self.__GetNextPcdName() - BlockSizePcd =3D PcdPair - self.Profile.PcdDict[PcdPair] =3D BlockSize - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - self.Profile.PcdFileLineDict[pcdPair] =3D FileLineTuple - =20 - BlockNumber =3D None - if self.__IsKeyword( "NumBlocks"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextDecimalNumber() and not self.__GetNextHex= Number(): - raise Warning("expected block numbers At Line ", self.File= Name, self.CurrentLineNumber) - =20 - BlockNumber =3D long(self.__Token, 0) - =20 - Obj.BlockSizeList.append((BlockSize, BlockNumber, BlockSizePcd)) - return True - - ## __GetDefineStatements() method - # - # Get define statements - # - # @param self The object pointer - # @param Obj for whom define statement is got - # @retval True Successfully find - # @retval False Not able to find - # - def __GetDefineStatements(self, Obj): - while self.__GetDefineStatement( Obj): - pass - =20 - ## __GetDefineStatement() method - # - # Get define statement - # - # @param self The object pointer - # @param Obj for whom define statement is got - # @retval True Successfully find - # @retval False Not able to find - # - def __GetDefineStatement(self, Obj): - if self.__IsKeyword("DEFINE"): - self.__GetNextToken() - Macro =3D self.__Token - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected value At Line ", self.FileName, se= lf.CurrentLineNumber) - - Value =3D self.__Token - Macro =3D '$(' + Macro + ')' - Obj.DefineVarDict[Macro] =3D Value - return True - =20 - return False - =20 - ## __GetSetStatements() method - # - # Get set statements - # - # @param self The object pointer - # @param Obj for whom set statement is got - # @retval True Successfully find - # @retval False Not able to find - # - def __GetSetStatements(self, Obj): - while self.__GetSetStatement(Obj): - pass - - ## __GetSetStatement() method - # - # Get set statement - # - # @param self The object pointer - # @param Obj for whom set statement is got - # @retval True Successfully find - # @retval False Not able to find - # - def __GetSetStatement(self, Obj): - if self.__IsKeyword("SET"): - PcdPair =3D self.__GetNextPcdName() - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected value At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - Value =3D self.__Token - if Value.startswith("{"): - # deal with value with {} - if not self.__SkipToToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, = self.CurrentLineNumber) - Value +=3D self.__SkippedChars - =20 - Obj.SetVarDict[PcdPair] =3D Value - self.Profile.PcdDict[PcdPair] =3D Value - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - self.Profile.PcdFileLineDict[PcdPair] =3D FileLineTuple - return True - - return False - - ## __GetRegionLayout() method - # - # Get region layout for FD - # - # @param self The object pointer - # @param Fd for whom region is got - # @retval True Successfully find - # @retval False Not able to find - # - def __GetRegionLayout(self, Fd): - if not self.__GetNextHexNumber(): - return False - =20 - RegionObj =3D CommonDataClass.FdfClass.RegionClassObject() - RegionObj.Offset =3D long(self.__Token, 0) - Fd.RegionList.append(RegionObj) - =20 - if not self.__IsToken( "|"): - raise Warning("expected '|' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - if not self.__GetNextHexNumber(): - raise Warning("expected Region Size At Line ", self.FileName, = self.CurrentLineNumber) - RegionObj.Size =3D long(self.__Token, 0) - =20 - if not self.__GetNextWord(): - return True - =20 - if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE"): - self.__UndoToken() - RegionObj.PcdOffset =3D self.__GetNextPcdName() - self.Profile.PcdDict[RegionObj.PcdOffset] =3D RegionObj.Offset= + long(Fd.BaseAddress, 0) - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - self.Profile.PcdFileLineDict[RegionObj.PcdOffset] =3D FileLine= Tuple - if self.__IsToken( "|"): - RegionObj.PcdSize =3D self.__GetNextPcdName() - self.Profile.PcdDict[RegionObj.PcdSize] =3D RegionObj.Size - FileLineTuple =3D GetRealFileLine(self.FileName, self.Curr= entLineNumber) - self.Profile.PcdFileLineDict[RegionObj.PcdSize] =3D FileLi= neTuple - =20 - if not self.__GetNextWord(): - return True - - if self.__Token =3D=3D "SET": - self.__UndoToken() - self.__GetSetStatements( RegionObj) - if not self.__GetNextWord(): - return True - =20 - elif self.__Token =3D=3D "FV": - self.__UndoToken() - self.__GetRegionFvType( RegionObj) - - elif self.__Token =3D=3D "CAPSULE": - self.__UndoToken() - self.__GetRegionCapType( RegionObj) - - elif self.__Token =3D=3D "FILE": - self.__UndoToken() - self.__GetRegionFileType( RegionObj) - - else: - self.__UndoToken() - self.__GetRegionDataType( RegionObj) - =20 - return True - =20 - ## __GetRegionFvType() method - # - # Get region fv data for region - # - # @param self The object pointer - # @param RegionObj for whom region data is got - # - def __GetRegionFvType(self, RegionObj): - - if not self.__IsKeyword( "FV"): - raise Warning("expected Keyword 'FV' At Line ", self.FileName,= self.CurrentLineNumber) - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected FV name At Line ", self.FileName, self= .CurrentLineNumber) - =20 - RegionObj.RegionType =3D "FV" - RegionObj.RegionDataList.append(self.__Token) - =20 - while self.__IsKeyword( "FV"): - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected FV name At Line ", self.FileName, = self.CurrentLineNumber) - =20 - RegionObj.RegionDataList.append(self.__Token) - - ## __GetRegionCapType() method - # - # Get region capsule data for region - # - # @param self The object pointer - # @param RegionObj for whom region data is got - # - def __GetRegionCapType(self, RegionObj): - - if not self.__IsKeyword("CAPSULE"): - raise Warning("expected Keyword 'CAPSULE' at line", self.FileN= ame, self.CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' at line", self.FileName, self.Cu= rrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected CAPSULE name at line", self.FileName, = self.CurrentLineNumber) - - RegionObj.RegionType =3D "CAPSULE" - RegionObj.RegionDataList.append(self.__Token) - - while self.__IsKeyword("CAPSULE"): - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' at line", self.FileName, sel= f.CurrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected CAPSULE name at line", self.FileNa= me, self.CurrentLineNumber) - - RegionObj.RegionDataList.append(self.__Token) - - ## __GetRegionFileType() method - # - # Get region file data for region - # - # @param self The object pointer - # @param RegionObj for whom region data is got - # - def __GetRegionFileType(self, RegionObj): - - if not self.__IsKeyword( "FILE"): - raise Warning("expected Keyword 'FILE' At Line ", self.FileNam= e, self.CurrentLineNumber) - - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected File name At Line ", self.FileName, se= lf.CurrentLineNumber) - - RegionObj.RegionType =3D "FILE" - RegionObj.RegionDataList.append( self.__Token) - =20 - while self.__IsKeyword( "FILE"): - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected FILE name At Line ", self.FileName= , self.CurrentLineNumber) - =20 - RegionObj.RegionDataList.append(self.__Token) - - ## __GetRegionDataType() method - # - # Get region array data for region - # - # @param self The object pointer - # @param RegionObj for whom region data is got - # - def __GetRegionDataType(self, RegionObj): - =20 - if not self.__IsKeyword( "DATA"): - raise Warning("expected Region Data type At Line ", self.FileN= ame, self.CurrentLineNumber) - - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__IsToken( "{"): - raise Warning("expected '{' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - if not self.__GetNextHexNumber(): - raise Warning("expected Hex byte At Line ", self.FileName, sel= f.CurrentLineNumber) - =20 - if len(self.__Token) > 18: - raise Warning("Hex string can't be converted to a valid UINT64= value", self.FileName, self.CurrentLineNumber) - =20 - DataString =3D self.__Token - DataString +=3D "," - =20 - while self.__IsToken(","): - if not self.__GetNextHexNumber(): - raise Warning("Invalid Hex number At Line ", self.FileName= , self.CurrentLineNumber) - if len(self.__Token) > 4: - raise Warning("Hex byte(must be 2 digits) too long At Line= ", self.FileName, self.CurrentLineNumber) - DataString +=3D self.__Token - DataString +=3D "," - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - DataString =3D DataString.rstrip(",") - RegionObj.RegionType =3D "DATA" - RegionObj.RegionDataList.append( DataString) - =20 - while self.__IsKeyword( "DATA"): - - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__IsToken( "{"): - raise Warning("expected '{' At Line ", self.FileName, self= .CurrentLineNumber) - =20 - if not self.__GetNextHexNumber(): - raise Warning("expected Hex byte At Line ", self.FileName,= self.CurrentLineNumber) - =20 - if len(self.__Token) > 18: - raise Warning("Hex string can't be converted to a valid UI= NT64 value", self.FileName, self.CurrentLineNumber) - =20 - DataString =3D self.__Token - DataString +=3D "," - =20 - while self.__IsToken(","): - self.__GetNextHexNumber() - if len(self.__Token) > 4: - raise Warning("Hex byte(must be 2 digits) too long At = Line ", self.FileName, self.CurrentLineNumber) - DataString +=3D self.__Token - DataString +=3D "," - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, self= .CurrentLineNumber) - =20 - DataString =3D DataString.rstrip(",") - RegionObj.RegionDataList.append( DataString) - =20 - ## __GetFv() method - # - # Get FV section contents and store its data into FV dictionary of s= elf.Profile - # - # @param self The object pointer - # @retval True Successfully find a FV - # @retval False Not able to find a FV - # =20 - def __GetFv(self): - if not self.__GetNextToken(): - return False - - S =3D self.__Token.upper() - if S.startswith("[") and not S.startswith("[FV."): - if not S.startswith("[CAPSULE.") \ - and not S.startswith("[VTF.") and not S.startswith("[RULE.= "): - raise Warning("Unknown section or section appear sequence = error \n(The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [= Rule.]) At Line ", self.FileName, self.CurrentLineNumber) - self.__UndoToken() - return False - - self.__UndoToken() - if not self.__IsToken("[FV.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning("Unknown Keyword At Line ", self.FileName, self.= CurrentLineNumber) - =20 - FvName =3D self.__GetUiName() - self.CurrentFvName =3D FvName.upper() - =20 - if not self.__IsToken( "]"): - raise Warning("expected ']' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - FvObj =3D CommonDataClass.FdfClass.FvClassObject() - FvObj.UiFvName =3D self.CurrentFvName - self.Profile.FvDict[self.CurrentFvName] =3D FvObj - =20 - Status =3D self.__GetCreateFile(FvObj) - if not Status: - raise Warning("FV name error At Line ", self.FileName, self.Cu= rrentLineNumber) - - self.__GetDefineStatements(FvObj) - - self.__GetAddressStatements(FvObj) - =20 - self.__GetBlockStatement(FvObj) - - self.__GetSetStatements(FvObj) - - self.__GetFvAlignment(FvObj) - - self.__GetFvAttributes(FvObj) - =20 - self.__GetFvNameGuid(FvObj) - - self.__GetAprioriSection(FvObj, FvObj.DefineVarDict.copy()) - self.__GetAprioriSection(FvObj, FvObj.DefineVarDict.copy()) - =20 - while True: - isInf =3D self.__GetInfStatement(FvObj, MacroDict =3D FvObj.De= fineVarDict.copy()) - isFile =3D self.__GetFileStatement(FvObj, MacroDict =3D FvObj.= DefineVarDict.copy()) - if not isInf and not isFile: - break - =20 - return True - - ## __GetFvAlignment() method - # - # Get alignment for FV - # - # @param self The object pointer - # @param Obj for whom alignment is got - # @retval True Successfully find a alignment statement - # @retval False Not able to find a alignment statement - # - def __GetFvAlignment(self, Obj): - =20 - if not self.__IsKeyword( "FvAlignment"): - return False - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected alignment value At Line ", self.FileNa= me, self.CurrentLineNumber) - =20 - if self.__Token.upper() not in ("1", "2", "4", "8", "16", "32", "6= 4", "128", "256", "512", \ - "1K", "2K", "4K", "8K", "16K", "32= K", "64K", "128K", "256K", "512K", \ - "1M", "2M", "4M", "8M", "16M", "32= M", "64M", "128M", "256M", "512M", \ - "1G", "2G"): - raise Warning("Unknown alignment value At Line ", self.FileNam= e, self.CurrentLineNumber) - Obj.FvAlignment =3D self.__Token - return True - =20 - ## __GetFvAttributes() method - # - # Get attributes for FV - # - # @param self The object pointer - # @param Obj for whom attribute is got - # @retval None - # - def __GetFvAttributes(self, FvObj): - =20 - while self.__GetNextWord(): - name =3D self.__Token - if name not in ("ERASE_POLARITY", "MEMORY_MAPPED", \ - "STICKY_WRITE", "LOCK_CAP", "LOCK_STATUS", "WRI= TE_ENABLED_CAP", \ - "WRITE_DISABLED_CAP", "WRITE_STATUS", "READ_ENA= BLED_CAP", \ - "READ_DISABLED_CAP", "READ_STATUS", "READ_LOCK_= CAP", \ - "READ_LOCK_STATUS", "WRITE_LOCK_CAP", "WRITE_LO= CK_STATUS", \ - "WRITE_POLICY_RELIABLE"): - self.__UndoToken() - return - - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken() or self.__Token.upper() not in ("= TRUE", "FALSE", "1", "0"): - raise Warning("expected TRUE/FALSE (1/0) At Line ", self.F= ileName, self.CurrentLineNumber) - =20 - FvObj.FvAttributeDict[name] =3D self.__Token - - return - =20 - ## __GetFvNameGuid() method - # - # Get FV GUID for FV - # - # @param self The object pointer - # @param Obj for whom GUID is got - # @retval None - # - def __GetFvNameGuid(self, FvObj): - - if not self.__IsKeyword( "FvNameGuid"): - return - - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D'", self.FileName, self.CurrentLin= eNumber) - - if not self.__GetNextGuid(): - raise Warning("expected FV GUID value", self.FileName, self.Cu= rrentLineNumber) - - FvObj.FvNameGuid =3D self.__Token - - return - - ## __GetAprioriSection() method - # - # Get token statements - # - # @param self The object pointer - # @param FvObj for whom apriori is got - # @param MacroDict dictionary used to replace macro - # @retval True Successfully find apriori statement - # @retval False Not able to find apriori statement - # - def __GetAprioriSection(self, FvObj, MacroDict =3D {}): - =20 - if not self.__IsKeyword( "APRIORI"): - return False - =20 - if not self.__IsKeyword("PEI") and not self.__IsKeyword("DXE"): - raise Warning("expected Apriori file type At Line ", self.File= Name, self.CurrentLineNumber) - AprType =3D self.__Token - =20 - if not self.__IsToken( "{"): - raise Warning("expected '{' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - AprSectionObj =3D CommonDataClass.FdfClass.AprioriSectionClassObje= ct() - AprSectionObj.AprioriType =3D AprType - =20 - self.__GetDefineStatements(AprSectionObj) - MacroDict.update(AprSectionObj.DefineVarDict) - =20 - while True: - IsInf =3D self.__GetInfStatement( AprSectionObj, MacroDict =3D= MacroDict) - IsFile =3D self.__GetFileStatement( AprSectionObj) - if not IsInf and not IsFile: - break - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, self.Cur= rentLineNumber) - - FvObj.AprioriSectionList.append(AprSectionObj) - return True - - ## __GetInfStatement() method - # - # Get INF statements - # - # @param self The object pointer - # @param Obj for whom inf statement is got - # @param MacroDict dictionary used to replace macro - # @retval True Successfully find inf statement - # @retval False Not able to find inf statement - # - def __GetInfStatement(self, Obj, ForCapsule =3D False, MacroDict =3D {= }): - - if not self.__IsKeyword( "INF"): - return False - =20 - ffsInf =3D CommonDataClass.FdfClass.FfsInfStatementClassObject() - self.__GetInfOptions( ffsInf) - =20 - if not self.__GetNextToken(): - raise Warning("expected INF file path At Line ", self.FileName= , self.CurrentLineNumber) - ffsInf.InfFileName =3D self.__Token - =20 -# if ffsInf.InfFileName.find('$') >=3D 0: -# ffsInf.InfFileName =3D GenFdsGlobalVariable.GenFdsGlobalVaria= ble.MacroExtend(ffsInf.InfFileName, MacroDict) - =20 - if not ffsInf.InfFileName in self.Profile.InfList: - self.Profile.InfList.append(ffsInf.InfFileName) - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - self.Profile.InfFileLineList.append(FileLineTuple) - =20 - if self.__IsToken('|'): - if self.__IsKeyword('RELOCS_STRIPPED'): - ffsInf.KeepReloc =3D False - elif self.__IsKeyword('RELOCS_RETAINED'): - ffsInf.KeepReloc =3D True - else: - raise Warning("Unknown reloc strip flag At Line ", self.Fi= leName, self.CurrentLineNumber) - =20 - if ForCapsule: - capsuleFfs =3D CapsuleData.CapsuleFfs() - capsuleFfs.Ffs =3D ffsInf - Obj.CapsuleDataList.append(capsuleFfs) - else: - Obj.FfsList.append(ffsInf) - return True - =20 - ## __GetInfOptions() method - # - # Get options for INF - # - # @param self The object pointer - # @param FfsInfObj for whom option is got - # - def __GetInfOptions(self, FfsInfObj): - =20 - if self.__IsKeyword( "RuleOverride"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected Rule name At Line ", self.FileName= , self.CurrentLineNumber) - FfsInfObj.Rule =3D self.__Token - =20 - if self.__IsKeyword( "VERSION"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected Version At Line ", self.FileName, = self.CurrentLineNumber) - =20 - if self.__GetStringData(): - FfsInfObj.Version =3D self.__Token - =20 - if self.__IsKeyword( "UI"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected UI name At Line ", self.FileName, = self.CurrentLineNumber) - =20 - if self.__GetStringData(): - FfsInfObj.Ui =3D self.__Token - - if self.__IsKeyword( "USE"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D'", self.FileName, self.Curren= tLineNumber) - if not self.__GetNextToken(): - raise Warning("expected ARCH name", self.FileName, self.Cu= rrentLineNumber) - FfsInfObj.UseArch =3D self.__Token - - =20 - if self.__GetNextToken(): - if TokenFindPattern.match(self.__Token): - FfsInfObj.KeyStringList.append(self.__Token) - if not self.__IsToken(","): - return - else: - self.__UndoToken() - return - =20 - while self.__GetNextToken(): - if not TokenFindPattern.match(self.__Token): - raise Warning("expected KeyString \"Target_Tag_Arch\" = At Line ", self.FileName, self.CurrentLineNumber) - FfsInfObj.KeyStringList.append(self.__Token) - =20 - if not self.__IsToken(","): - break - =20 - ## __GetFileStatement() method - # - # Get FILE statements - # - # @param self The object pointer - # @param Obj for whom FILE statement is got - # @param MacroDict dictionary used to replace macro - # @retval True Successfully find FILE statement - # @retval False Not able to find FILE statement - # - def __GetFileStatement(self, Obj, ForCapsule =3D False, MacroDict =3D = {}): - - if not self.__IsKeyword( "FILE"): - return False - =20 - FfsFileObj =3D CommonDataClass.FdfClass.FileStatementClassObject() - =20 - if not self.__GetNextWord(): - raise Warning("expected FFS type At Line ", self.FileName, sel= f.CurrentLineNumber) - FfsFileObj.FvFileType =3D self.__Token - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if not self.__GetNextGuid(): - if not self.__GetNextWord(): - raise Warning("expected File GUID", self.FileName, self.Cu= rrentLineNumber) - if self.__Token =3D=3D 'PCD': - if not self.__IsToken( "("): - raise Warning("expected '('", self.FileName, self.Curr= entLineNumber) - PcdPair =3D self.__GetNextPcdName() - if not self.__IsToken( ")"): - raise Warning("expected ')'", self.FileName, self.Curr= entLineNumber) - self.__Token =3D 'PCD('+PcdPair[1]+'.'+PcdPair[0]+')' - =20 - FfsFileObj.NameGuid =3D self.__Token - =20 - self.__GetFilePart( FfsFileObj, MacroDict.copy()) - =20 - if ForCapsule: - capsuleFfs =3D CapsuleData.CapsuleFfs() - capsuleFfs.Ffs =3D FfsFileObj - Obj.CapsuleDataList.append(capsuleFfs) - else: - Obj.FfsList.append(FfsFileObj) - =20 - return True - =20 - ## __FileCouldHaveRelocFlag() method - # - # Check whether reloc strip flag can be set for a file type. - # - # @param FileType The file type to check with - # @retval True This type could have relocation strip flag - # @retval False No way to have it - # - @staticmethod - def __FileCouldHaveRelocFlag (FileType): - if FileType in ('SEC', 'PEI_CORE', 'PEIM', 'PEI_DXE_COMBO'): - return True - else: - return False - =20 - ## __SectionCouldHaveRelocFlag() method - # - # Check whether reloc strip flag can be set for a section type. - # - # @param SectionType The section type to check with - # @retval True This type could have relocation strip flag - # @retval False No way to have it - # - @staticmethod - def __SectionCouldHaveRelocFlag (SectionType): - if SectionType in ('TE', 'PE32'): - return True - else: - return False - =20 - ## __GetFilePart() method - # - # Get components for FILE statement - # - # @param self The object pointer - # @param FfsFileObj for whom component is got - # @param MacroDict dictionary used to replace macro - # - def __GetFilePart(self, FfsFileObj, MacroDict =3D {}): - =20 - self.__GetFileOpts( FfsFileObj) - =20 - if not self.__IsToken("{"): -# if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('R= ELOCS_RETAINED'): -# if self.__FileCouldHaveRelocFlag(FfsFileObj.FvFileType): -# if self.__Token =3D=3D 'RELOCS_STRIPPED': -# FfsFileObj.KeepReloc =3D False -# else: -# FfsFileObj.KeepReloc =3D True -# else: -# raise Warning("File type %s could not have reloc stri= p flag At Line %d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.= FileName, self.CurrentLineNumber) -# =20 -# if not self.__IsToken("{"): - raise Warning("expected '{' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected File name or section data At Line ", s= elf.FileName, self.CurrentLineNumber) - =20 - if self.__Token =3D=3D "FV": - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected FV name At Line ", self.FileName, = self.CurrentLineNumber) - FfsFileObj.FvName =3D self.__Token - =20 - elif self.__Token =3D=3D "FD": - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected FD name At Line ", self.FileName, = self.CurrentLineNumber) - FfsFileObj.FdName =3D self.__Token - =20 - elif self.__Token in ("DEFINE", "APRIORI", "SECTION"): - self.__UndoToken() - self.__GetSectionData( FfsFileObj, MacroDict) - else: - FfsFileObj.FileName =3D self.__Token - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - ## __GetFileOpts() method - # - # Get options for FILE statement - # - # @param self The object pointer - # @param FfsFileObj for whom options is got - # - def __GetFileOpts(self, FfsFileObj): - =20 - if self.__GetNextToken(): - if TokenFindPattern.match(self.__Token): - FfsFileObj.KeyStringList.append(self.__Token) - if self.__IsToken(","): - while self.__GetNextToken(): - if not TokenFindPattern.match(self.__Token): - raise Warning("expected KeyString \"Target_Tag= _Arch\" At Line ", self.FileName, self.CurrentLineNumber) - FfsFileObj.KeyStringList.append(self.__Token) - - if not self.__IsToken(","): - break - =20 - else: - self.__UndoToken() - - if self.__IsKeyword( "FIXED", True): - FfsFileObj.Fixed =3D True - =20 - if self.__IsKeyword( "CHECKSUM", True): - FfsFileObj.CheckSum =3D True - =20 - if self.__GetAlignment(): - FfsFileObj.Alignment =3D self.__Token - =20 - =20 - =20 - ## __GetAlignment() method - # - # Return the alignment value - # - # @param self The object pointer - # @retval True Successfully find alignment - # @retval False Not able to find alignment - # - def __GetAlignment(self): - if self.__IsKeyword( "Align", True): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected alignment value At Line ", self.Fi= leName, self.CurrentLineNumber) - return True - =20 - return False - =20 - ## __GetFilePart() method - # - # Get section data for FILE statement - # - # @param self The object pointer - # @param FfsFileObj for whom section is got - # @param MacroDict dictionary used to replace macro - # - def __GetSectionData(self, FfsFileObj, MacroDict =3D {}): - Dict =3D {} - Dict.update(MacroDict) - =20 - self.__GetDefineStatements(FfsFileObj) - =20 - Dict.update(FfsFileObj.DefineVarDict) - self.__GetAprioriSection(FfsFileObj, Dict.copy()) - self.__GetAprioriSection(FfsFileObj, Dict.copy()) - =20 - while True: - IsLeafSection =3D self.__GetLeafSection(FfsFileObj, Dict) - IsEncapSection =3D self.__GetEncapsulationSec(FfsFileObj) - if not IsLeafSection and not IsEncapSection: - break - =20 - ## __GetLeafSection() method - # - # Get leaf section for Obj - # - # @param self The object pointer - # @param Obj for whom leaf section is got - # @param MacroDict dictionary used to replace macro - # @retval True Successfully find section statement - # @retval False Not able to find section statement - # - def __GetLeafSection(self, Obj, MacroDict =3D {}): - =20 - OldPos =3D self.GetFileBufferPos() - =20 - if not self.__IsKeyword( "SECTION"): - if len(Obj.SectionList) =3D=3D 0: - raise Warning("expected SECTION At Line ", self.FileName, = self.CurrentLineNumber) - else: - return False - =20 - AlignValue =3D None - if self.__GetAlignment(): - if self.__Token not in ("Auto", "8", "16", "32", "64", "128", = "512", "1K", "4K", "32K" ,"64K", "128K", - "256K", "512K", "1M", "2M", "4M", "8M"= , "16M"): - raise Warning("Incorrect alignment '%s'" % self.__Token, s= elf.FileName, self.CurrentLineNumber) - AlignValue =3D self.__Token - =20 - BuildNum =3D None - if self.__IsKeyword( "BUILD_NUM"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected Build number value At Line ", self= .FileName, self.CurrentLineNumber) - =20 - BuildNum =3D self.__Token - =20 - if self.__IsKeyword( "VERSION"): - if AlignValue =3D=3D 'Auto': - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected version At Line ", self.FileName, = self.CurrentLineNumber) - VerSectionObj =3D CommonDataClass.FdfClass.VerSectionClassObje= ct() - VerSectionObj.Alignment =3D AlignValue - VerSectionObj.BuildNum =3D BuildNum - if self.__GetStringData(): - VerSectionObj.StringData =3D self.__Token - else: - VerSectionObj.FileName =3D self.__Token - Obj.SectionList.append(VerSectionObj) - - elif self.__IsKeyword( "UI"): - if AlignValue =3D=3D 'Auto': - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected UI At Line ", self.FileName, self.= CurrentLineNumber) - UiSectionObj =3D CommonDataClass.FdfClass.UiSectionClassObject= () - UiSectionObj.Alignment =3D AlignValue - if self.__GetStringData(): - UiSectionObj.StringData =3D self.__Token - else: - UiSectionObj.FileName =3D self.__Token - Obj.SectionList.append(UiSectionObj) - =20 - elif self.__IsKeyword( "FV_IMAGE"): - if AlignValue =3D=3D 'Auto': - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__GetNextWord(): - raise Warning("expected FV name At Line ", self.FileName, = self.CurrentLineNumber) - =20 - FvName =3D self.__Token.upper() - FvObj =3D None - - if self.__IsToken( "{"): - FvObj =3D Fv.FV() - FvObj.UiFvName =3D FvName - self.__GetDefineStatements(FvObj) - MacroDict.update(FvObj.DefineVarDict) - self.__GetBlockStatement(FvObj) - self.__GetSetStatements(FvObj) - self.__GetFvAlignment(FvObj) - self.__GetFvAttributes(FvObj) - self.__GetAprioriSection(FvObj, MacroDict.copy()) - self.__GetAprioriSection(FvObj, MacroDict.copy()) - =20 - while True: - IsInf =3D self.__GetInfStatement(FvObj, MacroDict.copy= ()) - IsFile =3D self.__GetFileStatement(FvObj, MacroDict.co= py()) - if not IsInf and not IsFile: - break - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, = self.CurrentLineNumber) - =20 - FvImageSectionObj =3D CommonDataClass.FdfClass.FvImageSectionC= lassObject() - FvImageSectionObj.Alignment =3D AlignValue - if FvObj is not None: - FvImageSectionObj.Fv =3D FvObj - FvImageSectionObj.FvName =3D None - else: - FvImageSectionObj.FvName =3D FvName - =20 - Obj.SectionList.append(FvImageSectionObj)=20 - =20 - elif self.__IsKeyword("PEI_DEPEX_EXP") or self.__IsKeyword("DXE_DE= PEX_EXP") or self.__IsKeyword("SMM_DEPEX_EXP"): - if AlignValue =3D=3D 'Auto': - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) - DepexSectionObj =3D CommonDataClass.FdfClass.DepexSectionClass= Object() - DepexSectionObj.Alignment =3D AlignValue - DepexSectionObj.DepexType =3D self.__Token - =20 - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - if not self.__IsToken( "{"): - raise Warning("expected '{' At Line ", self.FileName, self= .CurrentLineNumber) - if not self.__SkipToToken( "}"): - raise Warning("expected Depex expression ending '}' At Lin= e ", self.FileName, self.CurrentLineNumber) - =20 - DepexSectionObj.Expression =3D self.__SkippedChars.rstrip('}') - Obj.SectionList.append(DepexSectionObj) - =20 - else: - =20 - if not self.__GetNextWord(): - raise Warning("expected section type At Line ", self.FileN= ame, self.CurrentLineNumber) - =20 - # Encapsulation section appear, UndoToken and return - if self.__Token =3D=3D "COMPRESS" or self.__Token =3D=3D "GUID= ED": - self.SetFileBufferPos(OldPos) - return False - =20 - if self.__Token not in ("COMPAT16", "PE32", "PIC", "TE", "FV_I= MAGE", "RAW", "DXE_DEPEX",\ - "UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID= ", "SMM_DEPEX"): - raise Warning("Unknown section type '%s'" % self.__Token, = self.FileName, self.CurrentLineNumber) - if AlignValue =3D=3D 'Auto'and (not self.__Token =3D=3D 'PE32'= ) and (not self.__Token =3D=3D 'TE'): - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) - # DataSection - DataSectionObj =3D CommonDataClass.FdfClass.DataSectionClassOb= ject() - DataSectionObj.Alignment =3D AlignValue - DataSectionObj.SecType =3D self.__Token - =20 - if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RE= LOCS_RETAINED'): - if self.__FileCouldHaveRelocFlag(Obj.FvFileType) and self.= __SectionCouldHaveRelocFlag(DataSectionObj.SecType): - if self.__Token =3D=3D 'RELOCS_STRIPPED': - DataSectionObj.KeepReloc =3D False - else: - DataSectionObj.KeepReloc =3D True - else: - raise Warning("File type %s, section type %s, could no= t have reloc strip flag At Line %d" % (Obj.FvFileType, DataSectionObj.SecTy= pe, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber) - =20 - if self.__IsToken("=3D"): - if not self.__GetNextToken(): - raise Warning("expected section file path At Line ", s= elf.FileName, self.CurrentLineNumber) - DataSectionObj.SectFileName =3D self.__Token - else: - if not self.__GetCglSection(DataSectionObj): - return False - =20 - Obj.SectionList.append(DataSectionObj) - =20 - return True - =20 - ## __GetCglSection() method - # - # Get compressed or GUIDed section for Obj - # - # @param self The object pointer - # @param Obj for whom leaf section is got - # @param AlignValue alignment value for complex section - # @retval True Successfully find section statement - # @retval False Not able to find section statement - # - def __GetCglSection(self, Obj, AlignValue =3D None): - =20 - if self.__IsKeyword( "COMPRESS"): - type =3D "PI_STD" - if self.__IsKeyword("PI_STD") or self.__IsKeyword("PI_NONE"): - type =3D self.__Token - =20 - if not self.__IsToken("{"): - raise Warning("expected '{' At Line ", self.FileName, self= .CurrentLineNumber) - - CompressSectionObj =3D CommonDataClass.FdfClass.CompressSectio= nClassObject() - CompressSectionObj.Alignment =3D AlignValue - CompressSectionObj.CompType =3D type - # Recursive sections... - while True: - IsLeafSection =3D self.__GetLeafSection(CompressSectionObj= ) - IsEncapSection =3D self.__GetEncapsulationSec(CompressSect= ionObj) - if not IsLeafSection and not IsEncapSection: - break - =20 - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, self= .CurrentLineNumber) - Obj.SectionList.append(CompressSectionObj) - =20 -# else: -# raise Warning("Compress type not known At Line ")=20 - =20 - return True - =20 - elif self.__IsKeyword( "GUIDED"): - GuidValue =3D None - if self.__GetNextGuid(): - GuidValue =3D self.__Token - - AttribDict =3D self.__GetGuidAttrib() - if not self.__IsToken("{"): - raise Warning("expected '{' At Line ", self.FileName, self= .CurrentLineNumber) - GuidSectionObj =3D CommonDataClass.FdfClass.GuidSectionClassOb= ject() - GuidSectionObj.Alignment =3D AlignValue - GuidSectionObj.NameGuid =3D GuidValue - GuidSectionObj.SectionType =3D "GUIDED" - GuidSectionObj.ProcessRequired =3D AttribDict["PROCESSING_REQU= IRED"] - GuidSectionObj.AuthStatusValid =3D AttribDict["AUTH_STATUS_VAL= ID"] - # Recursive sections... - while True: - IsLeafSection =3D self.__GetLeafSection(GuidSectionObj) - IsEncapSection =3D self.__GetEncapsulationSec(GuidSectionO= bj) - if not IsLeafSection and not IsEncapSection: - break - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, self= .CurrentLineNumber) - Obj.SectionList.append(GuidSectionObj) - =20 - return True - =20 - return False - - ## __GetGuidAttri() method - # - # Get attributes for GUID section - # - # @param self The object pointer - # @retval AttribDict Dictionary of key-value pair of section attrib= utes - # - def __GetGuidAttrib(self): - =20 - AttribDict =3D {} - AttribDict["PROCESSING_REQUIRED"] =3D False - AttribDict["AUTH_STATUS_VALID"] =3D False - if self.__IsKeyword("PROCESSING_REQUIRED") or self.__IsKeyword("AU= TH_STATUS_VALID"): - AttribKey =3D self.__Token - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken() or self.__Token.upper() not in ("= TRUE", "FALSE", "1", "0"): - raise Warning("expected TRUE/FALSE (1/0) At Line ", self.F= ileName, self.CurrentLineNumber) - AttribDict[AttribKey] =3D self.__Token - =20 - if self.__IsKeyword("PROCESSING_REQUIRED") or self.__IsKeyword("AU= TH_STATUS_VALID"): - AttribKey =3D self.__Token - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ") - - if not self.__GetNextToken() or self.__Token.upper() not in ("= TRUE", "FALSE", "1", "0"): - raise Warning("expected TRUE/FALSE (1/0) At Line ", self.F= ileName, self.CurrentLineNumber) - AttribDict[AttribKey] =3D self.__Token - =20 - return AttribDict - =20 - ## __GetEncapsulationSec() method - # - # Get encapsulation section for FILE - # - # @param self The object pointer - # @param FfsFile for whom section is got - # @retval True Successfully find section statement - # @retval False Not able to find section statement - # - def __GetEncapsulationSec(self, FfsFileObj): =20 - =20 - OldPos =3D self.GetFileBufferPos() - if not self.__IsKeyword( "SECTION"): - if len(FfsFileObj.SectionList) =3D=3D 0: - raise Warning("expected SECTION At Line ", self.FileName, = self.CurrentLineNumber) - else: - return False - =20 - AlignValue =3D None - if self.__GetAlignment(): - if self.__Token not in ("8", "16", "32", "64", "128", "512", "= 1K", "4K", "32K" ,"64K", "128K", - "256K", "512K", "1M", "2M", "4M", "8M"= , "16M"): - raise Warning("Incorrect alignment '%s'" % self.__Token, s= elf.FileName, self.CurrentLineNumber) - AlignValue =3D self.__Token - =20 - if not self.__GetCglSection(FfsFileObj, AlignValue): - self.SetFileBufferPos(OldPos) - return False - else: - return True - - ## __GetCapsule() method - # - # Get capsule section contents and store its data into capsule list = of self.Profile - # - # @param self The object pointer - # @retval True Successfully find a capsule - # @retval False Not able to find a capsule - # - def __GetCapsule(self): - =20 - if not self.__GetNextToken(): - return False - - S =3D self.__Token.upper() - if S.startswith("[") and not S.startswith("[CAPSULE."): - if not S.startswith("[VTF.") and not S.startswith("[RULE.") an= d not S.startswith("[OPTIONROM."): - raise Warning("Unknown section or section appear sequence = error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Ru= le.], [OptionRom.])", self.FileName, self.CurrentLineNumber) - self.__UndoToken() - return False - - self.__UndoToken() - if not self.__IsToken("[CAPSULE.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning("expected [Capsule.] At Line ", self.FileName, s= elf.CurrentLineNumber) =20 - =20 - CapsuleObj =3D CommonDataClass.FdfClass.CapsuleClassObject() - - CapsuleName =3D self.__GetUiName() - if not CapsuleName: - raise Warning("expected capsule name At line ", self.FileName,= self.CurrentLineNumber) - =20 - CapsuleObj.UiCapsuleName =3D CapsuleName.upper() - =20 - if not self.__IsToken( "]"): - raise Warning("expected ']' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - if self.__IsKeyword("CREATE_FILE"): - if not self.__IsToken( "=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected file name At Line ", self.FileName= , self.CurrentLineNumber) - =20 - CapsuleObj.CreateFile =3D self.__Token - =20 - self.__GetCapsuleStatements(CapsuleObj) - self.Profile.CapsuleList.append(CapsuleObj) - return True =20 - =20 - ## __GetCapsuleStatements() method - # - # Get statements for capsule - # - # @param self The object pointer - # @param Obj for whom statements are got - # - def __GetCapsuleStatements(self, Obj): - self.__GetCapsuleTokens(Obj) - self.__GetDefineStatements(Obj) - self.__GetSetStatements(Obj) - =20 - self.__GetCapsuleData(Obj) - =20 - ## __GetCapsuleStatements() method - # - # Get token statements for capsule - # - # @param self The object pointer - # @param Obj for whom token statements are got - # - def __GetCapsuleTokens(self, Obj): - =20 - if not self.__IsKeyword("CAPSULE_GUID"): - raise Warning("expected 'CAPSULE_GUID' At Line ", self.FileNam= e, self.CurrentLineNumber) - =20 - while self.__CurrentLine().find("=3D") !=3D -1: - NameValue =3D self.__CurrentLine().split("=3D") - Obj.TokensDict[NameValue[0].strip()] =3D NameValue[1].strip() - self.CurrentLineNumber +=3D 1 - self.CurrentOffsetWithinLine =3D 0 - =20 - ## __GetCapsuleData() method - # - # Get capsule data for capsule - # - # @param self The object pointer - # @param Obj for whom capsule data are got - # - def __GetCapsuleData(self, Obj): - =20 - while True: - IsInf =3D self.__GetInfStatement(Obj, True) - IsFile =3D self.__GetFileStatement(Obj, True) - IsFv =3D self.__GetFvStatement(Obj) - if not IsInf and not IsFile and not IsFv: - break - =20 - ## __GetFvStatement() method - # - # Get FV for capsule - # - # @param self The object pointer - # @param CapsuleObj for whom FV is got - # @retval True Successfully find a FV statement - # @retval False Not able to find a FV statement - # - def __GetFvStatement(self, CapsuleObj): - =20 - if not self.__IsKeyword("FV"): - return False - =20 - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected FV name At Line ", self.FileName, self= .CurrentLineNumber) - =20 -# CapsuleFv =3D CapsuleData.CapsuleFv() -# CapsuleFv.FvName =3D self.__Token -# CapsuleObj.CapsuleDataList.append(CapsuleFv) - return True - =20 - ## __GetRule() method - # - # Get Rule section contents and store its data into rule list of sel= f.Profile - # - # @param self The object pointer - # @retval True Successfully find a Rule - # @retval False Not able to find a Rule - # - def __GetRule(self): - =20 - if not self.__GetNextToken(): - return False - - S =3D self.__Token.upper() - if S.startswith("[") and not S.startswith("[RULE."): - if not S.startswith("[OPTIONROM."): - raise Warning("Unknown section or section appear sequence = error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Ru= le.], [OptionRom.])", self.FileName, self.CurrentLineNumber) - self.__UndoToken() - return False - self.__UndoToken() - if not self.__IsToken("[Rule.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning("expected [Rule.] At Line ", self.FileName, self= .CurrentLineNumber) - - if not self.__SkipToToken("."): - raise Warning("expected '.' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - Arch =3D self.__SkippedChars.rstrip(".") - if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "AARCH= 64", "COMMON"): - raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.= CurrentLineNumber) - =20 - ModuleType =3D self.__GetModuleType() - =20 - TemplateName =3D "" - if self.__IsToken("."): - if not self.__GetNextWord(): - raise Warning("expected template name At Line ", self.File= Name, self.CurrentLineNumber) - TemplateName =3D self.__Token - =20 - if not self.__IsToken( "]"): - raise Warning("expected ']' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - RuleObj =3D self.__GetRuleFileStatements() - RuleObj.Arch =3D Arch.upper() - RuleObj.ModuleType =3D ModuleType - RuleObj.TemplateName =3D TemplateName - if TemplateName =3D=3D '' : - self.Profile.RuleDict['RULE' + \ - '.' + \ - Arch.upper() + \ - '.' + \ - ModuleType.upper() ] =3D RuleObj - else : - self.Profile.RuleDict['RULE' + \ - '.' + \ - Arch.upper() + \ - '.' + \ - ModuleType.upper() + \ - '.' + \ - TemplateName.upper() ] =3D RuleObj -# self.Profile.RuleList.append(rule) - return True - =20 - ## __GetModuleType() method - # - # Return the module type - # - # @param self The object pointer - # @retval string module type - # - def __GetModuleType(self): - =20 - if not self.__GetNextWord(): - raise Warning("expected Module type At Line ", self.FileName, = self.CurrentLineNumber) - if self.__Token.upper() not in ("SEC", "PEI_CORE", "PEIM", "DXE_CO= RE", \ - "DXE_DRIVER", "DXE_SAL_DRIVER", \ - "DXE_SMM_DRIVER", "DXE_RUNTIME_DRIVER", \ - "UEFI_DRIVER", "UEFI_APPLICATION", "USER_DEFI= NED", "DEFAULT", "BASE", \ - "SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC= _PEIM", "RELOCATABLE_PEIM", \ - "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_R= T_DRIVER", "APPLICATION", "ACPITABLE", "SMM_CORE", "MM_STANDALONE", "MM_COR= E_STANDALONE"): - raise Warning("Unknown Module type At line ", self.FileName, s= elf.CurrentLineNumber) - return self.__Token - =20 - ## __GetFileExtension() method - # - # Return the file extension - # - # @param self The object pointer - # @retval string file name extension - # - def __GetFileExtension(self): - if not self.__IsToken("."): - raise Warning("expected '.' At Line ", self.FileName, self= .CurrentLineNumber) - =20 - Ext =3D "" - if self.__GetNextToken(): - if FileExtensionPattern.match(self.__Token): - Ext =3D self.__Token =20 - return '.' + Ext =20 - else: - raise Warning("Unknown file extension At Line ", self.File= Name, self.CurrentLineNumber) - =20 - else: - raise Warning("expected file extension At Line ", self.FileNam= e, self.CurrentLineNumber) - =20 - ## __GetRuleFileStatement() method - # - # Get rule contents - # - # @param self The object pointer - # @retval Rule Rule object - # - def __GetRuleFileStatements(self): - =20 - if not self.__IsKeyword("FILE"): - raise Warning("expected FILE At Line ", self.FileName, self.Cu= rrentLineNumber) - =20 - if not self.__GetNextWord(): - raise Warning("expected FFS type At Line ", self.FileName, sel= f.CurrentLineNumber) - =20 - Type =3D self.__Token.strip().upper() - if Type not in ("RAW", "FREEFORM", "SEC", "PEI_CORE", "PEIM",\ - "PEI_DXE_COMBO", "DRIVER", "DXE_CORE", "APPLI= CATION", "FV_IMAGE", "SMM", "SMM_CORE", "MM_STANDALONE"): - raise Warning("Unknown FV type At line ", self.FileName, self.= CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - =20 - if not self.__IsKeyword("$(NAMED_GUID)"): - if not self.__GetNextWord(): - raise Warning("expected $(NAMED_GUID)", self.FileName, sel= f.CurrentLineNumber) - if self.__Token =3D=3D 'PCD': - if not self.__IsToken( "("): - raise Warning("expected '('", self.FileName, self.Curr= entLineNumber) - PcdPair =3D self.__GetNextPcdName() - if not self.__IsToken( ")"): - raise Warning("expected ')'", self.FileName, self.Curr= entLineNumber) - self.__Token =3D 'PCD('+PcdPair[1]+'.'+PcdPair[0]+')' - =20 - NameGuid =3D self.__Token - - KeepReloc =3D None - if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS= _RETAINED'): - if self.__FileCouldHaveRelocFlag(Type): - if self.__Token =3D=3D 'RELOCS_STRIPPED': - KeepReloc =3D False - else: - KeepReloc =3D True - else: - raise Warning("File type %s could not have reloc strip fla= g At Line %d" % (Type, self.CurrentLineNumber), self.FileName, self.Current= LineNumber) - =20 - KeyStringList =3D [] - if self.__GetNextToken(): - if TokenFindPattern.match(self.__Token): - KeyStringList.append(self.__Token) - if self.__IsToken(","): - while self.__GetNextToken(): - if not TokenFindPattern.match(self.__Token): - raise Warning("expected KeyString \"Target_Tag= _Arch\" At Line ", self.FileName, self.CurrentLineNumber) - KeyStringList.append(self.__Token) - - if not self.__IsToken(","): - break - =20 - else: - self.__UndoToken() - - =20 - Fixed =3D False - if self.__IsKeyword("Fixed", True): - Fixed =3D True - =20 - CheckSum =3D False - if self.__IsKeyword("CheckSum", True): - CheckSum =3D True - =20 - AlignValue =3D "" - if self.__GetAlignment(): - if self.__Token not in ("Auto", "8", "16", "32", "64", "128", = "512", "1K", "4K", "32K" ,"64K", "128K", - "256K", "512K", "1M", "2M", "4M", "8M"= , "16M"): - raise Warning("Incorrect alignment At Line ", self.FileNam= e, self.CurrentLineNumber) - AlignValue =3D self.__Token - - if self.__IsToken("{"): - # Complex file rule expected - Rule =3D RuleComplexFile.RuleComplexFile() - Rule.FvFileType =3D Type - Rule.NameGuid =3D NameGuid - Rule.Alignment =3D AlignValue - Rule.CheckSum =3D CheckSum - Rule.Fixed =3D Fixed - Rule.KeyStringList =3D KeyStringList - if KeepReloc is not None: - Rule.KeepReloc =3D KeepReloc - =20 - while True: - IsEncapsulate =3D self.__GetRuleEncapsulationSection(Rule) - IsLeaf =3D self.__GetEfiSection(Rule) - if not IsEncapsulate and not IsLeaf: - break - =20 - if not self.__IsToken("}"): - raise Warning("expected '}' At Line ", self.FileName, self= .CurrentLineNumber) - =20 - return Rule - =20 - elif self.__IsToken("|"): - # Ext rule expected - Ext =3D self.__GetFileExtension() - =20 - Rule =3D RuleSimpleFile.RuleSimpleFile() - - Rule.FvFileType =3D Type - Rule.NameGuid =3D NameGuid - Rule.Alignment =3D AlignValue - Rule.CheckSum =3D CheckSum - Rule.Fixed =3D Fixed - Rule.FileExtension =3D Ext - Rule.KeyStringList =3D KeyStringList - if KeepReloc is not None: - Rule.KeepReloc =3D KeepReloc - =20 - return Rule - =20 - else: - # Simple file rule expected - if not self.__GetNextWord(): - raise Warning("expected leaf section type At Line ", self.= FileName, self.CurrentLineNumber) - - SectionName =3D self.__Token - =20 - if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IM= AGE", "RAW", "DXE_DEPEX",\ - "UI", "PEI_DEPEX", "VERSION", "SUBTYPE= _GUID", "SMM_DEPEX"): - raise Warning("Unknown leaf section name '%s'" % SectionNa= me, self.FileName, self.CurrentLineNumber) - - - if self.__IsKeyword("Fixed", True): - Fixed =3D True =20 - =20 - if self.__IsKeyword("CheckSum", True): - CheckSum =3D True - =20 - if self.__GetAlignment(): - if self.__Token not in ("Auto", "8", "16", "32", "64", "12= 8", "512", "1K", "4K", "32K" ,"64K", "128K", - "256K", "512K", "1M", "2M", "4M", = "8M", "16M"): - raise Warning("Incorrect alignment At Line ", self.Fil= eName, self.CurrentLineNumber) - if self.__Token =3D=3D 'Auto' and (not SectionName =3D=3D = 'PE32') and (not SectionName =3D=3D 'TE'): - raise Warning("Auto alignment can only be used in PE32= or TE section ", self.FileName, self.CurrentLineNumber) - AlignValue =3D self.__Token - =20 - if not self.__GetNextToken(): - raise Warning("expected File name At Line ", self.FileName= , self.CurrentLineNumber) - =20 - Rule =3D RuleSimpleFile.RuleSimpleFile() - Rule.SectionType =3D SectionName - Rule.FvFileType =3D Type - Rule.NameGuid =3D NameGuid - Rule.Alignment =3D AlignValue - Rule.CheckSum =3D CheckSum - Rule.Fixed =3D Fixed - Rule.FileName =3D self.__Token - Rule.KeyStringList =3D KeyStringList - if KeepReloc is not None: - Rule.KeepReloc =3D KeepReloc - return Rule - =20 - ## __GetEfiSection() method - # - # Get section list for Rule - # - # @param self The object pointer - # @param Obj for whom section is got - # @retval True Successfully find section statement - # @retval False Not able to find section statement - # - def __GetEfiSection(self, Obj): - =20 - OldPos =3D self.GetFileBufferPos() - if not self.__GetNextWord(): - return False - SectionName =3D self.__Token - =20 - if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE"= , "RAW", "DXE_DEPEX",\ - "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_= DEPEX"): - self.__UndoToken() - return False - =20 - if SectionName =3D=3D "FV_IMAGE": - FvImageSectionObj =3D FvImageSection.FvImageSection() - if self.__IsKeyword("FV_IMAGE"): - pass - if self.__IsToken( "{"): - FvObj =3D Fv.FV() - self.__GetDefineStatements(FvObj) - self.__GetBlockStatement(FvObj) - self.__GetSetStatements(FvObj) - self.__GetFvAlignment(FvObj) - self.__GetFvAttributes(FvObj) - self.__GetAprioriSection(FvObj) - self.__GetAprioriSection(FvObj) - =20 - while True: - IsInf =3D self.__GetInfStatement(FvObj) - IsFile =3D self.__GetFileStatement(FvObj) - if not IsInf and not IsFile: - break - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, = self.CurrentLineNumber) - FvImageSectionObj.Fv =3D FvObj - FvImageSectionObj.FvName =3D None - =20 - else: - if not self.__IsKeyword("FV"): - raise Warning("expected 'FV' At Line ", self.FileName,= self.CurrentLineNumber) - FvImageSectionObj.FvFileType =3D self.__Token - =20 - if self.__GetAlignment(): - if self.__Token not in ("8", "16", "32", "64", "128", = "512", "1K", "4K", "32K" ,"64K", "128K", - "256K", "512K", "1M", "2M", "4= M", "8M", "16M"): - raise Warning("Incorrect alignment At Line ", self= .FileName, self.CurrentLineNumber) - FvImageSectionObj.Alignment =3D self.__Token - =20 - if self.__IsToken('|'): - FvImageSectionObj.FvFileExtension =3D self.__GetFileEx= tension() - elif self.__GetNextToken(): - if self.__Token not in ("}", "COMPAT16", "PE32", "PIC"= , "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\ - "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_= DEPEX"): - FvImageSectionObj.FvFileName =3D self.__Token - else: - self.__UndoToken() - else: - raise Warning("expected FV file name At Line ", self.F= ileName, self.CurrentLineNumber) - =20 - Obj.SectionList.append(FvImageSectionObj) - return True - =20 - EfiSectionObj =3D EfiSection.EfiSection() - EfiSectionObj.SectionType =3D SectionName - =20 - if not self.__GetNextToken(): - raise Warning("expected file type At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if self.__Token =3D=3D "STRING": - if not self.__RuleSectionCouldHaveString(EfiSectionObj.Section= Type): - raise Warning("%s section could NOT have string data At Li= ne %d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName= , self.CurrentLineNumber) - =20 - if not self.__IsToken('=3D'): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - =20 - if not self.__GetNextToken(): - raise Warning("expected Quoted String At Line ", self.File= Name, self.CurrentLineNumber) - =20 - if self.__GetStringData(): - EfiSectionObj.StringData =3D self.__Token - =20 - if self.__IsKeyword("BUILD_NUM"): - if not self.__RuleSectionCouldHaveBuildNum(EfiSectionObj.S= ectionType): - raise Warning("%s section could NOT have BUILD_NUM At = Line %d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileNa= me, self.CurrentLineNumber) - =20 - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName= , self.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected Build number At Line ", self.F= ileName, self.CurrentLineNumber) - EfiSectionObj.BuildNum =3D self.__Token - =20 - else: - EfiSectionObj.FileType =3D self.__Token - self.__CheckRuleSectionFileType(EfiSectionObj.SectionType, Efi= SectionObj.FileType) - =20 - if self.__IsKeyword("Optional"): - if not self.__RuleSectionCouldBeOptional(EfiSectionObj.Section= Type): - raise Warning("%s section could NOT be optional At Line %d= " % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, sel= f.CurrentLineNumber) - EfiSectionObj.Optional =3D True - =20 - if self.__IsKeyword("BUILD_NUM"): - if not self.__RuleSectionCouldHaveBuildNum(EfiSectionObj.S= ectionType): - raise Warning("%s section could NOT have BUILD_NUM At = Line %d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileNa= me, self.CurrentLineNumber) - =20 - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName= , self.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected Build number At Line ", self.F= ileName, self.CurrentLineNumber) - EfiSectionObj.BuildNum =3D self.__Token - =20 - if self.__GetAlignment(): - if self.__Token not in ("Auto", "8", "16", "32", "64", "128", = "512", "1K", "4K", "32K" ,"64K", "128K", - "256K", "512K", "1M", "2M", "4M", "8M"= , "16M"): - raise Warning("Incorrect alignment '%s'" % self.__Token, s= elf.FileName, self.CurrentLineNumber) - if self.__Token =3D=3D 'Auto' and (not SectionName =3D=3D 'PE3= 2') and (not SectionName =3D=3D 'TE'): - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) - EfiSectionObj.Alignment =3D self.__Token - =20 - if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS= _RETAINED'): - if self.__SectionCouldHaveRelocFlag(EfiSectionObj.SectionType)= : - if self.__Token =3D=3D 'RELOCS_STRIPPED': - EfiSectionObj.KeepReloc =3D False - else: - EfiSectionObj.KeepReloc =3D True - if Obj.KeepReloc is not None and Obj.KeepReloc !=3D EfiSec= tionObj.KeepReloc: - raise Warning("Section type %s has reloc strip flag co= nflict with Rule At Line %d" % (EfiSectionObj.SectionType, self.CurrentLine= Number), self.FileName, self.CurrentLineNumber) - else: - raise Warning("Section type %s could not have reloc strip = flag At Line %d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), sel= f.FileName, self.CurrentLineNumber) - =20 - =20 - if self.__IsToken('|'): - EfiSectionObj.FileExtension =3D self.__GetFileExtension() - elif self.__GetNextToken(): - if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE", = "FV_IMAGE", "RAW", "DXE_DEPEX",\ - "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"): - =20 - if self.__Token.startswith('PCD'): - self.__UndoToken() - self.__GetNextWord() - =20 - if self.__Token =3D=3D 'PCD': - if not self.__IsToken( "("): - raise Warning("expected '('", self.FileName, s= elf.CurrentLineNumber) - PcdPair =3D self.__GetNextPcdName() - if not self.__IsToken( ")"): - raise Warning("expected ')'", self.FileName, s= elf.CurrentLineNumber) - self.__Token =3D 'PCD('+PcdPair[1]+'.'+PcdPair[0]+= ')' - =20 - EfiSectionObj.FileName =3D self.__Token =20 - =20 - else: - self.__UndoToken() - else: - raise Warning("expected section file name At Line ", self.File= Name, self.CurrentLineNumber) - =20 - Obj.SectionList.append(EfiSectionObj) - return True - =20 - ## __RuleSectionCouldBeOptional() method - # - # Get whether a section could be optional - # - # @param SectionType The section type to check - # @retval True section could be optional - # @retval False section never optional - # - @staticmethod - def __RuleSectionCouldBeOptional(SectionType): - if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW= ", "SMM_DEPEX"): - return True - else: - return False - =20 - ## __RuleSectionCouldHaveBuildNum() method - # - # Get whether a section could have build number information - # - # @param SectionType The section type to check - # @retval True section could have build number information - # @retval False section never have build number information - # - @staticmethod - def __RuleSectionCouldHaveBuildNum(SectionType): - if SectionType in ("VERSION"): - return True - else: - return False - =20 - ## __RuleSectionCouldHaveString() method - # - # Get whether a section could have string - # - # @param SectionType The section type to check - # @retval True section could have string - # @retval False section never have string - # - @staticmethod - def __RuleSectionCouldHaveString(SectionType): - if SectionType in ("UI", "VERSION"): - return True - else: - return False - =20 - ## __CheckRuleSectionFileType() method - # - # Get whether a section matches a file type - # - # @param self The object pointer - # @param SectionType The section type to check - # @param FileType The file type to check - # - def __CheckRuleSectionFileType(self, SectionType, FileType): - if SectionType =3D=3D "COMPAT16": - if FileType not in ("COMPAT16", "SEC_COMPAT16"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "PE32": - if FileType not in ("PE32", "SEC_PE32"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "PIC": - if FileType not in ("PIC", "PIC"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "TE": - if FileType not in ("TE", "SEC_TE"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "RAW": - if FileType not in ("BIN", "SEC_BIN", "RAW", "ASL", "ACPI"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "DXE_DEPEX" or SectionType =3D=3D "SMM_DEP= EX": - if FileType not in ("DXE_DEPEX", "SEC_DXE_DEPEX", "SMM_DEPEX")= : - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "UI": - if FileType not in ("UI", "SEC_UI"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "VERSION": - if FileType not in ("VERSION", "SEC_VERSION"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "PEI_DEPEX": - if FileType not in ("PEI_DEPEX", "SEC_PEI_DEPEX"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "GUID": - if FileType not in ("PE32", "SEC_GUID"): - raise Warning("Incorrect section file type At Line ", self= .FileName, self.CurrentLineNumber) =20 - =20 - ## __GetRuleEncapsulationSection() method - # - # Get encapsulation section for Rule - # - # @param self The object pointer - # @param Rule for whom section is got - # @retval True Successfully find section statement - # @retval False Not able to find section statement - # - def __GetRuleEncapsulationSection(self, Rule): - - if self.__IsKeyword( "COMPRESS"): - Type =3D "PI_STD" - if self.__IsKeyword("PI_STD") or self.__IsKeyword("PI_NONE"): - Type =3D self.__Token - =20 - if not self.__IsToken("{"): - raise Warning("expected '{' At Line ", self.FileName, self= .CurrentLineNumber) - - CompressSectionObj =3D CompressSection.CompressSection() - =20 - CompressSectionObj.CompType =3D Type - # Recursive sections... - while True: - IsEncapsulate =3D self.__GetRuleEncapsulationSection(Compr= essSectionObj) - IsLeaf =3D self.__GetEfiSection(CompressSectionObj) - if not IsEncapsulate and not IsLeaf: - break - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, self= .CurrentLineNumber) - Rule.SectionList.append(CompressSectionObj) - =20 - return True - - elif self.__IsKeyword( "GUIDED"): - GuidValue =3D None - if self.__GetNextGuid(): - GuidValue =3D self.__Token - =20 - if self.__IsKeyword( "$(NAMED_GUID)"): - GuidValue =3D self.__Token - =20 - AttribDict =3D self.__GetGuidAttrib() - =20 - if not self.__IsToken("{"): - raise Warning("expected '{' At Line ", self.FileName, self= .CurrentLineNumber) - GuidSectionObj =3D GuidSection.GuidSection() - GuidSectionObj.NameGuid =3D GuidValue - GuidSectionObj.SectionType =3D "GUIDED" - GuidSectionObj.ProcessRequired =3D AttribDict["PROCESSING_REQU= IRED"] - GuidSectionObj.AuthStatusValid =3D AttribDict["AUTH_STATUS_VAL= ID"] - =20 - # Efi sections... - while True: - IsEncapsulate =3D self.__GetRuleEncapsulationSection(GuidS= ectionObj) - IsLeaf =3D self.__GetEfiSection(GuidSectionObj) - if not IsEncapsulate and not IsLeaf: - break - =20 - if not self.__IsToken( "}"): - raise Warning("expected '}' At Line ", self.FileName, self= .CurrentLineNumber) - Rule.SectionList.append(GuidSectionObj) - - return True - - return False - =20 - ## __GetVtf() method - # - # Get VTF section contents and store its data into VTF list of self.= Profile - # - # @param self The object pointer - # @retval True Successfully find a VTF - # @retval False Not able to find a VTF - # - def __GetVtf(self): - =20 - if not self.__GetNextToken(): - return False - - S =3D self.__Token.upper() - if S.startswith("[") and not S.startswith("[VTF."): - if not S.startswith("[RULE.") and not S.startswith("[OPTIONROM= ."): - raise Warning("Unknown section or section appear sequence = error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Ru= le.], [OptionRom.])", self.FileName, self.CurrentLineNumber) - self.__UndoToken() - return False - - self.__UndoToken() - if not self.__IsToken("[VTF.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - print 'Parsing String: %s in File %s, At line: %d, Offset With= in Line: %d' \ - % (self.Profile.FileLinesList[self.CurrentLineNumber -= 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning("expected [VTF.] At Line ", self.FileName, self.= CurrentLineNumber) - - if not self.__SkipToToken("."): - raise Warning("expected '.' At Line ", self.FileName, self.Cur= rentLineNumber) - - Arch =3D self.__SkippedChars.rstrip(".").upper() - if Arch not in ("IA32", "X64", "IPF", "ARM", "AARCH64"): - raise Warning("Unknown Arch At line ", self.FileName, self.Cur= rentLineNumber) - - if not self.__GetNextWord(): - raise Warning("expected VTF name At Line ", self.FileName, sel= f.CurrentLineNumber) - Name =3D self.__Token.upper() - - VtfObj =3D Vtf.Vtf() - VtfObj.UiName =3D Name - VtfObj.KeyArch =3D Arch - =20 - if self.__IsToken(","): - if not self.__GetNextWord(): - raise Warning("expected Arch list At Line ", self.FileName= , self.CurrentLineNumber) - if self.__Token.upper() not in ("IA32", "X64", "IPF", "ARM", "= AARCH64"): - raise Warning("Unknown Arch At line ", self.FileName, self= .CurrentLineNumber) - VtfObj.ArchList =3D self.__Token.upper() - - if not self.__IsToken( "]"): - raise Warning("expected ']' At Line ", self.FileName, self.Cur= rentLineNumber) - =20 - if self.__IsKeyword("IA32_RST_BIN"): - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, se= lf.CurrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected Reset file At Line ", self.FileNam= e, self.CurrentLineNumber) - - VtfObj.ResetBin =3D self.__Token - =20 - while self.__GetComponentStatement(VtfObj): - pass - =20 - self.Profile.VtfList.append(VtfObj) - return True - =20 - ## __GetComponentStatement() method - # - # Get components in VTF - # - # @param self The object pointer - # @param VtfObj for whom component is got - # @retval True Successfully find a component - # @retval False Not able to find a component - # - def __GetComponentStatement(self, VtfObj): - =20 - if not self.__IsKeyword("COMP_NAME"): - return False - =20 - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if not self.__GetNextWord(): - raise Warning("expected Component Name At Line ", self.FileNam= e, self.CurrentLineNumber) - - CompStatementObj =3D ComponentStatement.ComponentStatement() - CompStatementObj.CompName =3D self.__Token - =20 - if not self.__IsKeyword("COMP_LOC"): - raise Warning("expected COMP_LOC At Line ", self.FileName, sel= f.CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - CompStatementObj.CompLoc =3D "" - if self.__GetNextWord(): - CompStatementObj.CompLoc =3D self.__Token - if self.__IsToken('|'): - if not self.__GetNextWord(): - raise Warning("Expected Region Name At Line ", self.Fi= leName, self.CurrentLineNumber) - =20 - if self.__Token not in ("F", "N", "S"): #, "H", "L", "P= H", "PL"): not support - raise Warning("Unknown location type At line ", self.F= ileName, self.CurrentLineNumber) - =20 - CompStatementObj.FilePos =3D self.__Token - else: - self.CurrentLineNumber +=3D 1 - self.CurrentOffsetWithinLine =3D 0 - =20 - if not self.__IsKeyword("COMP_TYPE"): - raise Warning("expected COMP_TYPE At Line ", self.FileName, se= lf.CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected Component type At Line ", self.FileNam= e, self.CurrentLineNumber) - if self.__Token not in ("FIT", "PAL_B", "PAL_A", "OEM"): - if not self.__Token.startswith("0x") or len(self.__Token) < 3 = or len(self.__Token) > 4 or \ - not self.__Token[2] in string.hexdigits or not self.__Toke= n[-1] in string.hexdigits: - raise Warning("Unknown location type At line ", self.FileN= ame, self.CurrentLineNumber) - CompStatementObj.CompType =3D self.__Token - =20 - if not self.__IsKeyword("COMP_VER"): - raise Warning("expected COMP_VER At Line ", self.FileName, sel= f.CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected Component version At Line ", self.File= Name, self.CurrentLineNumber) - - Pattern =3D re.compile('-$|[0-9]{0,1}[0-9]{1}\.[0-9]{0,1}[0-9]{1}'= ) - if Pattern.match(self.__Token) is None: - raise Warning("Unknown version format At line ", self.FileName= , self.CurrentLineNumber) - CompStatementObj.CompVer =3D self.__Token - =20 - if not self.__IsKeyword("COMP_CS"): - raise Warning("expected COMP_CS At Line ", self.FileName, self= .CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected Component CS At Line ", self.FileName,= self.CurrentLineNumber) - if self.__Token not in ("1", "0"): - raise Warning("Unknown Component CS At line ", self.FileName,= self.CurrentLineNumber) - CompStatementObj.CompCs =3D self.__Token - =20 - =20 - if not self.__IsKeyword("COMP_BIN"): - raise Warning("expected COMP_BIN At Line ", self.FileName, sel= f.CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected Component file At Line ", self.FileNam= e, self.CurrentLineNumber) - - CompStatementObj.CompBin =3D self.__Token - =20 - if not self.__IsKeyword("COMP_SYM"): - raise Warning("expected COMP_SYM At Line ", self.FileName, sel= f.CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if not self.__GetNextToken(): - raise Warning("expected Component symbol file At Line ", self.= FileName, self.CurrentLineNumber) - - CompStatementObj.CompSym =3D self.__Token - =20 - if not self.__IsKeyword("COMP_SIZE"): - raise Warning("expected COMP_SIZE At Line ", self.FileName, se= lf.CurrentLineNumber) - - if not self.__IsToken("=3D"): - raise Warning("expected '=3D' At Line ", self.FileName, self.C= urrentLineNumber) - - if self.__IsToken("-"): - CompStatementObj.CompSize =3D self.__Token - elif self.__GetNextDecimalNumber(): - CompStatementObj.CompSize =3D self.__Token - elif self.__GetNextHexNumber(): - CompStatementObj.CompSize =3D self.__Token - else: - raise Warning("Unknown size At line ", self.FileName, self.Cur= rentLineNumber) - =20 - VtfObj.ComponentStatementList.append(CompStatementObj) - return True - =20 - ## __GetFvInFd() method - # - # Get FV list contained in FD - # - # @param self The object pointer - # @param FdName FD name - # @retval FvList list of FV in FD - # - def __GetFvInFd (self, FdName): - =20 - FvList =3D [] - if FdName.upper() in self.Profile.FdDict.keys(): - FdObj =3D self.Profile.FdDict[FdName.upper()] - for elementRegion in FdObj.RegionList: - if elementRegion.RegionType =3D=3D 'FV': - for elementRegionData in elementRegion.RegionDataList: - if elementRegionData is not None and elementRegion= Data.upper() not in FvList: - FvList.append(elementRegionData.upper()) - return FvList - =20 - ## __GetReferencedFdFvTuple() method - # - # Get FD and FV list referenced by a FFS file - # - # @param self The object pointer - # @param FfsFile contains sections to be searched - # @param RefFdList referenced FD by section - # @param RefFvList referenced FV by section - # - def __GetReferencedFdFvTuple(self, FvObj, RefFdList =3D [], RefFvList = =3D []): - =20 - for FfsObj in FvObj.FfsList: - if isinstance(FfsObj, FfsFileStatement.FileStatement): - if FfsObj.FvName is not None and FfsObj.FvName.upper() not= in RefFvList: - RefFvList.append(FfsObj.FvName.upper()) - elif FfsObj.FdName is not None and FfsObj.FdName.upper() n= ot in RefFdList: - RefFdList.append(FfsObj.FdName.upper()) - else: - self.__GetReferencedFdFvTupleFromSection(FfsObj, RefFd= List, RefFvList) =20 - =20 - ## __GetReferencedFdFvTupleFromSection() method - # - # Get FD and FV list referenced by a FFS section - # - # @param self The object pointer - # @param FfsFile contains sections to be searched - # @param FdList referenced FD by section - # @param FvList referenced FV by section - # - def __GetReferencedFdFvTupleFromSection(self, FfsFile, FdList =3D [], = FvList =3D []): - =20 - SectionStack =3D [] - SectionStack.extend(FfsFile.SectionList) - while SectionStack !=3D []: - SectionObj =3D SectionStack.pop() - if isinstance(SectionObj, FvImageSection.FvImageSection): - if SectionObj.FvName is not None and SectionObj.FvName.upp= er() not in FvList: - FvList.append(SectionObj.FvName.upper()) - if SectionObj.Fv is not None and SectionObj.Fv.UiFvName is= not None and SectionObj.Fv.UiFvName.upper() not in FvList: - FvList.append(SectionObj.Fv.UiFvName.upper()) - self.__GetReferencedFdFvTuple(SectionObj.Fv, FdList, F= vList) - =20 - if isinstance(SectionObj, CompressSection.CompressSection) or = isinstance(SectionObj, GuidSection.GuidSection): - SectionStack.extend(SectionObj.SectionList) - =20 - ## CycleReferenceCheck() method - # - # Check whether cycle reference exists in FDF - # - # @param self The object pointer - # @retval True cycle reference exists - # @retval False Not exists cycle reference - # - def CycleReferenceCheck(self): - =20 - CycleRefExists =3D False - =20 - try: - for FvName in self.Profile.FvDict.keys(): - LogStr =3D "Cycle Reference Checking for FV: %s\n" % FvNam= e - RefFvStack =3D [] - RefFvStack.append(FvName) - FdAnalyzedList =3D [] - =20 - while RefFvStack !=3D []: - FvNameFromStack =3D RefFvStack.pop() - if FvNameFromStack.upper() in self.Profile.FvDict.keys= (): - FvObj =3D self.Profile.FvDict[FvNameFromStack.uppe= r()] - else: - continue - =20 - RefFdList =3D [] - RefFvList =3D [] - self.__GetReferencedFdFvTuple(FvObj, RefFdList, RefFvL= ist) - =20 - for RefFdName in RefFdList: - if RefFdName in FdAnalyzedList: - continue - =20 - LogStr +=3D "FD %s is referenced by FV %s\n" % (Re= fFdName, FvNameFromStack)=20 - FvInFdList =3D self.__GetFvInFd(RefFdName) - if FvInFdList !=3D []: - LogStr +=3D "FD %s contains FV: " % RefFdName - for FvObj in FvInFdList: - LogStr +=3D FvObj - LogStr +=3D ' \n' - if FvObj not in RefFvStack: - RefFvStack.append(FvObj) - =20 - if FvName in RefFvStack: - CycleRefExists =3D True - raise Warning(LogStr) - FdAnalyzedList.append(RefFdName) - =20 - for RefFvName in RefFvList: - LogStr +=3D "FV %s is referenced by FV %s\n" % (Re= fFvName, FvNameFromStack) - if RefFvName not in RefFvStack: - RefFvStack.append(RefFvName) - =20 - if FvName in RefFvStack: - CycleRefExists =3D True - raise Warning(LogStr) - =20 - except Warning: - print LogStr - =20 - finally: - return CycleRefExists - =20 -if __name__ =3D=3D "__main__": - import sys - try: - test_file =3D sys.argv[1] - except IndexError, v: - print "Usage: %s filename" % sys.argv[0] - sys.exit(1) - - parser =3D FdfParser(test_file) - try: - parser.ParseFile() - parser.CycleReferenceCheck() - except Warning, X: - print X.message - else: - print "Success!" - diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 9b7e898570..fd38b3d00d 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -59,11 +59,10 @@ from Common.MultipleWorkspace import MultipleWorkspace = as mws import Common.LongFilePathOs as os from Common.LongFilePathSupport import OpenLongFilePath as open from Capsule import EFI_CERT_TYPE_PKCS7_GUID from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID from Common.RangeExpression import RangeExpression -from Common.FdfParserLite import FileExtensionPattern,TokenFindPattern =20 ##define T_CHAR_SPACE ' ' ##define T_CHAR_NULL '\0' ##define T_CHAR_CR '\r' ##define T_CHAR_TAB '\t' @@ -83,10 +82,12 @@ SEPERATOR_TUPLE =3D ('=3D', '|', ',', '{', '}') =20 RegionSizePattern =3D re.compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|= \s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*") RegionSizeGuidPattern =3D re.compile("\s*(?P\w+\.\w+)\s*\|\s*(?P\w+\.\w+)\s*") RegionOffsetPcdPattern =3D re.compile("\s*(?P\w+\.\w+)\s*$") ShortcutPcdPattern =3D re.compile("\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-f= A-F0-9]+)\s*\|\s*(?P\w+\.\w+)\s*") +FileExtensionPattern =3D re.compile(r'([a-zA-Z][a-zA-Z0-9]*)') +TokenFindPattern =3D re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-= Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)') =20 AllIncludeFileList =3D [] =20 # Get the closest parent def GetParentAtLine (Line): diff --git a/BaseTools/Source/Python/Makefile b/BaseTools/Source/Python/Mak= efile index e1451e7fae..0b1721ca63 100644 --- a/BaseTools/Source/Python/Makefile +++ b/BaseTools/Source/Python/Makefile @@ -42,11 +42,10 @@ COMMON_PYTHON=3D$(BASE_TOOLS_PATH)\Source\Python\Common= \BuildToolError.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\DscClassObject.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\EdkIIWorkspace.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\EdkLogger.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\Expression.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\FdfClassObject.py \ - $(BASE_TOOLS_PATH)\Source\Python\Common\FdfParserLite.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\GlobalData.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\Identification.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\InfClassObject.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\LongFilePathOs.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\LongFilePathOsPath.p= y \ --=20 2.12.2.windows.2