From nobody Mon Dec 23 09:34:02 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 1517277020713966.9354948788426; Mon, 29 Jan 2018 17:50:20 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 996772233379F; Mon, 29 Jan 2018 17:44:44 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 6B42A221786A6 for ; Mon, 29 Jan 2018 17:44:43 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2018 17:50:17 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga005.jf.intel.com with ESMTP; 29 Jan 2018 17:50:16 -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.20; helo=mga02.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,433,1511856000"; d="scan'208";a="197206981" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Tue, 30 Jan 2018 09:50:13 +0800 Message-Id: <1517277013-4220-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [PATCH V2] 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 V2: Handle the case like {0} as value for UINT8/UINT16 type 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: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 16 +- BaseTools/Source/Python/Common/Expression.py | 306 +++++++++++------= ---- BaseTools/Source/Python/Workspace/DscBuildData.py | 21 +- .../Source/Python/Workspace/MetaFileParser.py | 10 +- BaseTools/Source/Python/build/BuildReport.py | 9 +- 5 files changed, 184 insertions(+), 178 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index ab178c9a4a..1cf50e872f 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1245,6 +1245,7 @@ class PlatformAutoGen(AutoGen): # 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 @@ -2463,22 +2464,9 @@ class PlatformAutoGen(AutoGen): 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) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 55fa06d414..fcd1154c7c 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -1,7 +1,7 @@ ## @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 @@ -251,9 +251,6 @@ class ValueExpression(object): 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, @@ -293,13 +290,15 @@ class ValueExpression(object): 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 '' @@ -454,13 +453,20 @@ class ValueExpression(object): Radix =3D 10 if self._Token.lower()[0:2] =3D=3D '0x' and len(self._Token) > 2: Radix =3D 16 - if self._Token.startswith('"') or self._Token.startswith("'")\ - or self._Token.startswith("L'") or self._Token.startswith('L"'= ): + if self._Token.startswith('"') or self._Token.startswith('L"'): + Flag =3D 0 + for Index in range(len(self._Token)): + if self._Token[Index] in ['"']: + Flag +=3D 1 + if Flag =3D=3D 2 and self._Token.endswith('"'): + self._Token =3D ParseFieldValue(self._Token)[0] + return True + if self._Token.startswith("'") or self._Token.startswith("L'"): Flag =3D 0 for Index in range(len(self._Token)): - if self._Token[Index] in ['"', "'"]: + if self._Token[Index] in ["'"]: Flag +=3D 1 - if Flag =3D=3D 2: + if Flag =3D=3D 2 and self._Token.endswith("'"): self._Token =3D ParseFieldValue(self._Token)[0] return True try: @@ -593,11 +599,10 @@ class ValueExpression(object): =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 @@ -734,145 +739,160 @@ class ValueExpressionEx(ValueExpression): PcdValue =3D self.PcdValue try: PcdValue =3D ValueExpression.__call__(self, RealValue, Depth) + if self.PcdType =3D=3D 'VOID*' and (PcdValue.startswith("'") o= r PcdValue.startswith("L'")): + raise BadExpression + elif self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', '= BOOLEAN'] and (PcdValue.startswith("'") + = or PcdValue.startswith( + '"') or PcdValue.startswith("L'") or PcdValue.startswi= th('L"') or PcdValue.startswith('{')): + raise BadExpression 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 + 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' =20 - if Size > 0: - PcdValue =3D '{' + ValueStr[:-2] + '}' if RealValue: return PcdValue =20 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] =3D=3D '-1': EdkLogger.error('build', FORMAT_INVALID, "Pcd format i= ncorrect.", File=3Dself.MetaFile, Line=3DLineNo, ExtraData=3D"%s.%s|%s" % (TokenSpaceGuid, = PcdCName, Setting)) - if ValueList[Index] and PcdType not in [MODEL_PCD_FEATURE_FLAG, MO= DEL_PCD_FIXED_AT_BUILD]: + if ValueList[Index]: + DatumType =3D self._DecPcds[PcdCName, TokenSpaceGuid].DatumType try: - ValueList[Index] =3D ValueExpression(ValueList[Index], Glo= balData.gPlatformPcds)(True) - except WrnExpression, Value: - ValueList[Index] =3D Value.result + 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=3Dself._LineIndex + 1) + EdkLogger.error('Parser', FORMAT_INVALID, Value, File=3Dse= lf.MetaFile, Line=3DLineNo, + ExtraData=3D"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 exp= ression: %s" % str(Excpt), File=3Dself.MetaFile, Line=3DLineNo) + 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, @@ -860,6 +856,9 @@ class DscBuildData(PlatformBuildClassObject): if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.strip= () !=3D ValueList[1].strip(): EdkLogger.error('build', FORMAT_INVALID, ErrStr , File= =3Dself.MetaFile, Line=3DLineNo, ExtraData=3D"%s.%s|%s" % (TokenSpaceGuid, = PcdCName, Setting)) + if (TokenSpaceGuid + '.' + PcdCName) in GlobalData.gPlatformPcds: + if GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] != =3D ValueList[Index]: + GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] = =3D ValueList[Index] return ValueList =20 def _FilterPcdBySkuUsage(self,Pcds): diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/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] =3D ValueExpression(PcdValue, self._Macros)= (True) except WrnExpression, Value: ValList[Index] =3D Value.result + except: + pass =20 if ValList[Index] =3D=3D 'True': ValList[Index] =3D '1' @@ -1990,14 +1992,6 @@ class DecParser(MetaFileParser): 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) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index f2a6e6d87e..53d0039c51 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -37,6 +37,7 @@ from Common.InfClassObject import gComponentType2ModuleTy= pe 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 @@ -45,7 +46,7 @@ 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) @@ -955,7 +956,11 @@ class PcdReport(object): 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 --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel