Re: [edk2] [Patch] BaseTools/GenFds: Remove redundant GetRealFileLine call

2018-05-27 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu <yonghong@intel.com> 

Best Regards,
Zhu Yonghong


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yonghong 
Zhu
Sent: Friday, May 25, 2018 7:59 AM
To: edk2-devel@lists.01.org
Cc: zurc...@ml01.01.org; Zurcher, Christopher J 
<christopher.j.zurc...@intel.com>; Gao, Liming <liming@intel.com>
Subject: [edk2] [Patch] BaseTools/GenFds: Remove redundant GetRealFileLine call

From: Zurcher, Christopher J <christopher.j.zurc...@intel.com>

The EvaluateConditional function should not call GetRealFileLine because this 
is already done in Warning init and only needs to be calculated in the event of 
a parsing failure. This fix stops InsertedLines from being subtracted twice 
during error handling.

Cc: Liming Gao <liming@intel.com>
Cc: Yonghong Zhu <yonghong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zurcher, Christopher J <christopher.j.zurc...@intel.com>
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 8a9296c..4518d8f 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -912,11 +912,10 @@ class FdfParser:
 # 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:
 if Value:
 return ValueExpression(Expression, MacroPcdDict)(True) @@ 
-937,16 +936,16 @@ class FdfParser:
 Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd]
 raise Warning("Cannot use this PCD (%s) in an 
expression as"
   " it must be defined in a 
[PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
   " of the DSC file (%s), and it is 
currently defined in this section:"
   " %s, line #: %d." % (Excpt.Pcd, 
GlobalData.gPlatformOtherPcds['DSCFILE'], Info[0], Info[1]),
-  *FileLineTuple)
+  self.FileName, Line)
 else:
 raise Warning("PCD (%s) is not defined in DSC file 
(%s)" % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE']),
-  *FileLineTuple)
+  self.FileName, Line)
 else:
-raise Warning(str(Excpt), *FileLineTuple)
+raise Warning(str(Excpt), self.FileName, Line)
 else:
 if Expression.startswith('$(') and Expression[-1] == ')':
 Expression = Expression[2:-1]
 return Expression in MacroPcdDict
 
--
2.6.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools/GenFds: Remove redundant GetRealFileLine call

2018-05-24 Thread Yonghong Zhu
From: Zurcher, Christopher J 

The EvaluateConditional function should not call GetRealFileLine
because this is already done in Warning init and only needs to be
calculated in the event of a parsing failure. This fix stops
InsertedLines from being subtracted twice during error handling.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zurcher, Christopher J 
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 8a9296c..4518d8f 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -912,11 +912,10 @@ class FdfParser:
 # 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:
 if Value:
 return ValueExpression(Expression, MacroPcdDict)(True)
@@ -937,16 +936,16 @@ class FdfParser:
 Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd]
 raise Warning("Cannot use this PCD (%s) in an 
expression as"
   " it must be defined in a 
[PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
   " of the DSC file (%s), and it is 
currently defined in this section:"
   " %s, line #: %d." % (Excpt.Pcd, 
GlobalData.gPlatformOtherPcds['DSCFILE'], Info[0], Info[1]),
-  *FileLineTuple)
+  self.FileName, Line)
 else:
 raise Warning("PCD (%s) is not defined in DSC file 
(%s)" % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE']),
-  *FileLineTuple)
+  self.FileName, Line)
 else:
-raise Warning(str(Excpt), *FileLineTuple)
+raise Warning(str(Excpt), self.FileName, Line)
 else:
 if Expression.startswith('$(') and Expression[-1] == ')':
 Expression = Expression[2:-1]
 return Expression in MacroPcdDict
 
-- 
2.6.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel