From 35f613d96ce43c7b23cd77aab063424ec4422e0c Mon Sep 17 00:00:00 2001 From: Yunhua Feng Date: Sat, 27 Jan 2018 00:28:05 +0800 Subject: BaseTools: Enhance parse performance by optimize ValueExpressionEx Optimize ValueExpressionEx function to enhance meta-data file parse performance. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng Reviewed-by: Yonghong Zhu Reviewed-by: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 21 ++++++++++----------- BaseTools/Source/Python/Workspace/MetaFileParser.py | 10 ++-------- 2 files changed, 12 insertions(+), 19 deletions(-) (limited to 'BaseTools/Source/Python/Workspace') diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index f30d3f7e73..012e16a488 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -825,13 +825,14 @@ class DscBuildData(PlatformBuildClassObject): if ValueList[2] == '-1': EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self.MetaFile, Line=LineNo, ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting)) - if ValueList[Index] and PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]: + if ValueList[Index]: + DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType try: - ValueList[Index] = ValueExpression(ValueList[Index], GlobalData.gPlatformPcds)(True) - except WrnExpression, Value: - ValueList[Index] = Value.result + ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True) except BadExpression, Value: - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=self._LineIndex + 1) + EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo, + ExtraData="PCD [%s.%s] Value \"%s\" " % ( + TokenSpaceGuid, PcdCName, ValueList[Index])) except EvaluationException, Excpt: if hasattr(Excpt, 'Pcd'): if Excpt.Pcd in GlobalData.gPlatformOtherPcds: @@ -845,13 +846,8 @@ class DscBuildData(PlatformBuildClassObject): else: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt), File=self.MetaFile, Line=LineNo) + if ValueList[Index]: - DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType - try: - ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True) - except BadExpression, Value: - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo, - ExtraData="PCD [%s.%s] Value \"%s\" " % (TokenSpaceGuid, PcdCName, ValueList[Index])) Valid, ErrStr = CheckPcdDatum(self._DecPcds[PcdCName, TokenSpaceGuid].DatumType, ValueList[Index]) if not Valid: EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo, @@ -860,6 +856,9 @@ class DscBuildData(PlatformBuildClassObject): if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.strip() != ValueList[1].strip(): EdkLogger.error('build', FORMAT_INVALID, ErrStr , File=self.MetaFile, Line=LineNo, ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting)) + if (TokenSpaceGuid + '.' + PcdCName) in GlobalData.gPlatformPcds: + if GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] != ValueList[Index]: + GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] = ValueList[Index] return ValueList def _FilterPcdBySkuUsage(self,Pcds): diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 8f4b5e5cc1..c928cef70f 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1593,6 +1593,8 @@ class DscParser(MetaFileParser): ValList[Index] = ValueExpression(PcdValue, self._Macros)(True) except WrnExpression, Value: ValList[Index] = Value.result + except: + pass if ValList[Index] == 'True': ValList[Index] = '1' @@ -1989,14 +1991,6 @@ class DecParser(MetaFileParser): PcdValue = ValueList[0] if PcdValue: - try: - ValueList[0] = ValueExpression(PcdValue, self._AllPcdDict)(True) - except WrnExpression, Value: - ValueList[0] = Value.result - except BadExpression, Value: - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=self._LineIndex + 1) - - if ValueList[0]: try: ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True) except BadExpression, Value: -- cgit v1.2.3