From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.171.2.34; helo=mail-in24.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from mail-in24.apple.com (mail-out24.apple.com [17.171.2.34]) (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 EDA352222C23E for ; Fri, 26 Jan 2018 11:15:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1516994449; x=2380908049; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7vfzUHdeUJN1vTp5rpeJgPCUtxVUhPOXa0oIZvUzQ+o=; b=2b9W86eg5K2y7ZpI372/KGlfjGBSra4iP4X9iGyLkW+jnnRofawtyr+9NbLlOMMz xs19VJzFrlKU+JtZ/Ea59HzADyaVJHQlS3iZgcEAr+6FU5a6KG8cERO1P0gJaAKI sZnAC3+NJo8x0O0KAhF170COGZNyXrcNUs42far037q7I9+s4Od6qdGhO+lJPEpv VUaQNl3ux4eye1uYc2d8uId9qB8+vj0YSY/rDhfzyhVIPos/9omk+WkOf9b7moOn bDfUYKkJBKuNeTzeIUwLIFzwZD1+aURyYqKpazInQIuPdZGmjb5tBnXsHbEg0P/t KFg9XedJXvGh3XUXM/2g+Q==; Received: from relay6.apple.com (relay6.apple.com [17.128.113.90]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in24.apple.com (Apple Secure Mail Relay) with SMTP id E4.1F.10828.19F7B6A5; Fri, 26 Jan 2018 11:20:49 -0800 (PST) X-AuditID: 11ab0218-260a89e000002a4c-01-5a6b7f9182bc Received: from nwk-mmpp-sz09.apple.com (nwk-mmpp-sz09.apple.com [17.128.115.80]) by relay6.apple.com (Apple SCV relay) with SMTP id 48.1C.05652.19F7B6A5; Fri, 26 Jan 2018 11:20:49 -0800 (PST) MIME-version: 1.0 Received: from [17.235.51.134] by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.1.20180104 64bit (built Jan 4 2018)) with ESMTPSA id <0P3600524GENPA60@nwk-mmpp-sz09.apple.com>; Fri, 26 Jan 2018 11:20:49 -0800 (PST) Sender: afish@apple.com From: Andrew Fish In-reply-to: <1516984085-9928-1-git-send-email-yonghong.zhu@intel.com> Date: Fri, 26 Jan 2018 11:20:47 -0800 Cc: edk2-devel@lists.01.org, Yunhua Feng , Liming Gao Message-id: <2212F325-CD05-45A1-9F64-16FDFCF141B2@apple.com> References: <1516984085-9928-1-git-send-email-yonghong.zhu@intel.com> To: Yonghong Zhu X-Mailer: Apple Mail (2.3445.5.20) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsUi2FAYpTuxPjvKYMdUA4s9h44yW6y4t4Hd Yn9HmsX2JYfZHFg8Fu95yeTRPfsfSwBTFJdNSmpOZllqkb5dAlfG1sNXGAv6XzFWHN/Uyd7A OLeLsYuRk0NCwETi86wHLF2MXBxCAmuYJP71fmXuYuQAS+z6pwERP8gosWH1f2aQBl4BQYkf k++xgNQwC8hLHDwvCxJmFtCS+P6oFWrOV0aJZ6fOMYEkhAXEJd6d2cQMYSdIHO25ygJiswko S6yY/4EdxOYUcJOY0rMarIZFQFXizIKLjBBD0yROz2hgg9hrI3HpewtYr5CAq8ThBoi4iICm RMuNbnaIZ5Qkpn+/zQZyhITABDaJaWvbmSYwCs9CcvcshLtnIbl7ASPzKkbh3MTMHN3MPCMT vcSCgpxUveT83E2MoIBfzSSxg/HLa8NDjAIcjEo8vAkm2VFCrIllxZW5hxilOViUxHkjlbOi hATSE0tSs1NTC1KL4otKc1KLDzEycXBKNTDO/9pSEruR0z+nXMf2sYBddtuFh44Kj+zmff0k dWI3L3u4wutQJuWErESpTy8rGu5ks63OfBEtca72/IRdIeZHAoIuSm4OVbpQ6fB5cwLb49r3 yTJHFym/22bjviql/5Es7/O5zcVTK5tmewRz6z30OLW579WXlAKj+yEz/c60XPu3bHdwWZUS S3FGoqEWc1FxIgD+aJ5GWQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsUi2FAcoDuxPjvKYOEKHos9h44yW6y4t4Hd Yn9HmsX2JYfZHFg8Fu95yeTRPfsfSwBTFJdNSmpOZllqkb5dAlfG1sNXGAv6XzFWHN/Uyd7A OLeLsYuRg0NCwERi1z+NLkYuDiGBg4wSG1b/Z+5i5OTgFRCU+DH5HgtIDbOAvMTB87IgYWYB LYnvj1pZIOq/Mko8O3WOCSQhLCAu8e7MJmYIO0HiaM9VFhCbTUBZYsX8D+wgNqeAm8SUntVg NSwCqhJnFlxkhBiaJnF6RgMbxF4biUvfW8B6hQRcJQ43QMRFBDQlWm50g82REFCSmP79NtsE RoFZSE6dhXDqLCSnLmBkXsUoUJSak1hpppdYUJCTqpecn7uJERyehVE7GBuWWx1iFOBgVOLh 3WGWHSXEmlhWXJl7iFGCg1lJhNeMEyjEm5JYWZValB9fVJqTWnyIUZqDRUmcN/5GSpSQQHpi SWp2ampBahFMlomDU6qBceb0707Hs+atvJ3gf69qz61gMdHdVjvv//pcviiB/1B/ziXGSRPl P169senA4Y4zJxRP7ZrOUa93x8p7bYxSMGtcfhnPfD/xisTA9J72i+GWRRdVbexZ3RQmCwXa C7xb3Mj/W2Bjx2/P5+nC5xJt7/k9W9dwKN3hzSaR11Esuk8+SO5sdFvQpsRSnJFoqMVcVJwI AOgc0sBLAgAA 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: Fri, 26 Jan 2018 19:15:20 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Any data on the performance improvement? Thanks, Andrew Fish > On Jan 26, 2018, at 8:28 AM, Yonghong Zhu wrote: > > 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 = self.Workspace.FvTargetList > self.AllPcdList = [] > # get the original module/package/platform objects > self.BuildDatabase = Workspace.BuildDatabase > self.DscBuildDataObj = Workspace.Platform > + self._GuidDict = Workspace._GuidDict > > # flag indicating if the makefile/C-code file has been created or not > self.IsMakeFileCreated = False > self.IsCodeFileCreated = False > > @@ -2461,26 +2462,13 @@ class PlatformAutoGen(AutoGen): > if FromPcd.DatumType not in [None, '']: > ToPcd.DatumType = FromPcd.DatumType > if FromPcd.SkuInfoList not in [None, '', []]: > ToPcd.SkuInfoList = FromPcd.SkuInfoList > # Add Flexible PCD format parse > - PcdValue = ToPcd.DefaultValue > - if PcdValue: > - try: > - ToPcd.DefaultValue = ValueExpression(PcdValue)(True) > - except WrnExpression, Value: > - ToPcd.DefaultValue = Value.result > - except BadExpression, Value: > - EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.DefaultValue, Value), > - File=self.MetaFile) > if ToPcd.DefaultValue: > - _GuidDict = {} > - for Pkg in self.PackageList: > - Guids = Pkg.Guids > - _GuidDict.update(Guids) > try: > - ToPcd.DefaultValue = ValueExpressionEx(ToPcd.DefaultValue, ToPcd.DatumType, _GuidDict)(True) > + ToPcd.DefaultValue = ValueExpressionEx(ToPcd.DefaultValue, 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=self.MetaFile) > > # check the validation of datum > diff --git a/BaseTools/Source/Python/Common/Expression.py 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 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 BSD 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 = False > if type(Expression) != type(''): > self._Expr = Expression > self._NoProcess = True > return > - if Expression.strip().startswith('{') and Expression.strip().endswith('}'): > - self._Expr = Expression > - self._NoProcess = True > > self._Expr = ReplaceExprMacro(Expression.strip(), > SymbolTable, > SupportedInMacroList) > > @@ -291,17 +288,19 @@ class ValueExpression(object): > self._Expr = self._Expr.strip() > if RealValue and Depth == 0: > self._Token = self._Expr > if self.__IsNumberToken(): > return self._Expr > - > + Token = '' > try: > Token = self._GetToken() > - if type(Token) == type('') and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len: > - return self._Expr > except BadExpression: > pass > + if type(Token) == type('') and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len: > + if len(Token) != len(self._Expr.replace(' ', '')): > + raise BadExpression > + return self._Expr > > self._Idx = 0 > self._Token = '' > > Val = self._ConExpr() > @@ -591,15 +590,14 @@ class ValueExpression(object): > self._LiteralToken.endswith('}'): > return True > > if self.HexPattern.match(self._LiteralToken): > Token = self._LiteralToken[2:] > - Token = Token.lstrip('0') > if not Token: > self._LiteralToken = '0x0' > else: > - self._LiteralToken = '0x' + Token.lower() > + self._LiteralToken = '0x' + Token > return True > return False > > def _GetToken(self): > return self.__GetNList() > @@ -734,147 +732,155 @@ class ValueExpressionEx(ValueExpression): > PcdValue = self.PcdValue > try: > PcdValue = ValueExpression.__call__(self, RealValue, Depth) > except WrnExpression, Value: > PcdValue = Value.result > - > - if PcdValue == 'True': > - PcdValue = '1' > - if PcdValue == 'False': > - PcdValue = '0' > - if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']: > - PcdValue = PcdValue.strip() > - if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'): > - PcdValue = PcdValue[1:-1].split(',') > - if type(PcdValue) == type([]): > - TmpValue = 0 > - Size = 0 > - for Item in PcdValue: > - if Item.startswith('UINT16'): > - ItemSize = 2 > - elif Item.startswith('UINT32'): > - ItemSize = 4 > - elif Item.startswith('UINT64'): > - ItemSize = 8 > - else: > - ItemSize = 0 > - Item = ValueExpressionEx(Item, self.PcdType, self._Symb)(True) > - > - if ItemSize == 0: > - ItemValue, ItemSize = ParseFieldValue(Item) > - else: > - ItemValue = ParseFieldValue(Item)[0] > - > - if type(ItemValue) == type(''): > - ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue) > - > - TmpValue = (ItemValue << (Size * 8)) | TmpValue > - Size = Size + ItemSize > - else: > - TmpValue, Size = ParseFieldValue(PcdValue) > - if type(TmpValue) == type(''): > - TmpValue = int(TmpValue) > - else: > - PcdValue = '0x%0{}X'.format(Size) % (TmpValue) > - if TmpValue < 0: > - raise BadExpression('Type %s PCD Value is negative' % self.PcdType) > - if self.PcdType == 'UINT8' and Size > 1: > - raise BadExpression('Type %s PCD Value Size is Larger than 1 byte' % self.PcdType) > - if self.PcdType == 'UINT16' and Size > 2: > - raise BadExpression('Type %s PCD Value Size is Larger than 2 byte' % self.PcdType) > - if self.PcdType == 'UINT32' and Size > 4: > - raise BadExpression('Type %s PCD Value Size is Larger than 4 byte' % self.PcdType) > - if self.PcdType == '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 = long(PcdValue) > - TmpList = [] > - if TmpValue.bit_length() == 0: > - PcdValue = '{0x00}' > - else: > - for I in range((TmpValue.bit_length() + 7) / 8): > - TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff)) > - PcdValue = '{' + ', '.join(TmpList) + '}' > - except: > - if PcdValue.strip().startswith('{'): > - PcdValue = PcdValue.strip()[1:-1].strip() > + except BadExpression: > + if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']: > + PcdValue = PcdValue.strip() > + if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'): > + PcdValue = PcdValue[1:-1].split(',') > + if type(PcdValue) == type([]): > + TmpValue = 0 > Size = 0 > - ValueStr = '' > - TokenSpaceGuidName = '' > - if PcdValue.startswith('GUID') and PcdValue.endswith(')'): > - try: > - TokenSpaceGuidName = re.search('GUID\((\w+)\)', PcdValue).group(1) > - except: > - pass > - if TokenSpaceGuidName and TokenSpaceGuidName in self._Symb: > - PcdValue = 'GUID(' + self._Symb[TokenSpaceGuidName] + ')' > - elif TokenSpaceGuidName: > - raise BadExpression('%s not found in DEC file' % TokenSpaceGuidName) > - > - ListItem, Size = ParseFieldValue(PcdValue) > - elif PcdValue.startswith('DEVICE_PATH') and PcdValue.endswith(')'): > - ListItem, Size = ParseFieldValue(PcdValue) > - else: > - ListItem = PcdValue.split(',') > - > - if type(ListItem) == type(0) or type(ListItem) == type(0L): > - for Index in range(0, Size): > - ValueStr += '0x%02X' % (int(ListItem) & 255) > - ListItem >>= 8 > - ValueStr += ', ' > - PcdValue = '{' + ValueStr[:-2] + '}' > - elif type(ListItem) == type(''): > - if ListItem.startswith('{') and ListItem.endswith('}'): > - PcdValue = ListItem > + for Item in PcdValue: > + if Item.startswith('UINT16'): > + ItemSize = 2 > + elif Item.startswith('UINT32'): > + ItemSize = 4 > + elif Item.startswith('UINT64'): > + ItemSize = 8 > + else: > + ItemSize = 0 > + Item = ValueExpressionEx(Item, self.PcdType, self._Symb)(True) > + > + if ItemSize == 0: > + ItemValue, ItemSize = ParseFieldValue(Item) > + else: > + ItemValue = ParseFieldValue(Item)[0] > + > + if type(ItemValue) == type(''): > + ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue) > + > + TmpValue = (ItemValue << (Size * 8)) | TmpValue > + Size = Size + ItemSize > + else: > + TmpValue, Size = ParseFieldValue(PcdValue) > + if type(TmpValue) == type(''): > + TmpValue = int(TmpValue) > + else: > + PcdValue = '0x%0{}X'.format(Size) % (TmpValue) > + if TmpValue < 0: > + raise BadExpression('Type %s PCD Value is negative' % self.PcdType) > + if self.PcdType == 'UINT8' and Size > 1: > + raise BadExpression('Type %s PCD Value Size is Larger than 1 byte' % self.PcdType) > + if self.PcdType == 'UINT16' and Size > 2: > + raise BadExpression('Type %s PCD Value Size is Larger than 2 byte' % self.PcdType) > + if self.PcdType == 'UINT32' and Size > 4: > + raise BadExpression('Type %s PCD Value Size is Larger than 4 byte' % self.PcdType) > + if self.PcdType == '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 = long(PcdValue) > + TmpList = [] > + if TmpValue.bit_length() == 0: > + PcdValue = '{0x00}' > else: > - LabelDict = {} > - ReLabel = re.compile('LABEL\((\w+)\)') > - ReOffset = re.compile('OFFSET_OF\((\w+)\)') > - for Index, Item in enumerate(ListItem): > - # for LABEL parse > - Item = Item.strip() > + for I in range((TmpValue.bit_length() + 7) / 8): > + TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff)) > + PcdValue = '{' + ', '.join(TmpList) + '}' > + except: > + if PcdValue.strip().startswith('{'): > + PcdValue = PcdValue.strip()[1:-1].strip() > + Size = 0 > + ValueStr = '' > + TokenSpaceGuidName = '' > + if PcdValue.startswith('GUID') and PcdValue.endswith(')'): > try: > - LabelList = ReLabel.findall(Item) > - for Label in LabelList: > - if Label not in LabelDict.keys(): > - LabelDict[Label] = str(Index) > - Item = ReLabel.sub('', Item) > + TokenSpaceGuidName = re.search('GUID\((\w+)\)', PcdValue).group(1) > except: > pass > - try: > - OffsetList = ReOffset.findall(Item) > - except: > - pass > - for Offset in OffsetList: > - if Offset in LabelDict.keys(): > - Re = re.compile('OFFSET_OF\(%s\)'% Offset) > - Item = Re.sub(LabelDict[Offset], Item) > - else: > - raise BadExpression('%s not defined before use' % Offset) > - if Item.startswith('UINT16'): > - ItemSize = 2 > - elif Item.startswith('UINT32'): > - ItemSize = 4 > - elif Item.startswith('UINT64'): > - ItemSize = 8 > - else: > - ItemSize = 0 > - TmpValue = ValueExpressionEx(Item, self.PcdType, self._Symb)(True) > - Item = '0x%x' % TmpValue if type(TmpValue) != type('') else TmpValue > - if ItemSize == 0: > - ItemValue, ItemSize = ParseFieldValue(Item) > - else: > - ItemValue = ParseFieldValue(Item)[0] > - for I in range(0, ItemSize): > - ValueStr += '0x%02X' % (int(ItemValue) & 255) > - ItemValue >>= 8 > + if TokenSpaceGuidName and TokenSpaceGuidName in self._Symb: > + PcdValue = 'GUID(' + self._Symb[TokenSpaceGuidName] + ')' > + elif TokenSpaceGuidName: > + raise BadExpression('%s not found in DEC file' % TokenSpaceGuidName) > + > + ListItem, Size = ParseFieldValue(PcdValue) > + elif PcdValue.startswith('DEVICE_PATH') and PcdValue.endswith(')'): > + ListItem, Size = ParseFieldValue(PcdValue) > + else: > + ListItem = PcdValue.split(',') > + > + if type(ListItem) == type(0) or type(ListItem) == type(0L): > + for Index in range(0, Size): > + ValueStr += '0x%02X' % (int(ListItem) & 255) > + ListItem >>= 8 > ValueStr += ', ' > - Size += ItemSize > - > - if Size > 0: > - PcdValue = '{' + ValueStr[:-2] + '}' > + PcdValue = '{' + ValueStr[:-2] + '}' > + elif type(ListItem) == type(''): > + if ListItem.startswith('{') and ListItem.endswith('}'): > + PcdValue = ListItem > + else: > + LabelDict = {} > + ReLabel = re.compile('LABEL\((\w+)\)') > + ReOffset = re.compile('OFFSET_OF\((\w+)\)') > + for Index, Item in enumerate(ListItem): > + # for LABEL parse > + Item = Item.strip() > + try: > + LabelList = ReLabel.findall(Item) > + for Label in LabelList: > + if Label not in LabelDict.keys(): > + LabelDict[Label] = str(Index) > + Item = ReLabel.sub('', Item) > + except: > + pass > + try: > + OffsetList = ReOffset.findall(Item) > + except: > + pass > + for Offset in OffsetList: > + if Offset in LabelDict.keys(): > + Re = re.compile('OFFSET_OF\(%s\)'% Offset) > + Item = Re.sub(LabelDict[Offset], Item) > + else: > + raise BadExpression('%s not defined before use' % Offset) > + ValueType = "" > + if Item.startswith('UINT16'): > + ItemSize = 1 > + ValueType = "UINT8" > + elif Item.startswith('UINT16'): > + ItemSize = 2 > + ValueType = "UINT16" > + elif Item.startswith('UINT32'): > + ItemSize = 4 > + elif Item.startswith('UINT64'): > + ItemSize = 8 > + else: > + ItemSize = 0 > + if ValueType: > + TmpValue = ValueExpressionEx(Item, ValueType, self._Symb)(True) > + else: > + TmpValue = ValueExpressionEx(Item, self.PcdType, self._Symb)(True) > + Item = '0x%x' % TmpValue if type(TmpValue) != type('') else TmpValue > + if ItemSize == 0: > + ItemValue, ItemSize = ParseFieldValue(Item) > + else: > + ItemValue = ParseFieldValue(Item)[0] > + for I in range(0, ItemSize): > + ValueStr += '0x%02X' % (int(ItemValue) & 255) > + ItemValue >>= 8 > + ValueStr += ', ' > + Size += ItemSize > + > + if Size > 0: > + PcdValue = '{' + ValueStr[:-2] + '}' > + if PcdValue == 'True': > + PcdValue = '1' > + if PcdValue == 'False': > + PcdValue = '0' > if RealValue: > return PcdValue > > if __name__ == '__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] = ValueExpression(ValueList[Index], GlobalData.gPlatformPcds)(True) > except WrnExpression, Value: > ValueList[Index] = Value.result > except BadExpression, Value: > - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=self._LineIndex + 1) > + DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType > + try: > + ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True) > + except BadExpression, Value: > + EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo, > + ExtraData="PCD [%s.%s] Value \"%s\" " % ( > + TokenSpaceGuid, PcdCName, ValueList[Index])) > 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 [PcdsFixedAtBuild] 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=self.MetaFile, Line=LineNo) > else: > EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt), > File=self.MetaFile, Line=LineNo) > + if ValueList[Index] == 'True': > + ValueList[Index] = '1' > + if ValueList[Index] == 'False': > + ValueList[Index] = '0' > + > if ValueList[Index]: > - DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType > - try: > - ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True) > - except BadExpression, Value: > - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo, > - ExtraData="PCD [%s.%s] Value \"%s\" " % (TokenSpaceGuid, PcdCName, ValueList[Index])) > Valid, ErrStr = CheckPcdDatum(self._DecPcds[PcdCName, TokenSpaceGuid].DatumType, ValueList[Index]) > if not Valid: > EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo, > ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName)) > if PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT): > diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 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=self.MetaFile, Line=self._LineIndex + 1) > > PcdValue = ValueList[0] > if PcdValue: > try: > - ValueList[0] = ValueExpression(PcdValue, self._AllPcdDict)(True) > - except WrnExpression, Value: > - ValueList[0] = Value.result > - except BadExpression, Value: > - EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=self._LineIndex + 1) > - > - if ValueList[0]: > - try: > ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True) > except BadExpression, Value: > EdkLogger.error('Parser', FORMAT_INVALID, Value, ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) > # check format of default value against the datum type > IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0]) > diff --git a/BaseTools/Source/Python/build/BuildReport.py 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 GuidStructureByteArrayToGuidString > 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 * > > ## Pattern to extract contents in EDK DXS files > gDxsDependencyPattern = re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL) > > ## Pattern to find total FV total size, occupied size in flash report intermediate file > @@ -953,11 +954,15 @@ class PcdReport(object): > DecDefaultValue = self.DecPcdDefault.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, DecType)) > DscDefaultValue = self.DscPcdDefault.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName)) > DscDefaultValBak = DscDefaultValue > DscDefaultValue = self.FdfPcdSet.get((Pcd.TokenCName, Key), DscDefaultValue) > if DscDefaultValue != DscDefaultValBak: > - DscDefaultValue = ValueExpressionEx(DscDefaultValue, Pcd.DatumType, self._GuidDict)(True) > + try: > + DscDefaultValue = ValueExpressionEx(DscDefaultValue, Pcd.DatumType, self._GuidDict)(True) > + except BadExpression, Value: > + EdkLogger.error('BuildReport', FORMAT_INVALID, "PCD Value: %s, Type: %s" %(DscDefaultValue, Pcd.DatumType)) > + > InfDefaultValue = None > > PcdValue = DecDefaultValue > if DscDefaultValue: > PcdValue = DscDefaultValue > -- > 2.6.1.windows.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel