|
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.
|