diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2016-04-21 14:50:30 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-13 09:32:35 +0800 |
commit | 1c691d30195e1b96f78b2a9f3d89288005ab336d (patch) | |
tree | 8142301199beb9dd997556fc6f37999ee542c7d5 /BaseTools | |
parent | 5f2d72936be6f8d426a1443fcce8de21a16a2ae5 (diff) | |
download | edk2-1c691d30195e1b96f78b2a9f3d89288005ab336d.tar.gz edk2-1c691d30195e1b96f78b2a9f3d89288005ab336d.tar.bz2 edk2-1c691d30195e1b96f78b2a9f3d89288005ab336d.zip |
BaseTools: Update FMP Capsule support to follow FDF spec
Current the FMP Capsule feature is supported, but its format has a little
different with FDF spec. so this patch 1) Align the FMP Capsule with FDF
spec. 2) fix some style issue, eg: Tab. 3) Add a SectionParser function to
check the section header info since this method is used in 7 places.
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit df81077f77f91b43f32f70e06950b86e20f711da)
Diffstat (limited to 'BaseTools')
-rw-r--r-- | BaseTools/Source/Python/GenFds/FdfParser.py | 60 |
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):
|