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.24; helo=mga09.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 28BE32222C246 for ; Sun, 28 Jan 2018 18:27:36 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2018 18:33:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,429,1511856000"; d="scan'208";a="26188452" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 28 Jan 2018 18:33:09 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 28 Jan 2018 18:33:09 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 28 Jan 2018 18:33:09 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.130]) with mapi id 14.03.0319.002; Mon, 29 Jan 2018 10:33:07 +0800 From: "Zhu, Yonghong" To: "'afish@apple.com'" CC: "edk2-devel@lists.01.org" , "Feng, YunhuaX" , "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [edk2] [Patch] BaseTools: Enhance parse performance by optimize ValueExpressionEx Thread-Index: AQHTlsK1OKP0KtaBeUGZv/4bpr6pxqOGAeeAgAGfkEA= Date: Mon, 29 Jan 2018 02:33:06 +0000 Message-ID: References: <1516984085-9928-1-git-send-email-yonghong.zhu@intel.com> <2212F325-CD05-45A1-9F64-16FDFCF141B2@apple.com> In-Reply-To: <2212F325-CD05-45A1-9F64-16FDFCF141B2@apple.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] 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: Mon, 29 Jan 2018 02:27:37 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable The bad performance was caused by newly PCD flexible value format support p= atch, eg: { 'AB', L'AB', 0x1, L"AB", UINT16(8)} Original tool doesn't parse byte array PCD value format and let complier to= do it, while after we add this new flexible value format support, BaseTool= parse its format which cause 10s to 85s if the platform has > 6000 bytes o= f byte array Pcd, even it use original simplest format eg: {0x1, 0x1, 0x1} So this patch do the enhancement from 85s to 15s if the byte array Pcd that= use original simplest format, and reduce the impact if user doesn't use th= ose new Pcd format. Best Regards, Zhu Yonghong -----Original Message----- From: afish@apple.com [mailto:afish@apple.com]=20 Sent: Saturday, January 27, 2018 3:21 AM To: Zhu, Yonghong Cc: edk2-devel@lists.01.org; Feng, YunhuaX ; Gao, L= iming Subject: Re: [edk2] [Patch] BaseTools: Enhance parse performance by optimiz= e ValueExpressionEx Any data on the performance improvement? Thanks, Andrew Fish > On Jan 26, 2018, at 8:28 AM, Yonghong Zhu wrote: >=20 > From: Yunhua Feng >=20 > Optimize ValueExpressionEx function to enhance meta-data file parse=20 > performance. >=20 > 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(-) >=20 > diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py=20 > 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)(Tru= e) > - 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.Def= aultValue, 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.Defau= ltValue, ToPcd.DatumType, _GuidDict)(True) > + ToPcd.DefaultValue =3D=20 > + ValueExpressionEx(ToPcd.DefaultValue, ToPcd.DatumType,=20 > + self._GuidDict)(True) > except BadExpression, Value: > EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s= ] Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defa= ultValue, Value), > File=3Dself.MetaFile) >=20 > # check the validation of datum diff --git=20 > a/BaseTools/Source/Python/Common/Expression.py=20 > b/BaseTools/Source/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 = value. > # > -# Copyright (c) 2011 - 2017, Intel Corporation. All rights=20 > reserved.
> +# Copyright (c) 2011 - 2018, Intel Corporation. All rights=20 > +reserved.
> # This program and the accompanying materials # are licensed and made=20 > available under the terms and conditions of the BSD License > # which accompanies this distribution. The full text of the license ma= y 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().end= swith('}'): > - 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('{')= 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 >=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', 'BOOL= EAN']: > - 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.st= artswith('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' % s= elf.PcdType) > - if self.PcdType =3D=3D 'UINT8' and Size > 1: > - raise BadExpression('Type %s PCD Value Size is Larger th= an 1 byte' % self.PcdType) > - if self.PcdType =3D=3D 'UINT16' and Size > 2: > - raise BadExpression('Type %s PCD Value Size is Larger th= an 2 byte' % self.PcdType) > - if self.PcdType =3D=3D 'UINT32' and Size > 4: > - raise BadExpression('Type %s PCD Value Size is Larger th= an 4 byte' % self.PcdType) > - if self.PcdType =3D=3D 'UINT64' and Size > 8: > - raise BadExpression('Type %s PCD Value Size is Larger th= an 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', '= BOOLEAN']: > + PcdValue =3D PcdValue.strip() > + if type(PcdValue) =3D=3D type('') and PcdValue.startswit= h('{') 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[TokenSpace= GuidName] + ')' > - elif TokenSpaceGuidName: > - raise BadExpression('%s not found in DEC fil= e' % 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) & 25= 5) > - ListItem >>=3D 8 > - ValueStr +=3D ', ' > - PcdValue =3D '{' + ValueStr[:-2] + '}' > - elif type(ListItem) =3D=3D type(''): > - if ListItem.startswith('{') and ListItem.endswit= h('}'): > - 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,=20 > + 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=20 > + ItemValue.startswith('0x') else int(ItemValue) > + > + TmpValue =3D (ItemValue << (Size * 8)) | TmpValu= e > + 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 Large= r than 1 byte' % self.PcdType) > + if self.PcdType =3D=3D 'UINT16' and Size > 2: > + raise BadExpression('Type %s PCD Value Size is Large= r than 2 byte' % self.PcdType) > + if self.PcdType =3D=3D 'UINT32' and Size > 4: > + raise BadExpression('Type %s PCD Value Size is Large= r than 4 byte' % self.PcdType) > + if self.PcdType =3D=3D 'UINT64' and Size > 8: > + raise BadExpression('Type %s PCD Value Size is Large= r 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.ends= with(')'): > 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=20 > + 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], I= tem) > - else: > - raise BadExpression('%s not defined = before 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.Pc= dType, self._Symb)(True) > - Item =3D '0x%x' % TmpValue if type(TmpValue)= !=3D type('') else TmpValue > - if ItemSize =3D=3D 0: > - ItemValue, ItemSize =3D ParseFieldValue(= Item) > - 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[TokenS= paceGuidName] + ')' > + elif TokenSpaceGuidName: > + raise BadExpression('%s not found in=20 > + DEC file' % TokenSpaceGuidName) > + > + ListItem, Size =3D ParseFieldValue(PcdValue) > + elif PcdValue.startswith('DEVICE_PATH') and PcdV= alue.endswith(')'): > + ListItem, Size =3D ParseFieldValue(PcdValue) > + else: > + ListItem =3D PcdValue.split(',') > + > + if type(ListItem) =3D=3D type(0) or type(ListIte= m) =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.end= swith('}'): > + 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(Ind= ex) > + 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 defi= ned 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(TmpVa= lue) !=3D type('') else TmpValue > + if ItemSize =3D=3D 0: > + ItemValue, ItemSize =3D ParseFieldVa= lue(Item) > + else: > + ItemValue =3D ParseFieldValue(Item)[= 0] > + for I in range(0, ItemSize): > + ValueStr +=3D '0x%02X' % (int(ItemVa= lue) & 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=20 > 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], Gl= obalData.gPlatformPcds)(True) > except WrnExpression, Value: > ValueList[Index] =3D Value.result > except BadExpression, Value: > - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=3D= self.MetaFile, Line=3Dself._LineIndex + 1) > + DatumType =3D self._DecPcds[PcdCName, TokenSpaceGuid].Da= tumType > + try: > + ValueList[Index] =3D ValueExpressionEx(ValueList[Ind= ex], DatumType, self._GuidDict)(True) > + except BadExpression, Value: > + EdkLogger.error('Parser', FORMAT_INVALID, Value, Fil= e=3Dself.MetaFile, Line=3DLineNo, > + ExtraData=3D"PCD [%s.%s] Value \"%s\= " " % ( > + TokenSpaceGuid, PcdCName,=20 > + ValueList[Index])) > 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 [PcdsFi= xedAtBuild] 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=3DLine= No) > else: > EdkLogger.error('Parser', FORMAT_INVALID, "Invalid ex= pression: %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].DatumT= ype > - try: > - ValueList[Index] =3D ValueExpressionEx(ValueList[Index],= DatumType, self._GuidDict)(True) > - except BadExpression, Value: > - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=3D= self.MetaFile, Line=3DLineNo, > - ExtraData=3D"PCD [%s.%s] Value \"%s\" " = % (TokenSpaceGuid, PcdCName, ValueList[Index])) > Valid, ErrStr =3D CheckPcdDatum(self._DecPcds[PcdCName, Token= SpaceGuid].DatumType, ValueList[Index]) > if not Valid: > EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=3Ds= elf.MetaFile, Line=3DLineNo, > ExtraData=3D"%s.%s" % (TokenSpaceGuid, Pc= dCName)) > if PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_E= X_DEFAULT): > diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py=20 > b/BaseTools/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,=20 > Line=3Dself._LineIndex + 1) >=20 > PcdValue =3D ValueList[0] > if PcdValue: > try: > - ValueList[0] =3D ValueExpression(PcdValue, self._All= PcdDict)(True) > - except WrnExpression, Value: > - ValueList[0] =3D Value.result > - except BadExpression, Value: > - EdkLogger.error('Parser', FORMAT_INVALID, Value, Fil= e=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, Extr= aData=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])= =20 > diff --git a/BaseTools/Source/Python/build/BuildReport.py=20 > b/BaseTools/Source/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=20 > GuidStructureByteArrayToGuidString > from Common.Misc import GuidStructureStringToGuidString from=20 > Common.InfClassObject import gComponentType2ModuleType from=20 > Common.BuildToolError import FILE_WRITE_FAILURE from=20 > Common.BuildToolError import CODE_ERROR from Common.BuildToolError=20 > import COMMAND_FAILURE > +from Common.BuildToolError import FORMAT_INVALID > from Common.LongFilePathSupport import OpenLongFilePath as open from=20 > Common.MultipleWorkspace import MultipleWorkspace as mws import=20 > Common.GlobalData as GlobalData from AutoGen.AutoGen import=20 > ModuleAutoGen from Common.Misc import PathClass from Common.String=20 > import NormPath from Common.DataType import * import collections -from=20 > Common.Expression import ValueExpressionEx > +from Common.Expression import * >=20 > ## Pattern to extract contents in EDK DXS files gDxsDependencyPattern=20 > =3D re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL) >=20 > ## Pattern to find total FV total size, occupied size in flash report=20 > intermediate file @@ -953,11 +954,15 @@ class PcdReport(object): > DecDefaultValue =3D self.DecPcdDefault.get((Pcd.Token= CName, Pcd.TokenSpaceGuidCName, DecType)) > DscDefaultValue =3D self.DscPcdDefault.get((Pcd.Token= CName, Pcd.TokenSpaceGuidCName)) > DscDefaultValBak =3D DscDefaultValue > DscDefaultValue =3D self.FdfPcdSet.get((Pcd.TokenCNam= e, Key), DscDefaultValue) > if DscDefaultValue !=3D DscDefaultValBak: > - DscDefaultValue =3D ValueExpressionEx(DscDefault= Value, Pcd.DatumType, self._GuidDict)(True) > + try: > + DscDefaultValue =3D ValueExpressionEx(DscDef= aultValue, Pcd.DatumType, self._GuidDict)(True) > + except BadExpression, Value: > + EdkLogger.error('BuildReport',=20 > + FORMAT_INVALID, "PCD Value: %s, Type: %s" %(DscDefaultValue,=20 > + Pcd.DatumType)) > + > InfDefaultValue =3D None >=20 > PcdValue =3D DecDefaultValue > if DscDefaultValue: > PcdValue =3D DscDefaultValue > -- > 2.6.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel