From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 1D3D42215BD85 for ; Mon, 29 Jan 2018 18:45:23 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2018 18:50:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,433,1511856000"; d="scan'208";a="197216264" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga005.jf.intel.com with ESMTP; 29 Jan 2018 18:50:57 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 29 Jan 2018 18:50:57 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 29 Jan 2018 18:50:56 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.130]) with mapi id 14.03.0319.002; Tue, 30 Jan 2018 10:50:55 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" Thread-Topic: [PATCH V2] BaseTools: Enhance parse performance by optimize ValueExpressionEx Thread-Index: AQHTmWyxfyGKC3LNYEmiQwneRtsIRaOLt2ZQ Date: Tue, 30 Jan 2018 02:50:54 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1B92DF@SHSMSX104.ccr.corp.intel.com> References: <1517277013-4220-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1517277013-4220-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Tue, 30 Jan 2018 02:45:24 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Zhu, Yonghong >Sent: Tuesday, January 30, 2018 9:50 AM >To: edk2-devel@lists.01.org >Cc: Feng, YunhuaX ; Gao, Liming > >Subject: [PATCH V2] BaseTools: Enhance parse performance by optimize >ValueExpressionEx > >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 >--- > 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 > > # 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.DefaultValue, 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.Defaul= tValue, >ToPcd.DatumType, _GuidDict)(True) >+ ToPcd.DefaultValue =3D ValueExpressionEx(ToPcd.Defaul= tValue, >ToPcd.DatumType, self._GuidDict)(True) > except BadExpression, Value: > EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s= ] Value >"%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, >ToPcd.DefaultValue, Value), > File=3Dself.MetaFile) >diff --git a/BaseTools/Source/Python/Common/Expression.py >b/BaseTools/Source/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 = value. > # >-# 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 B= SD >License > # which accompanies this distribution. The full text of the license ma= y 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().ends= with('}'): >- self._Expr =3D Expression >- self._NoProcess =3D True > > 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('{') = and >Token.endswith('}') and self._Idx >=3D self._Len: >- return self._Expr > except BadExpression: > pass >+ if type(Token) =3D=3D type('') and Token.startswith('{') and >Token.endswith('}') and self._Idx >=3D self._Len: >+ if len(Token) !=3D len(self._Expr.replace(' ', '')): >+ raise BadExpression >+ return self._Expr > > 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): > > 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 > >@@ -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("'") = or >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.startsw= ith('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', 'BOOLE= AN']: >- 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._= 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.sta= rtswith('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' % se= lf.PcdType) >- if self.PcdType =3D=3D 'UINT8' and Size > 1: >- raise BadExpression('Type %s PCD Value Size is Larger tha= n 1 byte' % >self.PcdType) >- if self.PcdType =3D=3D 'UINT16' and Size > 2: >- raise BadExpression('Type %s PCD Value Size is Larger tha= n 2 byte' % >self.PcdType) >- if self.PcdType =3D=3D 'UINT32' and Size > 4: >- raise BadExpression('Type %s PCD Value Size is Larger tha= n 4 byte' % >self.PcdType) >- if self.PcdType =3D=3D 'UINT64' and Size > 8: >- raise BadExpression('Type %s PCD Value Size is Larger tha= n 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) & = 0xff)) >- 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', 'B= OOLEAN']: >+ 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 >self._Symb: >- PcdValue =3D 'GUID(' + self._Symb[TokenSpaceG= uidName] + ')' >- elif TokenSpaceGuidName: >- raise BadExpression('%s not found in DEC file= ' % >TokenSpaceGuidName) >- >- ListItem, Size =3D ParseFieldValue(PcdValue) >- elif PcdValue.startswith('DEVICE_PATH') and >PcdValue.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 ', ' >- 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, se= lf._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.endsw= ith(')'): > 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\)'% = Offset) >- Item =3D Re.sub(LabelDict[Offset], It= em) >- else: >- raise BadExpression('%s not defined b= efore 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.Pcd= Type, >self._Symb)(True) >- Item =3D '0x%x' % TmpValue if type(TmpValue) = !=3D type('') else >TmpValue >- if ItemSize =3D=3D 0: >- ItemValue, ItemSize =3D ParseFieldValue(I= tem) >- 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 = in >self._Symb: >+ PcdValue =3D 'GUID(' + self._Symb[TokenSp= aceGuidName] + ')' >+ elif TokenSpaceGuidName: >+ raise BadExpression('%s not found in DEC = file' % >TokenSpaceGuidName) >+ >+ ListItem, Size =3D ParseFieldValue(PcdValue) >+ elif PcdValue.startswith('DEVICE_PATH') and >PcdValue.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.ends= with('}'): >+ 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(Inde= x) >+ 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 defin= ed 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, = ValueType, >self._Symb)(True) >+ else: >+ TmpValue =3D ValueExpressionEx(Item, = self.PcdType, >self._Symb)(True) >+ Item =3D '0x%x' % TmpValue if type(TmpVal= ue) !=3D type('') else >TmpValue >+ if ItemSize =3D=3D 0: >+ ItemValue, ItemSize =3D ParseFieldVal= ue(Item) >+ else: >+ ItemValue =3D ParseFieldValue(Item)[0= ] >+ for I in range(0, ItemSize): >+ ValueStr +=3D '0x%02X' % (int(ItemVal= ue) & 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 Size > 0: >- PcdValue =3D '{' + ValueStr[:-2] + '}' > if RealValue: > return PcdValue > >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 = incorrect.", >File=3Dself.MetaFile, Line=3DLineNo, > ExtraData=3D"%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 =3D self._DecPcds[PcdCName, TokenSpaceGuid].DatumTy= pe > try: >- ValueList[Index] =3D ValueExpression(ValueList[Index], >GlobalData.gPlatformPcds)(True) >- except WrnExpression, Value: >- ValueList[Index] =3D Value.result >+ ValueList[Index] =3D ValueExpressionEx(ValueList[Index], = DatumType, >self._GuidDict)(True) > except BadExpression, Value: >- EdkLogger.error('Parser', FORMAT_INVALID, Value, >File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) >+ EdkLogger.error('Parser', FORMAT_INVALID, Value, >File=3Dself.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 >expression: %s" % str(Excpt), > File=3Dself.MetaFile, Line=3DLineNo) >+ > if ValueList[Index]: >- DatumType =3D self._DecPcds[PcdCName, TokenSpaceGuid].DatumTy= pe >- 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[Index])) > Valid, ErrStr =3D CheckPcdDatum(self._DecPcds[PcdCName, >TokenSpaceGuid].DatumType, ValueList[Index]) > if not Valid: > EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=3Ds= elf.MetaFile, >Line=3DLineNo, >@@ -860,6 +856,9 @@ class DscBuildData(PlatformBuildClassObject): > if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.stri= p() !=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 > > 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] =3D ValueExpression(PcdValue, self._Macros= )(True) > except WrnExpression, Value: > ValList[Index] =3D Value.result >+ except: >+ pass > > 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._AllP= cdDict)(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], Valu= eList[1], >self._GuidDict)(True) > except BadExpression, Value: > EdkLogger.error('Parser', FORMAT_INVALID, Value, >ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineInde= x + 1) >diff --git a/BaseTools/Source/Python/build/BuildReport.py >b/BaseTools/Source/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 >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 >@@ -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 * > > ## 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.TokenCNam= e, Key), >DscDefaultValue) > if DscDefaultValue !=3D DscDefaultValBak: >- DscDefaultValue =3D ValueExpressionEx(DscDefaultV= alue, >Pcd.DatumType, self._GuidDict)(True) >+ try: >+ DscDefaultValue =3D ValueExpressionEx(DscDefa= ultValue, >Pcd.DatumType, self._GuidDict)(True) >+ except BadExpression, Value: >+ EdkLogger.error('BuildReport', FORMAT_INVALID= , "PCD >Value: %s, Type: %s" %(DscDefaultValue, Pcd.DatumType)) >+ > InfDefaultValue =3D None > > PcdValue =3D DecDefaultValue >-- >2.12.2.windows.2