|
From: <lg...@us...> - 2010-07-19 03:16:16
|
Revision: 1995
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=1995&view=rev
Author: lgao4
Date: 2010-07-19 03:16:10 +0000 (Mon, 19 Jul 2010)
Log Message:
-----------
Don't check the case sensitive file path that uses MACRO.
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2010-07-15 04:39:33 UTC (rev 1994)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2010-07-19 03:16:10 UTC (rev 1995)
@@ -2149,10 +2149,11 @@
if not self.__GetNextToken():
raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber)
ffsInf.InfFileName = self.__Token
- #do case sensitive check for file path
- ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
- if ErrorCode != 0:
- EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
+ if ffsInf.InfFileName.replace('$(WORKSPACE)', '').find('$') == -1:
+ #do case sensitive check for file path
+ ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
+ if ErrorCode != 0:
+ EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
if not ffsInf.InfFileName in self.Profile.InfList:
self.Profile.InfList.append(ffsInf.InfFileName)
@@ -2360,10 +2361,11 @@
self.__GetSectionData( FfsFileObj, MacroDict)
else:
FfsFileObj.FileName = self.__Token
- #do case sensitive check for file path
- ErrorCode, ErrorInfo = PathClass(NormPath(FfsFileObj.FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
- if ErrorCode != 0:
- EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
+ if FfsFileObj.FileName.replace('$(WORKSPACE)', '').find('$') == -1:
+ #do case sensitive check for file path
+ ErrorCode, ErrorInfo = PathClass(NormPath(FfsFileObj.FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
+ if ErrorCode != 0:
+ EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
if not self.__IsToken( "}"):
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
@@ -2609,10 +2611,11 @@
if not self.__GetNextToken():
raise Warning("expected section file path", self.FileName, self.CurrentLineNumber)
DataSectionObj.SectFileName = self.__Token
- #do case sensitive check for file path
- ErrorCode, ErrorInfo = PathClass(NormPath(DataSectionObj.SectFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
- if ErrorCode != 0:
- EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
+ if DataSectionObj.SectFileName.replace('$(WORKSPACE)', '').find('$') == -1:
+ #do case sensitive check for file path
+ ErrorCode, ErrorInfo = PathClass(NormPath(DataSectionObj.SectFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
+ if ErrorCode != 0:
+ EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
else:
if not self.__GetCglSection(DataSectionObj):
return False
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lg...@us...> - 2010-07-26 09:33:55
|
Revision: 1998
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=1998&view=rev
Author: lgao4
Date: 2010-07-26 09:33:47 +0000 (Mon, 26 Jul 2010)
Log Message:
-----------
Check file path specified in VFT section and OptionRom section.
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2010-07-20 08:08:05 UTC (rev 1997)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2010-07-26 09:33:47 UTC (rev 1998)
@@ -3532,6 +3532,11 @@
raise Warning("expected Reset file", self.FileName, self.CurrentLineNumber)
VtfObj.ResetBin = self.__Token
+ if VtfObj.ResetBin.replace('$(WORKSPACE)', '').find('$') == -1:
+ #check for file path
+ ErrorCode, ErrorInfo = PathClass(NormPath(VtfObj.ResetBin), GenFdsGlobalVariable.WorkSpaceDir).Validate()
+ if ErrorCode != 0:
+ EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
while self.__GetComponentStatement(VtfObj):
pass
@@ -3634,6 +3639,11 @@
raise Warning("expected Component file", self.FileName, self.CurrentLineNumber)
CompStatementObj.CompBin = self.__Token
+ if CompStatementObj.CompBin != '-' and CompStatementObj.CompBin.replace('$(WORKSPACE)', '').find('$') == -1:
+ #check for file path
+ ErrorCode, ErrorInfo = PathClass(NormPath(CompStatementObj.CompBin), GenFdsGlobalVariable.WorkSpaceDir).Validate()
+ if ErrorCode != 0:
+ EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
if not self.__IsKeyword("COMP_SYM"):
raise Warning("expected COMP_SYM", self.FileName, self.CurrentLineNumber)
@@ -3645,6 +3655,11 @@
raise Warning("expected Component symbol file", self.FileName, self.CurrentLineNumber)
CompStatementObj.CompSym = self.__Token
+ if CompStatementObj.CompSym != '-' and CompStatementObj.CompSym.replace('$(WORKSPACE)', '').find('$') == -1:
+ #check for file path
+ ErrorCode, ErrorInfo = PathClass(NormPath(CompStatementObj.CompSym), GenFdsGlobalVariable.WorkSpaceDir).Validate()
+ if ErrorCode != 0:
+ EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
if not self.__IsKeyword("COMP_SIZE"):
raise Warning("expected COMP_SIZE", self.FileName, self.CurrentLineNumber)
@@ -3722,6 +3737,11 @@
if not self.__GetNextToken():
raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber)
ffsInf.InfFileName = self.__Token
+ if ffsInf.InfFileName.replace('$(WORKSPACE)', '').find('$') == -1:
+ #check for file path
+ ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
+ if ErrorCode != 0:
+ EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
if not ffsInf.InfFileName in self.Profile.InfList:
self.Profile.InfList.append(ffsInf.InfFileName)
@@ -3814,6 +3834,11 @@
if not self.__GetNextToken():
raise Warning("expected File path", self.FileName, self.CurrentLineNumber)
FfsFileObj.FileName = self.__Token
+ if FfsFileObj.FileName.replace('$(WORKSPACE)', '').find('$') == -1:
+ #check for file path
+ ErrorCode, ErrorInfo = PathClass(NormPath(FfsFileObj.FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
+ if ErrorCode != 0:
+ EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
if FfsFileObj.FileType == 'EFI':
self.__GetOptRomOverrides(FfsFileObj)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <qh...@us...> - 2010-08-30 02:00:35
|
Revision: 2030
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2030&view=rev
Author: qhuang8
Date: 2010-08-30 02:00:29 +0000 (Mon, 30 Aug 2010)
Log Message:
-----------
Fix the issue that "macros defined in included file do not work in FDF file"
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2010-08-30 01:29:08 UTC (rev 2029)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2010-08-30 02:00:29 UTC (rev 2030)
@@ -751,7 +751,7 @@
raise Warning("Value %s is not a number", self.FileName, Line)
for Profile in AllMacroList:
- if Profile.FileName == FileLineTuple[0] and Profile.MacroName == Name and Profile.DefinedAtLine <= FileLineTuple[1]:
+ if Profile.MacroName == Name and Profile.DefinedAtLine <= FileLineTuple[1]:
if Op == None:
if Value == 'Bool' and Profile.MacroValue == None or Profile.MacroValue.upper() == 'FALSE':
return False
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2010-10-15 02:06:22
|
Revision: 2071
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2071&view=rev
Author: jsu1
Date: 2010-10-15 02:06:16 +0000 (Fri, 15 Oct 2010)
Log Message:
-----------
support the <SetStatement> (<SetStatements> ::= ?\226?\128?\156SET?\226?\128?\157 <PcdName> ?\226?\128?\156=?\226?\128?\157 [<VALUE>] <EOL>) in define section of fdf file.
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2010-10-13 07:07:09 UTC (rev 2070)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2010-10-15 02:06:16 UTC (rev 2071)
@@ -565,9 +565,9 @@
self.Rewind()
- ## PreprocessIncludeFile() method
+ ## PreprocessConditionalStatement() method
#
- # Preprocess file contents, replace !include statements with file contents.
+ # Preprocess conditional statement.
# In the end, rewind the file buffer pointer to the beginning
#
# @param self The object pointer
@@ -1264,6 +1264,12 @@
raise Warning("expected ']'", self.FileName, self.CurrentLineNumber)
while self.__GetNextWord():
+ # handle the SET statement
+ if self.__Token == 'SET':
+ self.__UndoToken()
+ self.__GetSetStatement(None)
+ continue
+
Macro = self.__Token
if not self.__IsToken("="):
@@ -1508,7 +1514,7 @@
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
if not self.__GetNextHexNumber() and not self.__GetNextDecimalNumber():
- raise Warning("expected Hex block size", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected Hex or Integer block size", self.FileName, self.CurrentLineNumber)
BlockSize = self.__Token
BlockSizePcd = None
@@ -1609,7 +1615,8 @@
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
Value += self.__SkippedChars
- Obj.SetVarDict[PcdPair] = Value
+ if Obj:
+ Obj.SetVarDict[PcdPair] = Value
self.Profile.PcdDict[PcdPair] = Value
return True
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gi...@us...> - 2011-08-05 01:46:29
|
Revision: 2227
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2227&view=rev
Author: gikidy
Date: 2011-08-05 01:46:23 +0000 (Fri, 05 Aug 2011)
Log Message:
-----------
Fix a bug for Genfds doesn't parse the correct macro value in conditional statement.
Signed-off-by: gikidy
Reviewed-by: lhauch
Reviewed-by: lgao4
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-07-19 09:23:29 UTC (rev 2226)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-08-05 01:46:23 UTC (rev 2227)
@@ -327,10 +327,10 @@
#
def __GetOneChar(self):
if self.CurrentOffsetWithinLine == len(self.Profile.FileLinesList[self.CurrentLineNumber - 1]) - 1:
- self.CurrentLineNumber += 1
- self.CurrentOffsetWithinLine = 0
+ self.CurrentLineNumber += 1
+ self.CurrentOffsetWithinLine = 0
else:
- self.CurrentOffsetWithinLine += 1
+ self.CurrentOffsetWithinLine += 1
## __CurrentChar() method
#
@@ -574,7 +574,16 @@
self.Profile.FileLinesList[IncludeLine - 1] = ''.join(TempList)
self.Rewind()
-
+
+ def __GetIfListCurrentItemStat(self, IfList):
+ if len(IfList) == 0:
+ return True
+
+ for Item in IfList:
+ if Item[1] == False:
+ return False
+
+ return True
## PreprocessConditionalStatement() method
#
@@ -589,28 +598,29 @@
RegionLayoutLine = 0
while self.__GetNextToken():
if self.__Token == 'DEFINE':
- DefineLine = self.CurrentLineNumber - 1
- DefineOffset = self.CurrentOffsetWithinLine - len('DEFINE')
- if not self.__GetNextToken():
- raise Warning("expected Macro name", self.FileName, self.CurrentLineNumber)
- Macro = self.__Token
- if not self.__IsToken( "="):
- raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
-
- if not self.__GetNextToken():
- raise Warning("expected value", self.FileName, self.CurrentLineNumber)
-
- if self.__GetStringData():
- pass
- Value = self.__Token
- if not Macro in InputMacroDict:
- FileLineTuple = GetRealFileLine(self.FileName, DefineLine + 1)
- MacProfile = MacroProfile(FileLineTuple[0], FileLineTuple[1])
- MacProfile.MacroName = Macro
- MacProfile.MacroValue = Value
- AllMacroList.append(MacProfile)
- InputMacroDict[MacProfile.MacroName] = MacProfile.MacroValue
- self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
+ if self.__GetIfListCurrentItemStat(IfList):
+ DefineLine = self.CurrentLineNumber - 1
+ DefineOffset = self.CurrentOffsetWithinLine - len('DEFINE')
+ if not self.__GetNextToken():
+ raise Warning("expected Macro name", self.FileName, self.CurrentLineNumber)
+ Macro = self.__Token
+ if not self.__IsToken( "="):
+ raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
+
+ if not self.__GetNextToken():
+ raise Warning("expected value", self.FileName, self.CurrentLineNumber)
+
+ if self.__GetStringData():
+ pass
+ Value = self.__Token
+ if not Macro in InputMacroDict:
+ FileLineTuple = GetRealFileLine(self.FileName, DefineLine + 1)
+ MacProfile = MacroProfile(FileLineTuple[0], FileLineTuple[1])
+ MacProfile.MacroName = Macro
+ MacProfile.MacroValue = Value
+ AllMacroList.append(MacProfile)
+ InputMacroDict[MacProfile.MacroName] = MacProfile.MacroValue
+ self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token == 'SET':
PcdPair = self.__GetNextPcdName()
PcdName = "%s.%s" % (PcdPair[1], PcdPair[0])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2011-09-30 03:28:14
|
Revision: 2337
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2337&view=rev
Author: yingke
Date: 2011-09-30 03:28:08 +0000 (Fri, 30 Sep 2011)
Log Message:
-----------
Fix a bug to report correct line number and line content when region type keyword is not expected.
Signed-off-by: yingke
Reviewed-by: jsu1, gikidy
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-09-30 03:27:02 UTC (rev 2336)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-09-30 03:28:08 UTC (rev 2337)
@@ -1610,9 +1610,13 @@
self.__UndoToken()
self.__GetRegionFileType( RegionObj)
- else:
+ elif self.__Token == "DATA":
self.__UndoToken()
self.__GetRegionDataType( RegionObj)
+ else:
+ raise Warning("A valid region type was not found. "
+ "Valid types are [SET, FV, CAPSULE, FILE, DATA]. This error occurred",
+ self.FileName, self.CurrentLineNumber)
return True
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2011-11-04 00:47:41
|
Revision: 2392
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2392&view=rev
Author: yingke
Date: 2011-11-04 00:47:35 +0000 (Fri, 04 Nov 2011)
Log Message:
-----------
Modify FDF parser to separate preprocess phase and parsing phase.
Signed-off-by: yingke
Reviewed-by: hchen30
Reviewed-by: jsu1
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-03 05:27:42 UTC (rev 2391)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-04 00:47:35 UTC (rev 2392)
@@ -1118,6 +1118,34 @@
def SetFileBufferPos(self, Pos):
(self.CurrentLineNumber, self.CurrentOffsetWithinLine) = Pos
+ ## Preprocess() method
+ #
+ # Preprocess comment, conditional directive, include directive, replace macro.
+ # Exception will be raised if syntax error found
+ #
+ # @param self The object pointer
+ #
+ def Preprocess(self):
+ 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 = ["".join(list) for list in self.Profile.FileLinesList]
+
+ while self.__GetDefines():
+ pass
+
+ Index = 0
+ while Index < len(self.Profile.FileLinesList):
+ FileLineTuple = GetRealFileLine(self.FileName, Index + 1)
+ self.Profile.FileLinesList[Index] = self.__ReplaceMacros(self.Profile.FileLinesList[Index], FileLineTuple[0], FileLineTuple[1])
+ Index += 1
+
## ParseFile() method
#
# Parse the file profile buffer to extract fd, fv ... information
@@ -1128,26 +1156,7 @@
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 = ["".join(list) for list in self.Profile.FileLinesList]
-
- while self.__GetDefines():
- pass
-
- Index = 0
- while Index < len(self.Profile.FileLinesList):
- FileLineTuple = GetRealFileLine(self.FileName, Index + 1)
- self.Profile.FileLinesList[Index] = self.__ReplaceMacros(self.Profile.FileLinesList[Index], FileLineTuple[0], FileLineTuple[1])
- Index += 1
-
+ self.Preprocess()
while self.__GetFd():
pass
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2011-11-17 08:33:05
|
Revision: 2414
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2414&view=rev
Author: yingke
Date: 2011-11-17 08:32:56 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Check if FD or FV name exist when FD or FV statement are in capsule section.
Signed-off-by: yingke
Reviewed-by: jsu1
Reviewed-by: gikidy
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-17 08:32:46 UTC (rev 2413)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-17 08:32:56 UTC (rev 2414)
@@ -2953,6 +2953,9 @@
if not self.__GetNextToken():
raise Warning("expected FV name", self.FileName, self.CurrentLineNumber)
+ if self.__Token.upper() not in self.Profile.FvDict.keys():
+ raise Warning("FV name does not exist", self.FileName, self.CurrentLineNumber)
+
CapsuleFv = CapsuleData.CapsuleFv()
CapsuleFv.FvName = self.__Token
CapsuleObj.CapsuleDataList.append(CapsuleFv)
@@ -2978,6 +2981,9 @@
if not self.__GetNextToken():
raise Warning("expected FD name", self.FileName, self.CurrentLineNumber)
+ if self.__Token.upper() not in self.Profile.FdDict.keys():
+ raise Warning("FD name does not exist", self.FileName, self.CurrentLineNumber)
+
CapsuleFd = CapsuleData.CapsuleFd()
CapsuleFd.FdName = self.__Token
CapsuleObj.CapsuleDataList.append(CapsuleFd)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2011-11-23 08:51:49
|
Revision: 2426
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2426&view=rev
Author: yingke
Date: 2011-11-23 08:51:42 +0000 (Wed, 23 Nov 2011)
Log Message:
-----------
Fix FDF macro bugs.
Signed-off-by: yingke
Reviewed-by: jsu1
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-23 08:27:38 UTC (rev 2425)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-23 08:51:42 UTC (rev 2426)
@@ -52,6 +52,8 @@
from Common import GlobalData
from Common.String import ReplaceMacro
+from Common.Misc import tdict
+
import re
import os
@@ -77,10 +79,6 @@
RegionSizeGuidPattern = re.compile("\s*(?P<base>\w+\.\w+)\s*\|\s*(?P<size>\w+\.\w+)\s*")
IncludeFileList = []
-# Macro passed from command line, which has greatest priority and can NOT be overridden by those in FDF
-InputMacroDict = {}
-# All Macro values when parsing file, not replace existing Macro
-AllMacroList = []
def GetRealFileLine (File, Line):
@@ -215,14 +213,17 @@
self.__Token = ""
self.__SkippedChars = ""
+ # Used to section info
+ self.__CurSection = []
+ # Key: [section name, UI name, arch]
+ # Value: {MACRO_NAME : MACRO_VALUE}
+ self.__MacroDict = tdict(True, 3)
+ self.__PcdDict = {}
+
self.__WipeOffArea = []
if GenFdsGlobalVariable.WorkSpaceDir == '':
GenFdsGlobalVariable.WorkSpaceDir = os.getenv("WORKSPACE")
- InputMacroDict.update(GlobalData.gPlatformDefines)
- InputMacroDict.update(GlobalData.gGlobalDefines)
- InputMacroDict.update(GlobalData.gCommandLineDefines)
-
## __IsWhiteSpace() method
#
# Whether char at current FileBufferPos is whitespace
@@ -381,30 +382,6 @@
self.Profile.FileLinesList = [list(s) for s in self.Profile.FileLinesList]
self.Profile.FileLinesList[-1].append(' ')
- def __ReplaceMacros(self, Str, File, Line):
- MacroEnd = 0
- while Str.find('$(', MacroEnd) >= 0:
- MacroStart = Str.find('$(', MacroEnd)
- if Str.find(')', MacroStart) > 0:
- MacroEnd = Str.find(')', MacroStart)
- Name = Str[MacroStart + 2 : MacroEnd]
- Value = None
- if Name in InputMacroDict:
- Value = InputMacroDict[Name]
-
- else:
- for Profile in AllMacroList:
- if Profile.FileName == File and Profile.MacroName == Name and Profile.DefinedAtLine <= Line:
- Value = Profile.MacroValue
-
- if Value != None:
- Str = Str.replace('$(' + Name + ')', Value)
- MacroEnd = MacroStart + len(Value)
-
- else:
- raise Warning("Macro not complete", self.FileName, self.CurrentLineNumber)
- return Str
-
def __ReplaceFragment(self, StartPos, EndPos, Value = ' '):
if StartPos[0] == EndPos[0]:
Offset = StartPos[1]
@@ -446,7 +423,67 @@
self.FileName, self.CurrentLineNumber)
MacroName = MacroName[2:-1]
return MacroName, NotFlag
-
+
+ def __SetMacroValue(self, Macro, Value):
+ if not self.__CurSection:
+ return
+
+ MacroDict = {}
+ if not self.__MacroDict[self.__CurSection[0], self.__CurSection[1], self.__CurSection[2]]:
+ self.__MacroDict[self.__CurSection[0], self.__CurSection[1], self.__CurSection[2]] = MacroDict
+ else:
+ MacroDict = self.__MacroDict[self.__CurSection[0], self.__CurSection[1], self.__CurSection[2]]
+ MacroDict[Macro] = Value
+
+ def __GetMacroValue(self, Macro):
+ # Highest priority
+ if Macro in GlobalData.gCommandLineDefines:
+ return GlobalData.gCommandLineDefines[Macro]
+ if Macro in GlobalData.gGlobalDefines:
+ return GlobalData.gGlobalDefines[Macro]
+
+ if self.__CurSection:
+ MacroDict = self.__MacroDict[
+ self.__CurSection[0],
+ self.__CurSection[1],
+ self.__CurSection[2]
+ ]
+ if MacroDict and Macro in MacroDict:
+ return MacroDict[Macro]
+
+ # Lowest priority
+ if Macro in GlobalData.gPlatformDefines:
+ return GlobalData.gPlatformDefines[Macro]
+ return None
+
+ def __SectionHeaderParser(self, Section):
+ # [Defines]
+ # [FD.UiName]: use dummy instead if UI name is optional
+ # [FV.UiName]
+ # [Capsule.UiName]
+ # [Rule]: don't take rule section into account, macro is not allowed in this section
+ # [VTF.arch.UiName, arch]
+ # [OptionRom.DriverName]
+ self.__CurSection = []
+ Section = Section.strip()[1:-1].upper().replace(' ', '').strip('.')
+ ItemList = Section.split('.')
+ Item = ItemList[0]
+ if Item == '' or Item == 'RULE':
+ return
+
+ if Item == 'DEFINES':
+ self.__CurSection = ['COMMON', 'COMMON', 'COMMON']
+ elif Item == 'VTF' and len(ItemList) == 3:
+ UiName = ItemList[2]
+ Pos = UiName.find(',')
+ if Pos != -1:
+ UiName = UiName[:Pos]
+ self.__CurSection = ['VTF', UiName, ItemList[1]]
+ elif len(ItemList) > 1:
+ self.__CurSection = [ItemList[0], ItemList[1], 'COMMON']
+ elif len(ItemList) > 0:
+ self.__CurSection = [ItemList[0], 'DUMMY', 'COMMON']
+
## PreprocessFile() method
#
# Preprocess file contents, replace comments with spaces.
@@ -530,10 +567,10 @@
raise Warning("expected include file name", self.FileName, self.CurrentLineNumber)
IncFileName = self.__Token
__IncludeMacros = {}
- __IncludeMacros['WORKSPACE'] = InputMacroDict['WORKSPACE']
- __IncludeMacros['ECP_SOURCE'] = InputMacroDict['ECP_SOURCE']
- __IncludeMacros['EFI_SOURCE'] = InputMacroDict['EFI_SOURCE']
- __IncludeMacros['EDK_SOURCE'] = InputMacroDict['EDK_SOURCE']
+ __IncludeMacros['WORKSPACE'] = self.__GetMacroValue('WORKSPACE')
+ __IncludeMacros['ECP_SOURCE'] = self.__GetMacroValue('ECP_SOURCE')
+ __IncludeMacros['EFI_SOURCE'] = self.__GetMacroValue('EFI_SOURCE')
+ __IncludeMacros['EDK_SOURCE'] = self.__GetMacroValue('EDK_SOURCE')
IncludedFile = NormPath(ReplaceMacro(IncFileName, __IncludeMacros, RaiseError=True))
#
@@ -609,8 +646,47 @@
IfList = []
RegionLayoutLine = 0
while self.__GetNextToken():
+ # Determine section name and the location dependent macro
+ if self.__GetIfListCurrentItemStat(IfList):
+ if self.__Token.startswith('['):
+ Header = self.__Token
+ if not self.__Token.endswith(']'):
+ self.__SkipToToken(']')
+ Header += self.__SkippedChars
+ if Header.find('$(') != -1:
+ raise Warning("macro cannot be used in section header", self.FileName, self.CurrentLineNumber)
+ self.__SectionHeaderParser(Header)
+ continue
+ # Replace macros except in RULE section or out of section
+ elif self.__CurSection and self.__Token.find('$(') != -1:
+ CurIndex = self.CurrentOffsetWithinLine
+ self.__UndoToken()
+ PreIndex = self.CurrentOffsetWithinLine
+ CurLine = self.Profile.FileLinesList[self.CurrentLineNumber - 1]
+ MacroReplaced = False
+ StartPos = CurLine.find('$(', PreIndex, CurIndex+1)
+ EndPos = CurLine.find(')', StartPos+2, CurIndex+1)
+ while StartPos != -1 and EndPos != -1:
+ MacroName = CurLine[StartPos+2 : EndPos]
+ MacorValue = self.__GetMacroValue(MacroName)
+ if MacorValue != None:
+ MacroReplaced = True
+ CurLine = CurLine.replace('$(' + MacroName + ')', MacorValue, 1)
+ PreIndex = StartPos + len(MacorValue)
+ CurIndex = CurIndex - (len(MacroName) + 3 - len(MacorValue))
+ else:
+ PreIndex = EndPos + 1
+ StartPos = CurLine.find('$(', PreIndex, CurIndex+1)
+ EndPos = CurLine.find(')', StartPos+2, CurIndex+1)
+ if not MacroReplaced:
+ self.CurrentOffsetWithinLine = CurIndex
+ self.Profile.FileLinesList[self.CurrentLineNumber - 1] = CurLine
+ continue
+
if self.__Token == 'DEFINE':
- if self.__GetIfListCurrentItemStat(IfList):
+ if self.__GetIfListCurrentItemStat(IfList):
+ if not self.__CurSection:
+ raise Warning("macro cannot be defined in Rule section or out of section", self.FileName, self.CurrentLineNumber)
DefineLine = self.CurrentLineNumber - 1
DefineOffset = self.CurrentOffsetWithinLine - len('DEFINE')
if not self.__GetNextToken():
@@ -625,13 +701,7 @@
if self.__GetStringData():
pass
Value = self.__Token
- if not Macro in InputMacroDict:
- FileLineTuple = GetRealFileLine(self.FileName, DefineLine + 1)
- MacProfile = MacroProfile(FileLineTuple[0], FileLineTuple[1])
- MacProfile.MacroName = Macro
- MacProfile.MacroValue = Value
- AllMacroList.append(MacProfile)
- InputMacroDict[MacProfile.MacroName] = MacProfile.MacroValue
+ self.__SetMacroValue(Macro, Value)
self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token == 'SET':
PcdPair = self.__GetNextPcdName()
@@ -649,7 +719,7 @@
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
Value += self.__SkippedChars
- InputMacroDict[PcdName] = Value
+ self.__PcdDict[PcdName] = Value
elif self.__Token in ('!ifdef', '!ifndef', '!if'):
IfStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token))
IfList.append([IfStartPos, None, None])
@@ -709,19 +779,50 @@
if not RegionSizeGuid:
RegionLayoutLine = self.CurrentLineNumber + 1
continue
- InputMacroDict[RegionSizeGuid.group('base')] = RegionSize.group('base')
- InputMacroDict[RegionSizeGuid.group('size')] = RegionSize.group('size')
+ self.__PcdDict[RegionSizeGuid.group('base')] = RegionSize.group('base')
+ self.__PcdDict[RegionSizeGuid.group('size')] = RegionSize.group('size')
RegionLayoutLine = self.CurrentLineNumber + 1
if IfList:
raise Warning("Missing !endif", self.FileName, self.CurrentLineNumber)
self.Rewind()
+ def __CollectMacroPcd(self):
+ MacroDict = {}
+
+ # PCD macro
+ MacroDict.update(self.__PcdDict)
+
+ # Lowest priority
+ MacroDict.update(GlobalData.gPlatformDefines)
+
+ if self.__CurSection:
+ # Defines macro
+ ScopeMacro = self.__MacroDict['COMMON', 'COMMON', 'COMMON']
+ if ScopeMacro:
+ MacroDict.update(ScopeMacro)
+
+ # Section macro
+ ScopeMacro = self.__MacroDict[
+ self.__CurSection[0],
+ self.__CurSection[1],
+ self.__CurSection[2]
+ ]
+ if ScopeMacro:
+ MacroDict.update(ScopeMacro)
+
+ MacroDict.update(GlobalData.gGlobalDefines)
+ MacroDict.update(GlobalData.gCommandLineDefines)
+ # Highest priority
+
+ return MacroDict
+
def __EvaluateConditional(self, Expression, Line, Op = None, Value = None):
FileLineTuple = GetRealFileLine(self.FileName, Line)
+ MacroPcdDict = self.__CollectMacroPcd()
if Op == 'eval':
try:
- return ValueExpression(Expression, InputMacroDict)()
+ return ValueExpression(Expression, MacroPcdDict)()
except SymbolNotFound:
return False
except WrnExpression, Excpt:
@@ -738,7 +839,7 @@
else:
if Expression.startswith('$(') and Expression[-1] == ')':
Expression = Expression[2:-1]
- return Expression in InputMacroDict
+ return Expression in MacroPcdDict
## __IsToken() method
#
@@ -1150,12 +1251,6 @@
while self.__GetDefines():
pass
-
- Index = 0
- while Index < len(self.Profile.FileLinesList):
- FileLineTuple = GetRealFileLine(self.FileName, Index + 1)
- self.Profile.FileLinesList[Index] = self.__ReplaceMacros(self.Profile.FileLinesList[Index], FileLineTuple[0], FileLineTuple[1])
- Index += 1
## ParseFile() method
#
@@ -1239,11 +1334,6 @@
if not self.__GetNextToken() or self.__Token.startswith('['):
raise Warning("expected MACRO value", self.FileName, self.CurrentLineNumber)
Value = self.__Token
- FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- MacProfile = MacroProfile(FileLineTuple[0], FileLineTuple[1])
- MacProfile.MacroName = Macro
- MacProfile.MacroValue = Value
- AllMacroList.append(MacProfile)
return False
@@ -2420,7 +2510,7 @@
if ErrorCode != 0:
EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
else:
- if not InputMacroDict["OUTPUT_DIRECTORY"] in FfsFileObj.FileName:
+ if not self.__GetMacroValue("OUTPUT_DIRECTORY") in FfsFileObj.FileName:
#do case sensitive check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(FfsFileObj.FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2011-11-28 02:10:37
|
Revision: 2434
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2434&view=rev
Author: yingke
Date: 2011-11-28 02:10:31 +0000 (Mon, 28 Nov 2011)
Log Message:
-----------
FDF parser bug fix:
1. Fix bug to get complete macro value.
2. Fix bug to report error if ?\226?\128?\156!if?\226?\128?\157, ?\226?\128?\156!ifdef?\226?\128?\157 are missing before ?\226?\128?\156!endif?\226?\128?\157.
3. Fix bug to get token correctly if the first line of FDF file is not comment.
Signed-off-by:yingke
Reviewed-by: jsu1
Reviewed-by: gikidy
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-28 02:00:55 UTC (rev 2433)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-28 02:10:31 UTC (rev 2434)
@@ -695,12 +695,7 @@
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
- if not self.__GetNextToken():
- raise Warning("expected value", self.FileName, self.CurrentLineNumber)
-
- if self.__GetStringData():
- pass
- Value = self.__Token
+ Value = self.__GetExpression()
self.__SetMacroValue(Macro, Value)
self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token == 'SET':
@@ -761,6 +756,8 @@
IfList[-1][2] = True
self.__WipeOffArea.append((IfList[-1][0], (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token == '!endif':
+ if len(IfList) <= 0:
+ raise Warning("Missing !if statement", self.FileName, self.CurrentLineNumber)
if IfList[-1][1]:
self.__WipeOffArea.append(((self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len('!endif')), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
else:
@@ -823,8 +820,6 @@
if Op == 'eval':
try:
return ValueExpression(Expression, MacroPcdDict)()
- except SymbolNotFound:
- return False
except WrnExpression, Excpt:
#
# Catch expression evaluation warning here. We need to report
@@ -1047,7 +1042,7 @@
# That is, when we got a space or any char in the tuple, we got the end of token.
if not str(TempChar).isspace() and not TempChar in SEPERATOR_TUPLE:
if not self.__UndoOneChar():
- break
+ return
# 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 == self.CurrentOffsetWithinLine and TempChar in SEPERATOR_TUPLE:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2011-11-28 05:57:28
|
Revision: 2437
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2437&view=rev
Author: yingke
Date: 2011-11-28 05:57:22 +0000 (Mon, 28 Nov 2011)
Log Message:
-----------
Fix bug to replace SET statement macro and evaluate SET statement PCD value in FDF file.
Signed-off-by: yingke
Reviewed-by: jsu1
Reviewed-by: gikidy
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-28 05:36:51 UTC (rev 2436)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-11-28 05:57:22 UTC (rev 2437)
@@ -645,6 +645,7 @@
# IfList is a stack of if branches with elements of list [Pos, CondSatisfied, BranchDetermined]
IfList = []
RegionLayoutLine = 0
+ ReplacedLine = -1
while self.__GetNextToken():
# Determine section name and the location dependent macro
if self.__GetIfListCurrentItemStat(IfList):
@@ -658,28 +659,26 @@
self.__SectionHeaderParser(Header)
continue
# Replace macros except in RULE section or out of section
- elif self.__CurSection and self.__Token.find('$(') != -1:
- CurIndex = self.CurrentOffsetWithinLine
+ elif self.__CurSection and ReplacedLine != self.CurrentLineNumber:
self.__UndoToken()
- PreIndex = self.CurrentOffsetWithinLine
+ ReplacedLine = self.CurrentLineNumber
CurLine = self.Profile.FileLinesList[self.CurrentLineNumber - 1]
- MacroReplaced = False
- StartPos = CurLine.find('$(', PreIndex, CurIndex+1)
- EndPos = CurLine.find(')', StartPos+2, CurIndex+1)
+ PreIndex = 0
+ StartPos = CurLine.find('$(', PreIndex)
+ EndPos = CurLine.find(')', StartPos+2)
while StartPos != -1 and EndPos != -1:
MacroName = CurLine[StartPos+2 : EndPos]
MacorValue = self.__GetMacroValue(MacroName)
if MacorValue != None:
- MacroReplaced = True
CurLine = CurLine.replace('$(' + MacroName + ')', MacorValue, 1)
- PreIndex = StartPos + len(MacorValue)
- CurIndex = CurIndex - (len(MacroName) + 3 - len(MacorValue))
+ if MacorValue.find('$(') != -1:
+ PreIndex = StartPos
+ else:
+ PreIndex = StartPos + len(MacorValue)
else:
PreIndex = EndPos + 1
- StartPos = CurLine.find('$(', PreIndex, CurIndex+1)
- EndPos = CurLine.find(')', StartPos+2, CurIndex+1)
- if not MacroReplaced:
- self.CurrentOffsetWithinLine = CurIndex
+ StartPos = CurLine.find('$(', PreIndex)
+ EndPos = CurLine.find(')', StartPos+2)
self.Profile.FileLinesList[self.CurrentLineNumber - 1] = CurLine
continue
@@ -704,16 +703,9 @@
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
- if not self.__GetNextToken():
- raise Warning("expected value", self.FileName, self.CurrentLineNumber)
+ Value = self.__GetExpression()
+ Value = self.__EvaluateConditional(Value, self.CurrentLineNumber, 'eval', True)
- Value = self.__Token
- if Value.startswith("{"):
- # deal with value with {}
- if not self.__SkipToToken( "}"):
- raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
- Value += self.__SkippedChars
-
self.__PcdDict[PcdName] = Value
elif self.__Token in ('!ifdef', '!ifndef', '!if'):
IfStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token))
@@ -819,7 +811,10 @@
MacroPcdDict = self.__CollectMacroPcd()
if Op == 'eval':
try:
- return ValueExpression(Expression, MacroPcdDict)()
+ if Value:
+ return ValueExpression(Expression, MacroPcdDict)(True)
+ else:
+ return ValueExpression(Expression, MacroPcdDict)()
except WrnExpression, Excpt:
#
# Catch expression evaluation warning here. We need to report
@@ -1652,16 +1647,9 @@
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
- if not self.__GetNextToken():
- raise Warning("expected value", self.FileName, self.CurrentLineNumber)
+ Value = self.__GetExpression()
+ Value = self.__EvaluateConditional(Value, self.CurrentLineNumber, 'eval', True)
- Value = self.__Token
- if Value.startswith("{"):
- # deal with value with {}
- if not self.__SkipToToken( "}"):
- raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
- Value += self.__SkippedChars
-
if Obj:
Obj.SetVarDict[PcdPair] = Value
self.Profile.PcdDict[PcdPair] = Value
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <xf...@us...> - 2011-12-05 03:09:52
|
Revision: 2457
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2457&view=rev
Author: xfzyr
Date: 2011-12-05 03:09:46 +0000 (Mon, 05 Dec 2011)
Log Message:
-----------
Update code to Fix a issue for the regression build failure of TunnelMountain.
Signed-off-by: yzeng15
Reviewed-by: gikidy
Reviewed-by: yingke
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-12-05 02:47:45 UTC (rev 2456)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-12-05 03:09:46 UTC (rev 2457)
@@ -1584,7 +1584,7 @@
BlockSizePcd = PcdPair
self.Profile.PcdDict[PcdPair] = BlockSize
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
+ self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple
BlockSize = long(BlockSize, 0)
BlockNumber = None
@@ -1675,7 +1675,7 @@
Obj.SetVarDict[PcdPair] = Value
self.Profile.PcdDict[PcdPair] = Value
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
+ self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple
return True
return False
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gi...@us...> - 2011-12-13 05:28:50
|
Revision: 2464
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2464&view=rev
Author: gikidy
Date: 2011-12-13 05:28:44 +0000 (Tue, 13 Dec 2011)
Log Message:
-----------
Fix an issue while using !ifndef in FDF file build tool cannot parse !ifndef statement correctly.
Signed-off-by: gikidy
Reviewed-by: lgao4
Reviewed-by: jliu66
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-12-09 09:56:48 UTC (rev 2463)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-12-13 05:28:44 UTC (rev 2464)
@@ -679,7 +679,7 @@
PreIndex = 0
StartPos = CurLine.find('$(', PreIndex)
EndPos = CurLine.find(')', StartPos+2)
- while StartPos != -1 and EndPos != -1:
+ while StartPos != -1 and EndPos != -1 and not (self.__Token == 'ifdef' or self.__Token == '!ifndef'):
MacroName = CurLine[StartPos+2 : EndPos]
MacorValue = self.__GetMacroValue(MacroName)
if MacorValue != None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gi...@us...> - 2011-12-16 03:16:46
|
Revision: 2472
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2472&view=rev
Author: gikidy
Date: 2011-12-16 03:16:40 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Fix an issue while using !ifdef in FDF file.
Signed-off-by: gikidy
Reviewed-by: lgao4
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-12-15 03:32:45 UTC (rev 2471)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2011-12-16 03:16:40 UTC (rev 2472)
@@ -679,7 +679,7 @@
PreIndex = 0
StartPos = CurLine.find('$(', PreIndex)
EndPos = CurLine.find(')', StartPos+2)
- while StartPos != -1 and EndPos != -1 and not (self.__Token == 'ifdef' or self.__Token == '!ifndef'):
+ while StartPos != -1 and EndPos != -1 and not (self.__Token == '!ifdef' or self.__Token == '!ifndef'):
MacroName = CurLine[StartPos+2 : EndPos]
MacorValue = self.__GetMacroValue(MacroName)
if MacorValue != None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2012-02-03 02:14:03
|
Revision: 2482
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2482&view=rev
Author: yingke
Date: 2012-02-03 02:13:57 +0000 (Fri, 03 Feb 2012)
Log Message:
-----------
Enhance regular SET and shortcut SET statement for FDF.
Signed-off-by: yingke
Reviewed-by: jsu1
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2012-02-01 02:53:53 UTC (rev 2481)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2012-02-03 02:13:57 UTC (rev 2482)
@@ -77,6 +77,7 @@
RegionSizePattern = re.compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
RegionSizeGuidPattern = re.compile("\s*(?P<base>\w+\.\w+)\s*\|\s*(?P<size>\w+\.\w+)\s*")
+ShortcutPcdPattern = re.compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
IncludeFileList = []
@@ -679,7 +680,7 @@
PreIndex = 0
StartPos = CurLine.find('$(', PreIndex)
EndPos = CurLine.find(')', StartPos+2)
- while StartPos != -1 and EndPos != -1 and not (self.__Token == '!ifdef' or self.__Token == '!ifndef'):
+ while StartPos != -1 and EndPos != -1 and self.__Token not in ['!ifdef', '!ifndef', '!if', '!elseif']:
MacroName = CurLine[StartPos+2 : EndPos]
MacorValue = self.__GetMacroValue(MacroName)
if MacorValue != None:
@@ -711,6 +712,8 @@
self.__SetMacroValue(Macro, Value)
self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token == 'SET':
+ SetLine = self.CurrentLineNumber - 1
+ SetOffset = self.CurrentOffsetWithinLine - len('SET')
PcdPair = self.__GetNextPcdName()
PcdName = "%s.%s" % (PcdPair[1], PcdPair[0])
if not self.__IsToken( "="):
@@ -720,6 +723,12 @@
Value = self.__EvaluateConditional(Value, self.CurrentLineNumber, 'eval', True)
self.__PcdDict[PcdName] = Value
+
+ self.Profile.PcdDict[PcdPair] = Value
+ FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
+ self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple
+
+ self.__WipeOffArea.append(((SetLine, SetOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token in ('!ifdef', '!ifndef', '!if'):
IfStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token))
IfList.append([IfStartPos, None, None])
@@ -773,6 +782,11 @@
if self.CurrentLineNumber <= RegionLayoutLine:
# Don't try the same line twice
continue
+ SetPcd = ShortcutPcdPattern.match(self.Profile.FileLinesList[self.CurrentLineNumber - 1])
+ if SetPcd:
+ self.__PcdDict[SetPcd.group('name')] = SetPcd.group('value')
+ RegionLayoutLine = self.CurrentLineNumber
+ continue
RegionSize = RegionSizePattern.match(self.Profile.FileLinesList[self.CurrentLineNumber - 1])
if not RegionSize:
RegionLayoutLine = self.CurrentLineNumber
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2012-02-29 03:22:00
|
Revision: 2492
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2492&view=rev
Author: yingke
Date: 2012-02-29 03:21:54 +0000 (Wed, 29 Feb 2012)
Log Message:
-----------
Fix bug for incorrect line number printed when check duplicated INFs in a FV section.
Signed-off-by: yingke
Reviewed-by: lgao4
Reviewed-by: jsu1
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2012-02-27 23:44:20 UTC (rev 2491)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2012-02-29 03:21:54 UTC (rev 2492)
@@ -2302,6 +2302,10 @@
if not self.__GetNextToken():
raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber)
ffsInf.InfFileName = self.__Token
+
+ ffsInf.CurrentLineNum = self.CurrentLineNumber
+ ffsInf.CurrentLineContent = self.__CurrentLine()
+
if ffsInf.InfFileName.replace('$(WORKSPACE)', '').find('$') == -1:
#do case sensitive check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
@@ -2321,9 +2325,6 @@
else:
raise Warning("Unknown reloc strip flag '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
- ffsInf.CurrentLineNum = self.CurrentLineNumber
- ffsInf.CurrentLineContent = self.__CurrentLine()
-
if ForCapsule:
capsuleFfs = CapsuleData.CapsuleFfs()
capsuleFfs.Ffs = ffsInf
@@ -2434,9 +2435,6 @@
FfsFileObj.NameGuid = self.__Token
- FfsFileObj.CurrentLineNum = self.CurrentLineNumber
- FfsFileObj.CurrentLineContent = self.__CurrentLine()
-
self.__GetFilePart( FfsFileObj, MacroDict.copy())
if ForCapsule:
@@ -2526,6 +2524,8 @@
self.__UndoToken()
self.__GetSectionData( FfsFileObj, MacroDict)
else:
+ FfsFileObj.CurrentLineNum = self.CurrentLineNumber
+ FfsFileObj.CurrentLineContent = self.__CurrentLine()
FfsFileObj.FileName = self.__Token
if FfsFileObj.FileName.replace('$(WORKSPACE)', '').find('$') == -1:
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2013-08-12 01:33:07
|
Revision: 2595
http://sourceforge.net/p/edk2-buildtools/code/2595
Author: yingke
Date: 2013-08-12 01:32:58 +0000 (Mon, 12 Aug 2013)
Log Message:
-----------
Support expressions in the Offset and Value fields in an FDF file?\226?\128?\153s [FD] section.
Signed-off-by: Yingke Liu <yin...@in...>
Reviewed-by: Larry Hauch <lar...@in...>
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2013-08-09 07:07:25 UTC (rev 2594)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2013-08-12 01:32:58 UTC (rev 2595)
@@ -1707,6 +1707,38 @@
return False
+ ## __CalcRegionExpr(self)
+ #
+ # Calculate expression for offset or size of a region
+ #
+ # @return: None if invalid expression
+ # Calculated number if successfully
+ #
+ def __CalcRegionExpr(self):
+ StartPos = self.GetFileBufferPos()
+ Expr = ''
+ PairCount = 0
+ while not self.__EndOfFile():
+ CurCh = self.__CurrentChar()
+ if CurCh == '(':
+ PairCount += 1
+ elif CurCh == ')':
+ PairCount -= 1
+
+ if CurCh in '|\r\n' and PairCount == 0:
+ break
+ Expr += CurCh
+ self.__GetOneChar()
+ try:
+ return long(
+ ValueExpression(Expr,
+ dict(['%s.%s' % (Pcd[1], Pcd[0]), Val]
+ for Pcd, Val in self.Profile.PcdDict.iteritems())
+ )(True),0)
+ except Exception:
+ self.SetFileBufferPos(StartPos)
+ return None
+
## __GetRegionLayout() method
#
# Get region layout for FD
@@ -1717,19 +1749,21 @@
# @retval False Not able to find
#
def __GetRegionLayout(self, Fd):
- if not self.__GetNextHexNumber():
+ Offset = self.__CalcRegionExpr()
+ if Offset == None:
return False
RegionObj = Region.Region()
- RegionObj.Offset = long(self.__Token, 0)
+ RegionObj.Offset = Offset
Fd.RegionList.append(RegionObj)
if not self.__IsToken( "|"):
raise Warning("expected '|'", self.FileName, self.CurrentLineNumber)
- if not self.__GetNextHexNumber():
+ Size = self.__CalcRegionExpr()
+ if Size == None:
raise Warning("expected Region Size", self.FileName, self.CurrentLineNumber)
- RegionObj.Size = long(self.__Token, 0)
+ RegionObj.Size = Size
if not self.__GetNextWord():
return True
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2013-11-18 05:46:01
|
Revision: 2609
http://sourceforge.net/p/edk2-buildtools/code/2609
Author: yingke
Date: 2013-11-18 05:45:54 +0000 (Mon, 18 Nov 2013)
Log Message:
-----------
Fix a bug which hangs build if FV section only has attributes listed.
Reviewed-by: Hesheng Chen <hes...@in...>
Signed-off-by: Yingke Liu <yin...@in...>
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2013-11-14 07:29:08 UTC (rev 2608)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2013-11-18 05:45:54 UTC (rev 2609)
@@ -2158,8 +2158,9 @@
# @retval None
#
def __GetFvAttributes(self, FvObj):
-
+ IsWordToken = False
while self.__GetNextWord():
+ IsWordToken = True
name = self.__Token
if name not in ("ERASE_POLARITY", "MEMORY_MAPPED", \
"STICKY_WRITE", "LOCK_CAP", "LOCK_STATUS", "WRITE_ENABLED_CAP", \
@@ -2178,7 +2179,7 @@
FvObj.FvAttributeDict[name] = self.__Token
- return True
+ return IsWordToken
## __GetFvNameGuid() method
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2013-12-11 07:49:58
|
Revision: 2626
http://sourceforge.net/p/edk2-buildtools/code/2626
Author: yingke
Date: 2013-12-11 07:49:55 +0000 (Wed, 11 Dec 2013)
Log Message:
-----------
1. Only HEX value was allowed by OEM_CAPSULE_FLAGS.
2. The value of offset PCD is only the offset not including base address in expression which is used by region offset and size.
Reviewed-by: Hesheng Chen <hes...@in...>
Signed-off-by: Yingke Liu <yin...@in...>
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2013-12-10 07:35:47 UTC (rev 2625)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2013-12-11 07:49:55 UTC (rev 2626)
@@ -1732,8 +1732,7 @@
try:
return long(
ValueExpression(Expr,
- dict(['%s.%s' % (Pcd[1], Pcd[0]), Val]
- for Pcd, Val in self.Profile.PcdDict.iteritems())
+ self.__CollectMacroPcd()
)(True),0)
except Exception:
self.SetFileBufferPos(StartPos)
@@ -1772,11 +1771,13 @@
self.__UndoToken()
RegionObj.PcdOffset = self.__GetNextPcdName()
self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + long(Fd.BaseAddress, 0))
+ self.__PcdDict['%s.%s' % (RegionObj.PcdOffset[1], RegionObj.PcdOffset[0])] = "0x%x" % RegionObj.Offset
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
self.Profile.PcdFileLineDict[RegionObj.PcdOffset] = FileLineTuple
if self.__IsToken( "|"):
RegionObj.PcdSize = self.__GetNextPcdName()
self.Profile.PcdDict[RegionObj.PcdSize] = "0x%08X" % RegionObj.Size
+ self.__PcdDict['%s.%s' % (RegionObj.PcdSize[1], RegionObj.PcdSize[0])] = "0x%x" % RegionObj.Size
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
self.Profile.PcdFileLineDict[RegionObj.PcdSize] = FileLineTuple
@@ -3063,12 +3064,14 @@
Value += self.__Token.strip()
elif Name == 'OEM_CAPSULE_FLAGS':
Value = self.__Token.strip()
+ if not Value.upper().startswith('0X'):
+ raise Warning("expected hex value between 0x0000 and 0xFFFF", self.FileName, self.CurrentLineNumber)
try:
Value = int(Value, 0)
except ValueError:
- raise Warning("expected integer value between 0x0000 and 0xFFFF", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected hex value between 0x0000 and 0xFFFF", self.FileName, self.CurrentLineNumber)
if not 0x0000 <= Value <= 0xFFFF:
- raise Warning("expected integer value between 0x0000 and 0xFFFF", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected hex value between 0x0000 and 0xFFFF", self.FileName, self.CurrentLineNumber)
Value = self.__Token.strip()
else:
Value = self.__Token.strip()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yi...@us...> - 2014-01-09 06:33:50
|
Revision: 2638
http://sourceforge.net/p/edk2-buildtools/code/2638
Author: yingke
Date: 2014-01-09 06:33:45 +0000 (Thu, 09 Jan 2014)
Log Message:
-----------
Fix a bug which report error if a correct FD contains a region with no region type followed by another region whose offset is an expression staring with a PCD.
Reviewed-by: Liming Gao <lim...@in...>
Signed-off-by: Yingke Liu <yin...@in...>
Modified Paths:
--------------
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2014-01-09 06:25:14 UTC (rev 2637)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2014-01-09 06:33:45 UTC (rev 2638)
@@ -1,7 +1,7 @@
## @file
# parse FDF file
#
-# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -77,6 +77,7 @@
RegionSizePattern = re.compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
RegionSizeGuidPattern = re.compile("\s*(?P<base>\w+\.\w+)\s*\|\s*(?P<size>\w+\.\w+)\s*")
+RegionOffsetPcdPattern = re.compile("\s*(?P<base>\w+\.\w+)\s*$")
ShortcutPcdPattern = re.compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
IncludeFileList = []
@@ -1768,18 +1769,26 @@
return True
if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE"):
+ #
+ # If next token is a word which is not a valid FV type, it might be part of [PcdOffset[|PcdSize]]
+ # Or it might be next region's offset described by an expression which starts with a PCD.
+ # PcdOffset[|PcdSize] or OffsetPcdExpression|Size
+ #
self.__UndoToken()
- RegionObj.PcdOffset = self.__GetNextPcdName()
- self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + long(Fd.BaseAddress, 0))
- self.__PcdDict['%s.%s' % (RegionObj.PcdOffset[1], RegionObj.PcdOffset[0])] = "0x%x" % RegionObj.Offset
- FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- self.Profile.PcdFileLineDict[RegionObj.PcdOffset] = FileLineTuple
- if self.__IsToken( "|"):
- RegionObj.PcdSize = self.__GetNextPcdName()
- self.Profile.PcdDict[RegionObj.PcdSize] = "0x%08X" % RegionObj.Size
- self.__PcdDict['%s.%s' % (RegionObj.PcdSize[1], RegionObj.PcdSize[0])] = "0x%x" % RegionObj.Size
+ IsRegionPcd = (RegionSizeGuidPattern.match(self.__CurrentLine()[self.CurrentOffsetWithinLine:]) or
+ RegionOffsetPcdPattern.match(self.__CurrentLine()[self.CurrentOffsetWithinLine:]))
+ if IsRegionPcd:
+ RegionObj.PcdOffset = self.__GetNextPcdName()
+ self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + long(Fd.BaseAddress, 0))
+ self.__PcdDict['%s.%s' % (RegionObj.PcdOffset[1], RegionObj.PcdOffset[0])] = "0x%x" % RegionObj.Offset
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- self.Profile.PcdFileLineDict[RegionObj.PcdSize] = FileLineTuple
+ self.Profile.PcdFileLineDict[RegionObj.PcdOffset] = FileLineTuple
+ if self.__IsToken( "|"):
+ RegionObj.PcdSize = self.__GetNextPcdName()
+ self.Profile.PcdDict[RegionObj.PcdSize] = "0x%08X" % RegionObj.Size
+ self.__PcdDict['%s.%s' % (RegionObj.PcdSize[1], RegionObj.PcdSize[0])] = "0x%x" % RegionObj.Size
+ FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
+ self.Profile.PcdFileLineDict[RegionObj.PcdSize] = FileLineTuple
if not self.__GetNextWord():
return True
@@ -1806,6 +1815,9 @@
self.__UndoToken()
self.__GetRegionDataType( RegionObj)
else:
+ self.__UndoToken()
+ if self.__GetRegionLayout(Fd):
+ return True
raise Warning("A valid region type was not found. "
"Valid types are [SET, FV, CAPSULE, FILE, DATA]. This error occurred",
self.FileName, self.CurrentLineNumber)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|