|
From: <yi...@us...> - 2012-03-23 06:59:27
|
Revision: 2505
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2505&view=rev
Author: yingke
Date: 2012-03-23 06:59:21 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
Report readable error message if invalid PCD is used in conditional directive.
Signed-off-by: yingke
Reviewed-by: lgao4
Reviewed-by: jsu1
Modified Paths:
--------------
trunk/BaseTools/Source/Python/Common/Expression.py
trunk/BaseTools/Source/Python/Common/GlobalData.py
trunk/BaseTools/Source/Python/GenFds/FdfParser.py
trunk/BaseTools/Source/Python/Workspace/MetaFileParser.py
Modified: trunk/BaseTools/Source/Python/Common/Expression.py
===================================================================
--- trunk/BaseTools/Source/Python/Common/Expression.py 2012-03-16 09:20:30 UTC (rev 2504)
+++ trunk/BaseTools/Source/Python/Common/Expression.py 2012-03-23 06:59:21 UTC (rev 2505)
@@ -465,7 +465,9 @@
# PCD token
if self.PcdPattern.match(self._Token):
if self._Token not in self._Symb:
- raise BadExpression(ERR_PCD_RESOLVE % self._Token)
+ Ex = BadExpression(ERR_PCD_RESOLVE % self._Token)
+ Ex.Pcd = self._Token
+ raise Ex
self._Token = ValueExpression(self._Symb[self._Token], self._Symb)(True)
if type(self._Token) != type(''):
self._LiteralToken = hex(self._Token)
Modified: trunk/BaseTools/Source/Python/Common/GlobalData.py
===================================================================
--- trunk/BaseTools/Source/Python/Common/GlobalData.py 2012-03-16 09:20:30 UTC (rev 2504)
+++ trunk/BaseTools/Source/Python/Common/GlobalData.py 2012-03-23 06:59:21 UTC (rev 2505)
@@ -26,7 +26,10 @@
gGlobalDefines = {}
gPlatformDefines = {}
+# PCD name and value pair for fixed at build and feature flag
gPlatformPcds = {}
+# PCDs with type that are not fixed at build and feature flag
+gPlatformOtherPcds = {}
gActivePlatform = None
gCommandLineDefines = {}
gEdkGlobal = {}
Modified: trunk/BaseTools/Source/Python/GenFds/FdfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2012-03-16 09:20:30 UTC (rev 2504)
+++ trunk/BaseTools/Source/Python/GenFds/FdfParser.py 2012-03-23 06:59:21 UTC (rev 2505)
@@ -853,7 +853,19 @@
Line=Line)
return Excpt.result
except Exception, Excpt:
- raise Warning("Invalid expression", *FileLineTuple)
+ if hasattr(Excpt, 'Pcd'):
+ if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
+ 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)
+ else:
+ raise Warning("PCD (%s) is not defined in DSC file (%s)" % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE']),
+ *FileLineTuple)
+ else:
+ raise Warning(str(Excpt), *FileLineTuple)
else:
if Expression.startswith('$(') and Expression[-1] == ')':
Expression = Expression[2:-1]
Modified: trunk/BaseTools/Source/Python/Workspace/MetaFileParser.py
===================================================================
--- trunk/BaseTools/Source/Python/Workspace/MetaFileParser.py 2012-03-16 09:20:30 UTC (rev 2504)
+++ trunk/BaseTools/Source/Python/Workspace/MetaFileParser.py 2012-03-23 06:59:21 UTC (rev 2505)
@@ -1185,9 +1185,23 @@
# Only catch expression evaluation error here. We need to report
# the precise number of line on which the error occurred
#
- EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
- File=self._FileWithError, ExtraData=' '.join(self._ValueList),
- Line=self._LineIndex+1)
+ if hasattr(Excpt, 'Pcd'):
+ if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
+ Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd]
+ EdkLogger.error('Parser', FORMAT_INVALID, "Cannot use this PCD (%s) in an expression as"
+ " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
+ " of the DSC file, and it is currently defined in this section:"
+ " %s, line #: %d." % (Excpt.Pcd, Info[0], Info[1]),
+ File=self._FileWithError, ExtraData=' '.join(self._ValueList),
+ Line=self._LineIndex+1)
+ else:
+ EdkLogger.error('Parser', FORMAT_INVALID, "PCD (%s) is not defined in DSC file" % Excpt.Pcd,
+ File=self._FileWithError, ExtraData=' '.join(self._ValueList),
+ Line=self._LineIndex+1)
+ else:
+ EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
+ File=self._FileWithError, ExtraData=' '.join(self._ValueList),
+ Line=self._LineIndex+1)
except MacroException, Excpt:
EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt),
File=self._FileWithError, ExtraData=' '.join(self._ValueList),
@@ -1246,6 +1260,20 @@
Name = TokenSpaceGuid + '.' + PcdName
self._Symbols[Name] = Value
+ Content = open(str(self.MetaFile), 'r').readlines()
+ GlobalData.gPlatformOtherPcds['DSCFILE'] = str(self.MetaFile)
+ for PcdType in (MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_HII,
+ MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNAMIC_EX_HII,
+ MODEL_PCD_DYNAMIC_EX_VPD):
+ Records = self._RawTable.Query(PcdType, BelongsToItem=-1.0)
+ for TokenSpaceGuid,PcdName,Value,Dummy2,Dummy3,ID,Line in Records:
+ Name = TokenSpaceGuid + '.' + PcdName
+ if Name not in GlobalData.gPlatformOtherPcds:
+ PcdLine = Line
+ while not Content[Line - 1].lstrip().startswith(TAB_SECTION_START):
+ Line -= 1
+ GlobalData.gPlatformOtherPcds[Name] = (CleanString(Content[Line - 1]), PcdLine, PcdType)
+
def __ProcessDefine(self):
if not self._Enabled:
return
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|