summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/GenFds
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py60
1 files changed, 34 insertions, 26 deletions
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 28af09b982..72fb3dc56e 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -55,7 +55,6 @@ from Common.String import ReplaceMacro
from Common.Misc import tdict
-import re
import Common.LongFilePathOs as os
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -106,7 +105,7 @@ def GetRealFileLine (File, Line):
if Profile.IsLineInFile(Line):
return Profile.GetLineInFile(Line)
elif Line >= Profile.InsertStartLineNumber and Profile.Level == 1:
- InsertedLines += Profile.GetTotalLines()
+ InsertedLines += Profile.GetTotalLines()
return (File, Line - InsertedLines)
@@ -181,7 +180,7 @@ class IncludeFileProfile :
TotalLines = self.InsertAdjust + len(self.FileLinesList)
for Profile in self.IncludeFileList:
- TotalLines += Profile.GetTotalLines()
+ TotalLines += Profile.GetTotalLines()
return TotalLines
@@ -1398,6 +1397,20 @@ class FdfParser:
% (FileLineTuple[1], self.CurrentOffsetWithinLine + 1, self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :].rstrip('\n').rstrip('\r'))
raise
+ ## SectionParser() method
+ #
+ # Parse the file section info
+ # Exception will be raised if syntax error found
+ #
+ # @param self The object pointer
+ # @param section The section string
+
+ def SectionParser(self, section):
+ S = section.upper()
+ if not S.startswith("[DEFINES") and not S.startswith("[FD.") and not S.startswith("[FV.") and not S.startswith("[CAPSULE.") \
+ and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM.") and not S.startswith('[FMPPAYLOAD.'):
+ raise Warning("Unknown section or section appear sequence error (The correct sequence should be [DEFINES], [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.], [FMPPAYLOAD.])", self.FileName, self.CurrentLineNumber)
+
## __GetDefines() method
#
# Get Defines section contents and store its data into AllMacrosList
@@ -1413,9 +1426,7 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[DEFINES"):
- if not S.startswith("[FD.") and not S.startswith("[FV.") and not 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.SectionParser(S)
self.__UndoToken()
return False
@@ -2108,9 +2119,7 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[FV."):
- if not S.startswith('[FMPPAYLOAD.') and not 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 [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -3151,9 +3160,8 @@ class FdfParser:
if not self.__GetNextToken():
return False
S = self.__Token.upper()
- if not S.startswith("[FMPPAYLOAD."):
- if not 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 [FD.], [FV.], [FmpPayload.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ if S.startswith("[") and not S.startswith("[FMPPAYLOAD."):
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -3223,8 +3231,7 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[CAPSULE."):
- if 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 [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -3394,18 +3401,19 @@ class FdfParser:
return True
def __GetFmpStatement(self, CapsuleObj):
- if not self.__IsKeyword("FMP"):
- return False
+ if not self.__IsKeyword("FMP_PAYLOAD"):
+ if not self.__IsKeyword("FMP"):
+ return False
- if not self.__IsKeyword("PAYLOAD"):
- self.__UndoToken()
- return False
+ if not self.__IsKeyword("PAYLOAD"):
+ self.__UndoToken()
+ return False
if not self.__IsToken("="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
- raise Warning("expected payload name after FMP PAYLOAD =", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected payload name after FMP_PAYLOAD =", self.FileName, self.CurrentLineNumber)
Payload = self.__Token.upper()
if Payload not in self.Profile.FmpPayloadDict:
raise Warning("This FMP Payload does not exist: %s" % self.__Token, self.FileName, self.CurrentLineNumber)
@@ -3507,8 +3515,7 @@ class FdfParser:
S = 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.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
self.__UndoToken()
@@ -3586,7 +3593,7 @@ class FdfParser:
#
def __GetFileExtension(self):
if not self.__IsToken("."):
- raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
Ext = ""
if self.__GetNextToken():
@@ -4084,8 +4091,7 @@ class FdfParser:
S = 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.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -4291,7 +4297,9 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[OPTIONROM."):
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
+ self.__UndoToken()
+ return False
self.__UndoToken()
if not self.__IsToken("[OptionRom.", True):