From nobody Fri Nov 1 10:24:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516984100997464.6395116303444; Fri, 26 Jan 2018 08:28:20 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 927392222C25D; Fri, 26 Jan 2018 08:22:48 -0800 (PST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CB0052222C233 for ; Fri, 26 Jan 2018 08:22:46 -0800 (PST) Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jan 2018 08:28:16 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by fmsmga007.fm.intel.com with ESMTP; 26 Jan 2018 08:28:15 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,417,1511856000"; d="scan'208";a="13218661" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Sat, 27 Jan 2018 00:28:05 +0800 Message-Id: <1516984085-9928-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [Patch] BaseTools: Enhance parse performance by optimize ValueExpressionEx X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yunhua Feng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Yunhua Feng 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 --- BaseTools/Source/Python/AutoGen/AutoGen.py | 16 +- BaseTools/Source/Python/Common/Expression.py | 286 +++++++++++------= ---- BaseTools/Source/Python/Workspace/DscBuildData.py | 19 +- .../Source/Python/Workspace/MetaFileParser.py | 8 - BaseTools/Source/Python/build/BuildReport.py | 9 +- 5 files changed, 167 insertions(+), 171 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index ab178c9..1cf50e8 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1243,10 +1243,11 @@ class PlatformAutoGen(AutoGen): self.FvTargetList =3D self.Workspace.FvTargetList self.AllPcdList =3D [] # get the original module/package/platform objects self.BuildDatabase =3D Workspace.BuildDatabase self.DscBuildDataObj =3D Workspace.Platform + self._GuidDict =3D Workspace._GuidDict =20 # flag indicating if the makefile/C-code file has been created or = not self.IsMakeFileCreated =3D False self.IsCodeFileCreated =3D False =20 @@ -2461,26 +2462,13 @@ class PlatformAutoGen(AutoGen): if FromPcd.DatumType not in [None, '']: ToPcd.DatumType =3D FromPcd.DatumType if FromPcd.SkuInfoList not in [None, '', []]: ToPcd.SkuInfoList =3D FromPcd.SkuInfoList # Add Flexible PCD format parse - PcdValue =3D ToPcd.DefaultValue - if PcdValue: - try: - ToPcd.DefaultValue =3D ValueExpression(PcdValue)(True) - except WrnExpression, Value: - ToPcd.DefaultValue =3D Value.result - except BadExpression, Value: - EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s]= Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defau= ltValue, Value), - File=3Dself.MetaFile) if ToPcd.DefaultValue: - _GuidDict =3D {} - for Pkg in self.PackageList: - Guids =3D Pkg.Guids - _GuidDict.update(Guids) try: - ToPcd.DefaultValue =3D ValueExpressionEx(ToPcd.Default= Value, ToPcd.DatumType, _GuidDict)(True) + ToPcd.DefaultValue =3D ValueExpressionEx(ToPcd.Default= Value, ToPcd.DatumType, self._GuidDict)(True) except BadExpression, Value: EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s]= Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defau= ltValue, Value), File=3Dself.MetaFile) =20 # check the validation of datum diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 55fa06d..d62fb48 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -1,9 +1,9 @@ ## @file # This file is used to parse and evaluate expression in directive or PCD v= alue. # -# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License # which accompanies this distribution. The full text of the license may= be found at # http://opensource.org/licenses/bsd-license.php # @@ -249,13 +249,10 @@ class ValueExpression(object): self._NoProcess =3D False if type(Expression) !=3D type(''): self._Expr =3D Expression self._NoProcess =3D True return - if Expression.strip().startswith('{') and Expression.strip().endsw= ith('}'): - self._Expr =3D Expression - self._NoProcess =3D True =20 self._Expr =3D ReplaceExprMacro(Expression.strip(), SymbolTable, SupportedInMacroList) =20 @@ -291,17 +288,19 @@ class ValueExpression(object): self._Expr =3D self._Expr.strip() if RealValue and Depth =3D=3D 0: self._Token =3D self._Expr if self.__IsNumberToken(): return self._Expr - + Token =3D '' try: Token =3D self._GetToken() - if type(Token) =3D=3D type('') and Token.startswith('{') a= nd Token.endswith('}') and self._Idx >=3D self._Len: - return self._Expr except BadExpression: pass + if type(Token) =3D=3D type('') and Token.startswith('{') and T= oken.endswith('}') and self._Idx >=3D self._Len: + if len(Token) !=3D len(self._Expr.replace(' ', '')): + raise BadExpression + return self._Expr =20 self._Idx =3D 0 self._Token =3D '' =20 Val =3D self._ConExpr() @@ -591,15 +590,14 @@ class ValueExpression(object): self._LiteralToken.endswith('}'): return True =20 if self.HexPattern.match(self._LiteralToken): Token =3D self._LiteralToken[2:] - Token =3D Token.lstrip('0') if not Token: self._LiteralToken =3D '0x0' else: - self._LiteralToken =3D '0x' + Token.lower() + self._LiteralToken =3D '0x' + Token return True return False =20 def _GetToken(self): return self.__GetNList() @@ -734,147 +732,155 @@ class ValueExpressionEx(ValueExpression): PcdValue =3D self.PcdValue try: PcdValue =3D ValueExpression.__call__(self, RealValue, Depth) except WrnExpression, Value: PcdValue =3D Value.result - - if PcdValue =3D=3D 'True': - PcdValue =3D '1' - if PcdValue =3D=3D 'False': - PcdValue =3D '0' - if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEA= N']: - PcdValue =3D PcdValue.strip() - if type(PcdValue) =3D=3D type('') and PcdValue.startswith('{')= and PcdValue.endswith('}'): - PcdValue =3D PcdValue[1:-1].split(',') - if type(PcdValue) =3D=3D type([]): - TmpValue =3D 0 - Size =3D 0 - for Item in PcdValue: - if Item.startswith('UINT16'): - ItemSize =3D 2 - elif Item.startswith('UINT32'): - ItemSize =3D 4 - elif Item.startswith('UINT64'): - ItemSize =3D 8 - else: - ItemSize =3D 0 - Item =3D ValueExpressionEx(Item, self.PcdType, self._S= ymb)(True) - - if ItemSize =3D=3D 0: - ItemValue, ItemSize =3D ParseFieldValue(Item) - else: - ItemValue =3D ParseFieldValue(Item)[0] - - if type(ItemValue) =3D=3D type(''): - ItemValue =3D int(ItemValue, 16) if ItemValue.star= tswith('0x') else int(ItemValue) - - TmpValue =3D (ItemValue << (Size * 8)) | TmpValue - Size =3D Size + ItemSize - else: - TmpValue, Size =3D ParseFieldValue(PcdValue) - if type(TmpValue) =3D=3D type(''): - TmpValue =3D int(TmpValue) - else: - PcdValue =3D '0x%0{}X'.format(Size) % (TmpValue) - if TmpValue < 0: - raise BadExpression('Type %s PCD Value is negative' % sel= f.PcdType) - if self.PcdType =3D=3D 'UINT8' and Size > 1: - raise BadExpression('Type %s PCD Value Size is Larger than= 1 byte' % self.PcdType) - if self.PcdType =3D=3D 'UINT16' and Size > 2: - raise BadExpression('Type %s PCD Value Size is Larger than= 2 byte' % self.PcdType) - if self.PcdType =3D=3D 'UINT32' and Size > 4: - raise BadExpression('Type %s PCD Value Size is Larger than= 4 byte' % self.PcdType) - if self.PcdType =3D=3D 'UINT64' and Size > 8: - raise BadExpression('Type %s PCD Value Size is Larger than= 8 byte' % self.PcdType) - if self.PcdType in ['VOID*']: - try: - TmpValue =3D long(PcdValue) - TmpList =3D [] - if TmpValue.bit_length() =3D=3D 0: - PcdValue =3D '{0x00}' - else: - for I in range((TmpValue.bit_length() + 7) / 8): - TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0= xff)) - PcdValue =3D '{' + ', '.join(TmpList) + '}' - except: - if PcdValue.strip().startswith('{'): - PcdValue =3D PcdValue.strip()[1:-1].strip() + except BadExpression: + if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BO= OLEAN']: + PcdValue =3D PcdValue.strip() + if type(PcdValue) =3D=3D type('') and PcdValue.startswith(= '{') and PcdValue.endswith('}'): + PcdValue =3D PcdValue[1:-1].split(',') + if type(PcdValue) =3D=3D type([]): + TmpValue =3D 0 Size =3D 0 - ValueStr =3D '' - TokenSpaceGuidName =3D '' - if PcdValue.startswith('GUID') and PcdValue.endswith('= )'): - try: - TokenSpaceGuidName =3D re.search('GUID\((\w+)\= )', PcdValue).group(1) - except: - pass - if TokenSpaceGuidName and TokenSpaceGuidName in se= lf._Symb: - PcdValue =3D 'GUID(' + self._Symb[TokenSpaceGu= idName] + ')' - elif TokenSpaceGuidName: - raise BadExpression('%s not found in DEC file'= % TokenSpaceGuidName) - - ListItem, Size =3D ParseFieldValue(PcdValue) - elif PcdValue.startswith('DEVICE_PATH') and PcdValue.e= ndswith(')'): - ListItem, Size =3D ParseFieldValue(PcdValue) - else: - ListItem =3D PcdValue.split(',') - - if type(ListItem) =3D=3D type(0) or type(ListItem) =3D= =3D type(0L): - for Index in range(0, Size): - ValueStr +=3D '0x%02X' % (int(ListItem) & 255) - ListItem >>=3D 8 - ValueStr +=3D ', ' - PcdValue =3D '{' + ValueStr[:-2] + '}' - elif type(ListItem) =3D=3D type(''): - if ListItem.startswith('{') and ListItem.endswith(= '}'): - PcdValue =3D ListItem + for Item in PcdValue: + if Item.startswith('UINT16'): + ItemSize =3D 2 + elif Item.startswith('UINT32'): + ItemSize =3D 4 + elif Item.startswith('UINT64'): + ItemSize =3D 8 + else: + ItemSize =3D 0 + Item =3D ValueExpressionEx(Item, self.PcdType, sel= f._Symb)(True) + + if ItemSize =3D=3D 0: + ItemValue, ItemSize =3D ParseFieldValue(Item) + else: + ItemValue =3D ParseFieldValue(Item)[0] + + if type(ItemValue) =3D=3D type(''): + ItemValue =3D int(ItemValue, 16) if ItemValue.= startswith('0x') else int(ItemValue) + + TmpValue =3D (ItemValue << (Size * 8)) | TmpValue + Size =3D Size + ItemSize + else: + TmpValue, Size =3D ParseFieldValue(PcdValue) + if type(TmpValue) =3D=3D type(''): + TmpValue =3D int(TmpValue) + else: + PcdValue =3D '0x%0{}X'.format(Size) % (TmpValue) + if TmpValue < 0: + raise BadExpression('Type %s PCD Value is negative' %= self.PcdType) + if self.PcdType =3D=3D 'UINT8' and Size > 1: + raise BadExpression('Type %s PCD Value Size is Larger = than 1 byte' % self.PcdType) + if self.PcdType =3D=3D 'UINT16' and Size > 2: + raise BadExpression('Type %s PCD Value Size is Larger = than 2 byte' % self.PcdType) + if self.PcdType =3D=3D 'UINT32' and Size > 4: + raise BadExpression('Type %s PCD Value Size is Larger = than 4 byte' % self.PcdType) + if self.PcdType =3D=3D 'UINT64' and Size > 8: + raise BadExpression('Type %s PCD Value Size is Larger = than 8 byte' % self.PcdType) + if self.PcdType in ['VOID*']: + try: + TmpValue =3D long(PcdValue) + TmpList =3D [] + if TmpValue.bit_length() =3D=3D 0: + PcdValue =3D '{0x00}' else: - LabelDict =3D {} - ReLabel =3D re.compile('LABEL\((\w+)\)') - ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') - for Index, Item in enumerate(ListItem): - # for LABEL parse - Item =3D Item.strip() + for I in range((TmpValue.bit_length() + 7) / 8): + TmpList.append('0x%02x' % ((TmpValue >> I * 8)= & 0xff)) + PcdValue =3D '{' + ', '.join(TmpList) + '}' + except: + if PcdValue.strip().startswith('{'): + PcdValue =3D PcdValue.strip()[1:-1].strip() + Size =3D 0 + ValueStr =3D '' + TokenSpaceGuidName =3D '' + if PcdValue.startswith('GUID') and PcdValue.endswi= th(')'): try: - LabelList =3D ReLabel.findall(Item) - for Label in LabelList: - if Label not in LabelDict.keys(): - LabelDict[Label] =3D str(Index) - Item =3D ReLabel.sub('', Item) + TokenSpaceGuidName =3D re.search('GUID\((\= w+)\)', PcdValue).group(1) except: pass - try: - OffsetList =3D ReOffset.findall(Item) - except: - pass - for Offset in OffsetList: - if Offset in LabelDict.keys(): - Re =3D re.compile('OFFSET_OF\(%s\)'% O= ffset) - Item =3D Re.sub(LabelDict[Offset], Ite= m) - else: - raise BadExpression('%s not defined be= fore use' % Offset) - if Item.startswith('UINT16'): - ItemSize =3D 2 - elif Item.startswith('UINT32'): - ItemSize =3D 4 - elif Item.startswith('UINT64'): - ItemSize =3D 8 - else: - ItemSize =3D 0 - TmpValue =3D ValueExpressionEx(Item, self.PcdT= ype, self._Symb)(True) - Item =3D '0x%x' % TmpValue if type(TmpValue) != =3D type('') else TmpValue - if ItemSize =3D=3D 0: - ItemValue, ItemSize =3D ParseFieldValue(It= em) - else: - ItemValue =3D ParseFieldValue(Item)[0] - for I in range(0, ItemSize): - ValueStr +=3D '0x%02X' % (int(ItemValue) &= 255) - ItemValue >>=3D 8 + if TokenSpaceGuidName and TokenSpaceGuidName i= n self._Symb: + PcdValue =3D 'GUID(' + self._Symb[TokenSpa= ceGuidName] + ')' + elif TokenSpaceGuidName: + raise BadExpression('%s not found in DEC f= ile' % TokenSpaceGuidName) + + ListItem, Size =3D ParseFieldValue(PcdValue) + elif PcdValue.startswith('DEVICE_PATH') and PcdVal= ue.endswith(')'): + ListItem, Size =3D ParseFieldValue(PcdValue) + else: + ListItem =3D PcdValue.split(',') + + if type(ListItem) =3D=3D type(0) or type(ListItem)= =3D=3D type(0L): + for Index in range(0, Size): + ValueStr +=3D '0x%02X' % (int(ListItem) & = 255) + ListItem >>=3D 8 ValueStr +=3D ', ' - Size +=3D ItemSize - - if Size > 0: - PcdValue =3D '{' + ValueStr[:-2] + '}' + PcdValue =3D '{' + ValueStr[:-2] + '}' + elif type(ListItem) =3D=3D type(''): + if ListItem.startswith('{') and ListItem.endsw= ith('}'): + PcdValue =3D ListItem + else: + LabelDict =3D {} + ReLabel =3D re.compile('LABEL\((\w+)\)') + ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') + for Index, Item in enumerate(ListItem): + # for LABEL parse + Item =3D Item.strip() + try: + LabelList =3D ReLabel.findall(Item) + for Label in LabelList: + if Label not in LabelDict.keys(): + LabelDict[Label] =3D str(Index) + Item =3D ReLabel.sub('', Item) + except: + pass + try: + OffsetList =3D ReOffset.findall(Item) + except: + pass + for Offset in OffsetList: + if Offset in LabelDict.keys(): + Re =3D re.compile('OFFSET_OF\(%s\)= '% Offset) + Item =3D Re.sub(LabelDict[Offset],= Item) + else: + raise BadExpression('%s not define= d before use' % Offset) + ValueType =3D "" + if Item.startswith('UINT16'): + ItemSize =3D 1 + ValueType =3D "UINT8" + elif Item.startswith('UINT16'): + ItemSize =3D 2 + ValueType =3D "UINT16" + elif Item.startswith('UINT32'): + ItemSize =3D 4 + elif Item.startswith('UINT64'): + ItemSize =3D 8 + else: + ItemSize =3D 0 + if ValueType: + TmpValue =3D ValueExpressionEx(Item, V= alueType, self._Symb)(True) + else: + TmpValue =3D ValueExpressionEx(Item, s= elf.PcdType, self._Symb)(True) + Item =3D '0x%x' % TmpValue if type(TmpValu= e) !=3D type('') else TmpValue + if ItemSize =3D=3D 0: + ItemValue, ItemSize =3D ParseFieldValu= e(Item) + else: + ItemValue =3D ParseFieldValue(Item)[0] + for I in range(0, ItemSize): + ValueStr +=3D '0x%02X' % (int(ItemValu= e) & 255) + ItemValue >>=3D 8 + ValueStr +=3D ', ' + Size +=3D ItemSize + + if Size > 0: + PcdValue =3D '{' + ValueStr[:-2] + '}' + if PcdValue =3D=3D 'True': + PcdValue =3D '1' + if PcdValue =3D=3D 'False': + PcdValue =3D '0' if RealValue: return PcdValue =20 if __name__ =3D=3D '__main__': pass diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index f30d3f7..25b2377 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -829,11 +829,17 @@ class DscBuildData(PlatformBuildClassObject): try: ValueList[Index] =3D ValueExpression(ValueList[Index], Glo= balData.gPlatformPcds)(True) except WrnExpression, Value: ValueList[Index] =3D Value.result except BadExpression, Value: - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=3Dse= lf.MetaFile, Line=3Dself._LineIndex + 1) + DatumType =3D self._DecPcds[PcdCName, TokenSpaceGuid].Datu= mType + try: + ValueList[Index] =3D ValueExpressionEx(ValueList[Index= ], DatumType, self._GuidDict)(True) + except BadExpression, Value: + EdkLogger.error('Parser', FORMAT_INVALID, Value, File= =3Dself.MetaFile, Line=3DLineNo, + ExtraData=3D"PCD [%s.%s] Value \"%s\" = " % ( + TokenSpaceGuid, PcdCName, ValueList[In= dex])) except EvaluationException, Excpt: if hasattr(Excpt, 'Pcd'): if Excpt.Pcd in GlobalData.gPlatformOtherPcds: EdkLogger.error('Parser', FORMAT_INVALID, "Cannot = use this PCD (%s) in an expression as" " it must be defined in a [PcdsFix= edAtBuild] or [PcdsFeatureFlag] section" @@ -843,17 +849,16 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('Parser', FORMAT_INVALID, "PCD (%s= ) is not defined in DSC file" % Excpt.Pcd, File=3Dself.MetaFile, Line=3DLineN= o) else: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid exp= ression: %s" % str(Excpt), File=3Dself.MetaFile, Line=3DLineNo) + if ValueList[Index] =3D=3D 'True': + ValueList[Index] =3D '1' + if ValueList[Index] =3D=3D 'False': + ValueList[Index] =3D '0' + if ValueList[Index]: - DatumType =3D self._DecPcds[PcdCName, TokenSpaceGuid].DatumType - try: - ValueList[Index] =3D ValueExpressionEx(ValueList[Index], D= atumType, self._GuidDict)(True) - except BadExpression, Value: - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=3Dse= lf.MetaFile, Line=3DLineNo, - ExtraData=3D"PCD [%s.%s] Value \"%s\" " % = (TokenSpaceGuid, PcdCName, ValueList[Index])) Valid, ErrStr =3D CheckPcdDatum(self._DecPcds[PcdCName, TokenS= paceGuid].DatumType, ValueList[Index]) if not Valid: EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=3Dse= lf.MetaFile, Line=3DLineNo, ExtraData=3D"%s.%s" % (TokenSpaceGuid, Pcd= CName)) if PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX= _DEFAULT): diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index 8f4b5e5..4ee129c 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1988,18 +1988,10 @@ class DecParser(MetaFileParser): File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) =20 PcdValue =3D ValueList[0] if PcdValue: try: - ValueList[0] =3D ValueExpression(PcdValue, self._AllPc= dDict)(True) - except WrnExpression, Value: - ValueList[0] =3D Value.result - except BadExpression, Value: - EdkLogger.error('Parser', FORMAT_INVALID, Value, File= =3Dself.MetaFile, Line=3Dself._LineIndex + 1) - - if ValueList[0]: - try: ValueList[0] =3D ValueExpressionEx(ValueList[0], Value= List[1], self._GuidDict)(True) except BadExpression, Value: EdkLogger.error('Parser', FORMAT_INVALID, Value, Extra= Data=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) # check format of default value against the datum type IsValid, Cause =3D CheckPcdDatum(ValueList[1], ValueList[0]) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index f2a6e6d..53d0039 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -35,19 +35,20 @@ from Common.Misc import GuidStructureByteArrayToGuidStr= ing from Common.Misc import GuidStructureStringToGuidString from Common.InfClassObject import gComponentType2ModuleType from Common.BuildToolError import FILE_WRITE_FAILURE from Common.BuildToolError import CODE_ERROR from Common.BuildToolError import COMMAND_FAILURE +from Common.BuildToolError import FORMAT_INVALID from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws import Common.GlobalData as GlobalData from AutoGen.AutoGen import ModuleAutoGen from Common.Misc import PathClass from Common.String import NormPath from Common.DataType import * import collections -from Common.Expression import ValueExpressionEx +from Common.Expression import * =20 ## Pattern to extract contents in EDK DXS files gDxsDependencyPattern =3D re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END"= , re.DOTALL) =20 ## Pattern to find total FV total size, occupied size in flash report inte= rmediate file @@ -953,11 +954,15 @@ class PcdReport(object): DecDefaultValue =3D self.DecPcdDefault.get((Pcd.TokenC= Name, Pcd.TokenSpaceGuidCName, DecType)) DscDefaultValue =3D self.DscPcdDefault.get((Pcd.TokenC= Name, Pcd.TokenSpaceGuidCName)) DscDefaultValBak =3D DscDefaultValue DscDefaultValue =3D self.FdfPcdSet.get((Pcd.TokenCName= , Key), DscDefaultValue) if DscDefaultValue !=3D DscDefaultValBak: - DscDefaultValue =3D ValueExpressionEx(DscDefaultVa= lue, Pcd.DatumType, self._GuidDict)(True) + try: + DscDefaultValue =3D ValueExpressionEx(DscDefau= ltValue, Pcd.DatumType, self._GuidDict)(True) + except BadExpression, Value: + EdkLogger.error('BuildReport', FORMAT_INVALID,= "PCD Value: %s, Type: %s" %(DscDefaultValue, Pcd.DatumType)) + InfDefaultValue =3D None =20 PcdValue =3D DecDefaultValue if DscDefaultValue: PcdValue =3D DscDefaultValue --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel