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.65; helo=mga03.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 E21FC22280C29 for ; Tue, 26 Dec 2017 21:47:08 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2017 21:52:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,462,1508828400"; d="scan'208";a="190235199" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga006.fm.intel.com with ESMTP; 26 Dec 2017 21:52:03 -0800 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Dec 2017 21:52:02 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Dec 2017 21:52:02 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Wed, 27 Dec 2017 13:52:00 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" Thread-Topic: [edk2] [Patch] BaseTools: Support PCD flexible values format Thread-Index: AQHTftLlEHAN1AAtsU+qo0ZY1y+cTKNWr/Lg Date: Wed, 27 Dec 2017 05:51:59 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1990F6@SHSMSX104.ccr.corp.intel.com> References: <1514352222-13024-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1514352222-13024-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] BaseTools: Support PCD flexible values format 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: Wed, 27 Dec 2017 05:47:09 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >Yonghong Zhu >Sent: Wednesday, December 27, 2017 1:24 PM >To: edk2-devel@lists.01.org >Cc: Feng, YunhuaX >Subject: [edk2] [Patch] BaseTools: Support PCD flexible values format > >https://bugzilla.tianocore.org/show_bug.cgi?id=3D541 > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Yunhua Feng >Signed-off-by: Yonghong Zhu >--- > BaseTools/Source/Python/AutoGen/AutoGen.py | 39 ++++ > BaseTools/Source/Python/AutoGen/GenC.py | 2 + > BaseTools/Source/Python/Common/Expression.py | 246 >++++++++++++++++++++- > BaseTools/Source/Python/Common/Misc.py | 203 +++++++++-------= - > BaseTools/Source/Python/Workspace/DscBuildData.py | 16 +- > BaseTools/Source/Python/Workspace/InfBuildData.py | 7 + > .../Source/Python/Workspace/MetaFileParser.py | 17 +- > .../Source/Python/Workspace/WorkspaceCommon.py | 8 +- > BaseTools/Source/Python/build/BuildReport.py | 6 + > 9 files changed, 430 insertions(+), 114 deletions(-) > >diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py >b/BaseTools/Source/Python/AutoGen/AutoGen.py >index cacd009..8be5bfc 100644 >--- a/BaseTools/Source/Python/AutoGen/AutoGen.py >+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py >@@ -269,10 +269,11 @@ class WorkspaceAutoGen(AutoGen): > self.AutoGenObjectList =3D [] > self._BuildDir =3D None > self._FvDir =3D None > self._MakeFileDir =3D None > self._BuildCommand =3D None >+ self._GuidDict =3D {} > > # there's many relative directory operations, so ... > os.chdir(self.WorkspaceDir) > > # >@@ -417,24 +418,42 @@ class WorkspaceAutoGen(AutoGen): > TokenSpaceGuidCNameList =3D [] > FoundFlag =3D False > PcdDatumType =3D '' > NewValue =3D '' > for package in PGen.PackageList: >+ Guids =3D package.Guids >+ self._GuidDict.update(Guids) >+ for package in PGen.PackageList: > for key in package.Pcds: > PcdItem =3D package.Pcds[key] > if HasTokenSpace: > if (PcdItem.TokenCName, PcdItem.TokenSpac= eGuidCName) >=3D=3D (TokenCName, TokenSpaceGuidCName): > PcdDatumType =3D PcdItem.DatumType >+ if pcdvalue.startswith('H'): >+ try: >+ pcdvalue =3D ValueExpressionE= x(pcdvalue[1:], >PcdDatumType, self._GuidDict)(True) >+ except BadExpression, Value: >+ if Value.result > 1: >+ EdkLogger.error('Parser',= FORMAT_INVALID, 'PCD >[%s.%s] Value "%s", %s' % >+ (TokenSpa= ceGuidCName, TokenCName, >pcdvalue, Value)) >+ pcdvalue =3D 'H' + pcdvalue > NewValue =3D >BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, >PcdDatumType, pcdvalue) > FoundFlag =3D True > else: > if PcdItem.TokenCName =3D=3D TokenCName: > if not PcdItem.TokenSpaceGuidCName in >TokenSpaceGuidCNameList: > if len (TokenSpaceGuidCNameList) = < 1: > >TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName) > PcdDatumType =3D PcdItem.Datu= mType > TokenSpaceGuidCName =3D >PcdItem.TokenSpaceGuidCName >+ if pcdvalue.startswith('H'): >+ try: >+ pcdvalue =3D ValueExp= ressionEx(pcdvalue[1:], >PcdDatumType, self._GuidDict)(True) >+ except BadExpression, Val= ue: >+ EdkLogger.error('Pars= er', FORMAT_INVALID, 'PCD >[%s.%s] Value "%s", %s' % >+ (Toke= nSpaceGuidCName, TokenCName, >pcdvalue, Value)) >+ pcdvalue =3D 'H' + pcdval= ue > NewValue =3D >BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, >PcdDatumType, pcdvalue) > FoundFlag =3D True > else: > EdkLogger.error( > 'build', >@@ -2444,10 +2463,30 @@ class PlatformAutoGen(AutoGen): > ToPcd.MaxDatumSize =3D FromPcd.MaxDatumSize > if FromPcd.DatumType not in [None, '']: > ToPcd.DatumType =3D FromPcd.DatumType > if FromPcd.SkuInfoList not in [None, '', []]: > ToPcd.SkuInfoList =3D FromPcd.SkuInfoList >+ # Add Flexible PCD format parse >+ PcdValue =3D ToPcd.DefaultValue >+ if PcdValue: >+ try: >+ ToPcd.DefaultValue =3D ValueExpression(PcdValue)(True= ) >+ except WrnExpression, Value: >+ ToPcd.DefaultValue =3D Value.result >+ except BadExpression, Value: >+ EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s= ] Value >"%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, >ToPcd.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) >+ except BadExpression, Value: >+ EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s= ] Value >"%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, >ToPcd.DefaultValue, Value), >+ File=3Dself.MetaFile) > > # check the validation of datum > IsValid, Cause =3D CheckPcdDatum(ToPcd.DatumType, >ToPcd.DefaultValue) > if not IsValid: > EdkLogger.error('build', FORMAT_INVALID, Cause, File=3Dse= lf.MetaFile, >diff --git a/BaseTools/Source/Python/AutoGen/GenC.py >b/BaseTools/Source/Python/AutoGen/GenC.py >index 6b95cd4..3e98506 100644 >--- a/BaseTools/Source/Python/AutoGen/GenC.py >+++ b/BaseTools/Source/Python/AutoGen/GenC.py >@@ -1031,10 +1031,12 @@ def CreateModulePcdCode(Info, AutoGenC, >AutoGenH, Pcd): > elif BoolValue =3D=3D 'FALSE' or BoolValue =3D=3D '0': > Value =3D '0U' > > if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']: > try: >+ if Value.upper().endswith('L'): >+ Value =3D Value[:-1] > if Value.upper().startswith('0X'): > ValueNumber =3D int (Value, 16) > else: > ValueNumber =3D int (Value) > except: >diff --git a/BaseTools/Source/Python/Common/Expression.py >b/BaseTools/Source/Python/Common/Expression.py >index ba83e02..953a412 100644 >--- a/BaseTools/Source/Python/Common/Expression.py >+++ b/BaseTools/Source/Python/Common/Expression.py >@@ -13,11 +13,13 @@ > ## Import Modules > # > from Common.GlobalData import * > from CommonDataClass.Exceptions import BadExpression > from CommonDataClass.Exceptions import WrnExpression >-from Misc import GuidStringToGuidStructureString >+from Misc import GuidStringToGuidStructureString, ParseFieldValue >+import Common.EdkLogger as EdkLogger >+import copy > > ERR_STRING_EXPR =3D 'This operator cannot be used in string expre= ssion: >[%s].' > ERR_SNYTAX =3D 'Syntax error, the rest of expression cannot = be >evaluated: [%s].' > ERR_MATCH =3D 'No matching right parenthesis.' > ERR_STRING_TOKEN =3D 'Bad string token: [%s].' >@@ -112,10 +114,19 @@ def ReplaceExprMacro(String, Macros, ExceptionList >=3D None): > String =3D RetStr > MacroStartPos =3D String.find('$(') > StrList[i] =3D RetStr > return ''.join(StrList) > >+# transfer int to string for in/not in expression >+def IntToStr(Value): >+ StrList =3D [] >+ while Value > 0: >+ StrList.append(chr(Value & 0xff)) >+ Value =3D Value >> 8 >+ Value =3D '"' + ''.join(StrList) + '"' >+ return Value >+ > SupportedInMacroList =3D ['TARGET', 'TOOL_CHAIN_TAG', 'ARCH', 'FAMILY'] > > class ValueExpression(object): > # Logical operator mapping > LogicalOperators =3D { >@@ -144,14 +155,28 @@ class ValueExpression(object): > > @staticmethod > def Eval(Operator, Oprand1, Oprand2 =3D None): > WrnExp =3D None > >- if Operator not in ["=3D=3D", "!=3D", ">=3D", "<=3D", ">", "<", "= in", "not in"] and \ >- (type(Oprand1) =3D=3D type('') or type(Oprand2) =3D=3D type('= ')): >- raise BadExpression(ERR_STRING_EXPR % Operator) >- >+ if Operator not in ["in", "not in"] and (type(Oprand1) =3D=3D typ= e('') or >type(Oprand2) =3D=3D type('')): >+ if type(Oprand1) =3D=3D type(''): >+ if Oprand1[0] in ['"', "'"] or Oprand1.startswith('L"') o= r >Oprand1.startswith("L'")or Oprand1.startswith('UINT'): >+ Oprand1, Size =3D ParseFieldValue(Oprand1) >+ else: >+ Oprand1,Size =3D ParseFieldValue('"' + Oprand1 + '"') >+ if type(Oprand2) =3D=3D type(''): >+ if Oprand2[0] in ['"', "'", 'L'] or Oprand2.startswith('U= INT'): >+ Oprand2, Size =3D ParseFieldValue(Oprand2) >+ else: >+ Oprand2, Size =3D ParseFieldValue('"' + Oprand2 + '"'= ) >+ if type(Oprand1) =3D=3D type('') or type(Oprand2) =3D=3D type= (''): >+ raise BadExpression(ERR_STRING_EXPR % Operator) >+ if Operator in ['in', 'not in']: >+ if type(Oprand1) !=3D type(''): >+ Oprand1 =3D IntToStr(Oprand1) >+ if type(Oprand2) !=3D type(''): >+ Oprand2 =3D IntToStr(Oprand2) > TypeDict =3D { > type(0) : 0, > type(0L) : 0, > type('') : 1, > type(True) : 2 >@@ -224,10 +249,13 @@ 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().ends= with('}'): >+ self._Expr =3D Expression >+ self._NoProcess =3D True > > self._Expr =3D ReplaceExprMacro(Expression.strip(), > SymbolTable, > SupportedInMacroList) > >@@ -235,11 +263,11 @@ class ValueExpression(object): > raise BadExpression(ERR_EMPTY_EXPR) > > # > # The symbol table including PCD and macro mapping > # >- self._Symb =3D SymbolTable >+ self._Symb =3D copy.deepcopy(SymbolTable) > self._Symb.update(self.LogicalOperators) > self._Idx =3D 0 > self._Len =3D len(self._Expr) > self._Token =3D '' > self._WarnExcept =3D None >@@ -282,11 +310,11 @@ class ValueExpression(object): > if Val =3D=3D 'L""': > Val =3D False > elif not Val: > Val =3D False > RealVal =3D '""' >- elif not Val.startswith('L"') and not Val.startswith('{'): >+ elif not Val.startswith('L"') and not Val.startswith('{') and= not >Val.startswith("L'"): > Val =3D True > RealVal =3D '"' + RealVal + '"' > > # The expression has been parsed, but the end of expression is no= t >reached > # It means the rest does not comply EBNF of >@@ -424,10 +452,19 @@ class ValueExpression(object): > # Try to convert string to number > def __IsNumberToken(self): > 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"= '): >+ Flag =3D 0 >+ for Index in range(len(self._Token)): >+ if self._Token[Index] in ['"', "'"]: >+ Flag +=3D 1 >+ if Flag =3D=3D 2: >+ self._Token =3D ParseFieldValue(self._Token)[0] >+ return True > try: > self._Token =3D int(self._Token, Radix) > return True > except ValueError: > return False >@@ -471,14 +508,16 @@ class ValueExpression(object): > > # Replace escape \\\", \" > Expr =3D self._Expr[self._Idx:].replace('\\\\', '//').replace('\\= \"', '\\\'') > for Ch in Expr: > self._Idx +=3D 1 >- if Ch =3D=3D '"': >+ if Ch =3D=3D '"' or Ch =3D=3D "'": > break > self._Token =3D self._LiteralToken =3D self._Expr[Idx:self._Idx] >- if not self._Token.endswith('"'): >+ if self._Token.startswith('"') and not self._Token.endswith('"'): >+ raise BadExpression(ERR_STRING_TOKEN % self._Token) >+ if self._Token.startswith("'") and not self._Token.endswith("'"): > raise BadExpression(ERR_STRING_TOKEN % self._Token) > self._Token =3D self._Token[1:-1] > return self._Token > > # Get token that is comprised by alphanumeric, underscore or dot(used= by >PCD) >@@ -576,11 +615,48 @@ class ValueExpression(object): > if Expr.startswith('L"'): > # Skip L > self._Idx +=3D 1 > UStr =3D self.__GetString() > self._Token =3D 'L"' + UStr + '"' >+ self._Token, Size =3D ParseFieldValue(self._Token) >+ return self._Token >+ elif Expr.startswith("L'"): >+ # Skip L >+ self._Idx +=3D 1 >+ UStr =3D self.__GetString() >+ self._Token =3D "L'" + UStr + "'" >+ self._Token, Size =3D ParseFieldValue(self._Token) >+ return self._Token >+ elif Expr.startswith('"'): >+ UStr =3D self.__GetString() >+ self._Token =3D '"' + UStr + '"' >+ self._Token, Size =3D ParseFieldValue(self._Token) > return self._Token >+ elif Expr.startswith("'"): >+ UStr =3D self.__GetString() >+ self._Token =3D "'" + UStr + "'" >+ self._Token, Size =3D ParseFieldValue(self._Token) >+ return self._Token >+ elif Expr.startswith('UINT'): >+ Re =3D re.compile('(?:UINT8|UINT16|UINT32|UINT64)\((.+)\)') >+ try: >+ RetValue =3D Re.search(Expr).group(1) >+ except: >+ raise BadExpression('Invalid Expression %s' % Expr) >+ Idx =3D self._Idx >+ for Ch in Expr: >+ self._Idx +=3D 1 >+ if Ch =3D=3D '(': >+ Prefix =3D self._Expr[Idx:self._Idx - 1] >+ Idx =3D self._Idx >+ if Ch =3D=3D ')': >+ TmpValue =3D self._Expr[Idx :self._Idx - 1] >+ TmpValue =3D ValueExpression(TmpValue)(True) >+ TmpValue =3D '0x%x' % int(TmpValue) if type(TmpValue)= !=3D type('') >else TmpValue >+ break >+ self._Token, Size =3D ParseFieldValue(Prefix + '(' + TmpValue= + ')') >+ return self._Token > > self._Token =3D '' > if Expr: > Ch =3D Expr[0] > Match =3D self.RegGuidPattern.match(Expr) >@@ -646,10 +722,162 @@ class ValueExpression(object): > self._Token =3D self.LogicalOperators[self._Token] > return True > self._Idx =3D Idx > return False > >+class ValueExpressionEx(ValueExpression): >+ def __init__(self, PcdValue, PcdType, SymbolTable=3D{}): >+ ValueExpression.__init__(self, PcdValue, SymbolTable) >+ self.PcdValue =3D PcdValue >+ self.PcdType =3D PcdType >+ >+ def __call__(self, RealValue=3DFalse, Depth=3D0): >+ 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', '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() >+ 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 >+ 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], 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 >+ ValueStr +=3D ', ' >+ Size +=3D ItemSize >+ >+ if Size > 0: >+ PcdValue =3D '{' + ValueStr[:-2] + '}' >+ if RealValue: >+ return PcdValue >+ > if __name__ =3D=3D '__main__': > pass > while True: > input =3D raw_input('Input expr: ') > if input in 'qQ': >diff --git a/BaseTools/Source/Python/Common/Misc.py >b/BaseTools/Source/Python/Common/Misc.py >index 0374be0..c51b685 100644 >--- a/BaseTools/Source/Python/Common/Misc.py >+++ b/BaseTools/Source/Python/Common/Misc.py >@@ -35,10 +35,11 @@ from BuildToolError import * > from CommonDataClass.DataClass import * > from Parsing import GetSplitValueList > from Common.LongFilePathSupport import OpenLongFilePath as open > from Common.MultipleWorkspace import MultipleWorkspace as mws > import uuid >+from CommonDataClass.Exceptions import BadExpression > > ## Regular expression used to find out place holders in string template > gPlaceholderPattern =3D re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | >re.UNICODE) > > ## Dictionary used to store file time stamp for quick re-access >@@ -1470,103 +1471,123 @@ def AnalyzePcdExpression(Setting): > FieldList.append(Setting[StartPos:Pos].strip()) > StartPos =3D Pos + 1 > > return FieldList > >+def ParseDevPathValue (Value): >+ pass >+ > def ParseFieldValue (Value): >- if type(Value) =3D=3D type(0): >- return Value, (Value.bit_length() + 7) / 8 >- if type(Value) <> type(''): >- raise ValueError >- Value =3D Value.strip() >- if Value.startswith('UINT8') and Value.endswith(')'): >- Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) >- if Size > 1: >- raise ValueError >+ if type(Value) =3D=3D type(0): >+ return Value, (Value.bit_length() + 7) / 8 >+ if type(Value) <> type(''): >+ raise BadExpression('Type %s is %s' %(Value, type(Value))) >+ Value =3D Value.strip() >+ if Value.startswith('UINT8') and Value.endswith(')'): >+ Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) >+ if Size > 1: >+ raise BadExpression('Value (%s) Size larger than %d' %(Value,= Size)) >+ return Value, 1 >+ if Value.startswith('UINT16') and Value.endswith(')'): >+ Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) >+ if Size > 2: >+ raise BadExpression('Value (%s) Size larger than %d' %(Value,= Size)) >+ return Value, 2 >+ if Value.startswith('UINT32') and Value.endswith(')'): >+ Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) >+ if Size > 4: >+ raise BadExpression('Value (%s) Size larger than %d' %(Value,= Size)) >+ return Value, 4 >+ if Value.startswith('UINT64') and Value.endswith(')'): >+ Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) >+ if Size > 8: >+ raise BadExpression('Value (%s) Size larger than %d' % (Value= , Size)) >+ return Value, 8 >+ if Value.startswith('GUID') and Value.endswith(')'): >+ Value =3D Value.split('(', 1)[1][:-1].strip() >+ if Value[0] =3D=3D '{' and Value[-1] =3D=3D '}': >+ Value =3D Value[1:-1].strip() >+ Value =3D Value.split('{', 1) >+ Value =3D ['%02x' % int(Item, 16) for Item in (Value[0] + Val= ue[1][:- >1]).split(',')] >+ if len(Value[0]) !=3D 8: >+ Value[0] =3D '%08X' % int(Value[0], 16) >+ if len(Value[1]) !=3D 4: >+ Value[1] =3D '%04X' % int(Value[1], 16) >+ if len(Value[2]) !=3D 4: >+ Value[2] =3D '%04X' % int(Value[2], 16) >+ Value =3D '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + = '-' + >''.join(Value[5:11]) >+ if Value[0] =3D=3D '"' and Value[-1] =3D=3D '"': >+ Value =3D Value[1:-1] >+ try: >+ Value =3D "'" + uuid.UUID(Value).get_bytes_le() + "'" >+ except ValueError, Message: >+ raise BadExpression('%s' % Message) >+ Value, Size =3D ParseFieldValue(Value) >+ return Value, 16 >+ if Value.startswith('L"') and Value.endswith('"'): >+ # Unicode String >+ List =3D list(Value[2:-1]) >+ List.reverse() >+ Value =3D 0 >+ for Char in List: >+ Value =3D (Value << 16) | ord(Char) >+ return Value, (len(List) + 1) * 2 >+ if Value.startswith('"') and Value.endswith('"'): >+ # ASCII String >+ List =3D list(Value[1:-1]) >+ List.reverse() >+ Value =3D 0 >+ for Char in List: >+ Value =3D (Value << 8) | ord(Char) >+ return Value, len(List) + 1 >+ if Value.startswith("L'") and Value.endswith("'"): >+ # Unicode Character Constant >+ List =3D list(Value[2:-1]) >+ List.reverse() >+ Value =3D 0 >+ for Char in List: >+ Value =3D (Value << 16) | ord(Char) >+ return Value, len(List) * 2 >+ if Value.startswith("'") and Value.endswith("'"): >+ # Character constant >+ List =3D list(Value[1:-1]) >+ List.reverse() >+ Value =3D 0 >+ for Char in List: >+ Value =3D (Value << 8) | ord(Char) >+ return Value, len(List) >+ if Value.startswith('{') and Value.endswith('}'): >+ # Byte array >+ Value =3D Value[1:-1] >+ List =3D [Item.strip() for Item in Value.split(',')] >+ List.reverse() >+ Value =3D 0 >+ RetSize =3D 0 >+ for Item in List: >+ ItemValue, Size =3D ParseFieldValue(Item) >+ RetSize +=3D Size >+ for I in range(Size): >+ Value =3D (Value << 8) | ((ItemValue >> 8 * I) & 0xff) >+ return Value, RetSize >+ if Value.startswith('DEVICE_PATH(') and Value.endswith(')'): >+ Value =3D Value.split('"')[1] >+ return ParseDevPathValue(Value) >+ if Value.lower().startswith('0x'): >+ Value =3D int(Value, 16) >+ if Value =3D=3D 0: >+ return 0, 1 >+ return Value, (Value.bit_length() + 7) / 8 >+ if Value[0].isdigit(): >+ Value =3D int(Value, 10) >+ if Value =3D=3D 0: >+ return 0, 1 >+ return Value, (Value.bit_length() + 7) / 8 >+ if Value.lower() =3D=3D 'true': >+ return 1, 1 >+ if Value.lower() =3D=3D 'false': >+ return 0, 1 > return Value, 1 >- if Value.startswith('UINT16') and Value.endswith(')'): >- Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) >- if Size > 2: >- raise ValueError >- return Value, 2 >- if Value.startswith('UINT32') and Value.endswith(')'): >- Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) >- if Size > 4: >- raise ValueError >- return Value, 4 >- if Value.startswith('UINT64') and Value.endswith(')'): >- Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) >- if Size > 8: >- raise ValueError >- return Value, 8 >- if Value.startswith('GUID') and Value.endswith(')'): >- Value =3D Value.split('(', 1)[1][:-1].strip() >- if Value[0] =3D=3D '{' and Value[-1] =3D=3D '}': >- Value =3D Value[1:-1].strip() >- Value =3D Value.split('{', 1) >- Value =3D [Item.strip()[2:] for Item in (Value[0] + Value[1][:-1]).= split(',')] >- Value =3D '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '-' + = ''.join(Value[5:11]) >- if Value[0] =3D=3D '"' and Value[-1] =3D=3D '"': >- Value =3D Value[1:-1] >- Value =3D "'" + uuid.UUID(Value).get_bytes_le() + "'" >- Value, Size =3D ParseFieldValue(Value) >- return Value, 16 >- if Value.startswith('L"') and Value.endswith('"'): >- # Unicode String >- List =3D list(Value[2:-1]) >- List.reverse() >- Value =3D 0 >- for Char in List: >- Value =3D (Value << 16) | ord(Char) >- return Value, (len(List) + 1) * 2 >- if Value.startswith('"') and Value.endswith('"'): >- # ASCII String >- List =3D list(Value[1:-1]) >- List.reverse() >- Value =3D 0 >- for Char in List: >- Value =3D (Value << 8) | ord(Char) >- return Value, len(List) + 1 >- if Value.startswith("L'") and Value.endswith("'"): >- # Unicode Character Constant >- List =3D list(Value[2:-1]) >- List.reverse() >- Value =3D 0 >- for Char in List: >- Value =3D (Value << 16) | ord(Char) >- return Value, len(List) * 2 >- if Value.startswith("'") and Value.endswith("'"): >- # Character constant >- List =3D list(Value[1:-1]) >- List.reverse() >- Value =3D 0 >- for Char in List: >- Value =3D (Value << 8) | ord(Char) >- return Value, len(List) >- if Value.startswith('{') and Value.endswith('}'): >- # Byte array >- Value =3D Value[1:-1] >- List =3D [Item.strip() for Item in Value.split(',')] >- List.reverse() >- Value =3D 0 >- for Item in List: >- ItemValue, Size =3D ParseFieldValue(Item) >- if Size > 1: >- raise ValueError >- Value =3D (Value << 8) | ItemValue >- return Value, len(List) >- if Value.lower().startswith('0x'): >- Value =3D int(Value, 16) >- return Value, (Value.bit_length() + 7) / 8 >- if Value[0].isdigit(): >- Value =3D int(Value, 10) >- return Value, (Value.bit_length() + 7) / 8 >- if Value.lower() =3D=3D 'true': >- return 1, 1 >- if Value.lower() =3D=3D 'false': >- return 0, 1 >- return Value, 1 > > ## AnalyzeDscPcd > # > # Analyze DSC PCD value, since there is no data type info in DSC > # This fuction is used to match functions (AnalyzePcdData, AnalyzeHiiPcd= Data, >AnalyzeVpdPcdData) used for retrieving PCD value from database >diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py >b/BaseTools/Source/Python/Workspace/DscBuildData.py >index e422100..f9cd429 100644 >--- a/BaseTools/Source/Python/Workspace/DscBuildData.py >+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py >@@ -798,11 +798,11 @@ class DscBuildData(PlatformBuildClassObject): > if ModuleFile in self._Modules: > continue > ModuleData =3D self._Bdb[ModuleFile, self._Arch, self._Ta= rget, >self._Toolchain] > PkgSet.update(ModuleData.Packages) > >- self._DecPcds =3D GetDeclaredPcd(self, self._Bdb, self._Arch, >self._Target, self._Toolchain,PkgSet) >+ self._DecPcds, self._GuidDict =3D GetDeclaredPcd(self, self._= Bdb, >self._Arch, self._Target, self._Toolchain,PkgSet) > > > if (PcdCName, TokenSpaceGuid) not in self._DecPcds: > EdkLogger.error('build', PARSER_ERROR, > "Pcd (%s.%s) defined in DSC is not declared i= n DEC files. Arch: >['%s']" % (TokenSpaceGuid, PcdCName, self._Arch), >@@ -819,10 +819,12 @@ class DscBuildData(PlatformBuildClassObject): > if ValueList[Index] and PcdType not in [MODEL_PCD_FEATURE_FLAG, >MODEL_PCD_FIXED_AT_BUILD]: > try: > ValueList[Index] =3D ValueExpression(ValueList[Index], >GlobalData.gPlatformPcds)(True) > except WrnExpression, Value: > ValueList[Index] =3D Value.result >+ except BadExpression, Value: >+ EdkLogger.error('Parser', FORMAT_INVALID, Value, >File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) > 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" >@@ -832,15 +834,17 @@ 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 >expression: %s" % str(Excpt), > File=3Dself.MetaFile, Line=3DLineNo) >- if ValueList[Index] =3D=3D 'True': >- ValueList[Index] =3D '1' >- elif ValueList[Index] =3D=3D 'False': >- ValueList[Index] =3D '0' > 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, > ExtraData=3D"%s.%s" % (TokenSpaceGuid, Pc= dCName)) > if PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, >MODEL_PCD_DYNAMIC_EX_DEFAULT): >@@ -2056,11 +2060,11 @@ class DscBuildData(PlatformBuildClassObject): > ModuleFile =3D PathClass(NormPath(Inf), GlobalData.gWorks= pace, >Arch=3Dself._Arch) > if ModuleFile in self._Modules: > continue > ModuleData =3D self._Bdb[ModuleFile, self._Arch, self._Ta= rget, >self._Toolchain] > PkgSet.update(ModuleData.Packages) >- self._DecPcds =3D GetDeclaredPcd(self, self._Bdb, self._Arch, >self._Target, self._Toolchain,PkgSet) >+ self._DecPcds, self._GuidDict =3D GetDeclaredPcd(self, self._= Bdb, >self._Arch, self._Target, self._Toolchain,PkgSet) > return self._DecPcds > _Macros =3D property(_GetMacros) > Arch =3D property(_GetArch, _SetArch) > Platform =3D property(_GetPlatformName) > PlatformName =3D property(_GetPlatformName) >diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py >b/BaseTools/Source/Python/Workspace/InfBuildData.py >index fd94067..7ea9b56 100644 >--- a/BaseTools/Source/Python/Workspace/InfBuildData.py >+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py >@@ -14,10 +14,11 @@ > > from Common.String import * > from Common.DataType import * > from Common.Misc import * > from types import * >+from MetaFileParser import * > > from Workspace.BuildClassObject import ModuleBuildClassObject, >LibraryClassObject, PcdClassObject > ## Module build information from INF file > # > # This class is used to retrieve information stored in database and conv= ert >them >@@ -1142,10 +1143,16 @@ class InfBuildData(ModuleBuildClassObject): > Pcd.DatumType =3D PcdInPackage.DatumType > Pcd.MaxDatumSize =3D PcdInPackage.MaxDatumSize > Pcd.InfDefaultValue =3D Pcd.DefaultValue > if Pcd.DefaultValue in [None, '']: > Pcd.DefaultValue =3D PcdInPackage.DefaultValue >+ else: >+ try: >+ Pcd.DefaultValue =3D ValueExpressionEx(Pcd.De= faultValue, >Pcd.DatumType, self.Guids)(True) >+ except BadExpression, Value: >+ EdkLogger.error('Parser', FORMAT_INVALID, 'PC= D [%s.%s] >Value "%s", %s' %(TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, Value), >+ File=3Dself.MetaFile, Line=3D= LineNo) > break > else: > EdkLogger.error( > 'build', > FORMAT_INVALID, >diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py >b/BaseTools/Source/Python/Workspace/MetaFileParser.py >index 3038447..b2b0e28 100644 >--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py >+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py >@@ -25,11 +25,11 @@ import Common.EdkLogger as EdkLogger > import Common.GlobalData as GlobalData > > from CommonDataClass.DataClass import * > from Common.DataType import * > from Common.String import * >-from Common.Misc import GuidStructureStringToGuidString, >CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, >AnalyzePcdExpression >+from Common.Misc import GuidStructureStringToGuidString, >CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, >AnalyzePcdExpression, ParseFieldValue > from Common.Expression import * > from CommonDataClass.Exceptions import * > from Common.LongFilePathSupport import OpenLongFilePath as open > > from MetaFileTable import MetaFileStorage >@@ -180,10 +180,11 @@ class MetaFileParser(object): > self._Enabled =3D 0 > self._Finished =3D False > self._PostProcessed =3D False > # Different version of meta-file has different way to parse. > self._Version =3D 0 >+ self._GuidDict =3D {} # for Parser PCD value {GUID(gTokeSpaceGui= dName)} > > ## Store the parsed data in table > def _Store(self, *Args): > return self._Table.Insert(*Args) > >@@ -1869,10 +1870,12 @@ class DecParser(MetaFileParser): > ExtraData=3Dself._CurrentLine + \ > " ( =3D >)", > File=3Dself.MetaFile, Line=3Dself._LineIndex = + 1) > self._ValueList[0] =3D TokenList[0] > self._ValueList[1] =3D TokenList[1] >+ if self._ValueList[0] not in self._GuidDict: >+ self._GuidDict[self._ValueList[0]] =3D self._ValueList[1] > > ## PCD sections parser > # > # [PcdsFixedAtBuild] > # [PcdsPatchableInModule] >@@ -1985,16 +1988,18 @@ class DecParser(MetaFileParser): > 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] =3D=3D 'True': >- ValueList[0] =3D '1' >- if ValueList[0] =3D=3D 'False': >- ValueList[0] =3D '0' >- >+ 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) > # check format of default value against the datum type > IsValid, Cause =3D CheckPcdDatum(ValueList[1], ValueList[0]) > if not IsValid: > EdkLogger.error('Parser', FORMAT_INVALID, Cause, >ExtraData=3Dself._CurrentLine, > File=3Dself.MetaFile, Line=3Dself._LineIn= dex + 1) >diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py >b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py >index c289b9d..c760e57 100644 >--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py >+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py >@@ -1,9 +1,9 @@ > ## @file > # Common routines used by workspace > # >-# Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
>+# Copyright (c) 2012 - 2017, 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 may = be >found at > # http://opensource.org/licenses/bsd-license.php > # >@@ -41,28 +41,32 @@ def GetPackageList(Platform, BuildDatabase, Arch, >Target, Toolchain): > # @param BuildDatabase: The database saves all data for all metafiles > # @param Arch: Current arch > # @param Target: Current target > # @param Toolchain: Current toolchain > # @retval: A dictionary contains instances of PcdClassObject with key >(PcdCName, TokenSpaceGuid) >+# @retval: A dictionary contains real GUIDs of TokenSpaceGuid > # > def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, >Toolchain,additionalPkgs): > PkgList =3D GetPackageList(Platform, BuildDatabase, Arch, Target, Too= lchain) > PkgList =3D set(PkgList) > PkgList |=3D additionalPkgs > DecPcds =3D {} >+ GuidDict =3D {} > for Pkg in PkgList: >+ Guids =3D Pkg.Guids >+ GuidDict.update(Guids) > for Pcd in Pkg.Pcds: > PcdCName =3D Pcd[0] > PcdTokenName =3D Pcd[1] > if GlobalData.MixedPcd: > for PcdItem in GlobalData.MixedPcd.keys(): > if (PcdCName, PcdTokenName) in GlobalData.MixedPcd[Pc= dItem]: > PcdCName =3D PcdItem[0] > break > if (PcdCName, PcdTokenName) not in DecPcds.keys(): > DecPcds[PcdCName, PcdTokenName] =3D Pkg.Pcds[Pcd] >- return DecPcds >+ return DecPcds, GuidDict > > ## Get all dependent libraries for a module > # > # @param Module: InfBuildData instance > # @param Platform: DscBuildData instance >diff --git a/BaseTools/Source/Python/build/BuildReport.py >b/BaseTools/Source/Python/build/BuildReport.py >index 75e8ec9..5da9914 100644 >--- a/BaseTools/Source/Python/build/BuildReport.py >+++ b/BaseTools/Source/Python/build/BuildReport.py >@@ -43,10 +43,11 @@ 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 > > ## Pattern to extract contents in EDK DXS files > gDxsDependencyPattern =3D >re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL) > > ## Pattern to find total FV total size, occupied size in flash report >intermediate file >@@ -847,12 +848,15 @@ class PcdReport(object): > > # > # Collect PCD DEC default value. > # > self.DecPcdDefault =3D {} >+ self._GuidDict =3D {} > for Pa in Wa.AutoGenObjectList: > for Package in Pa.PackageList: >+ Guids =3D Package.Guids >+ self._GuidDict.update(Guids) > for (TokenCName, TokenSpaceGuidCName, DecType) in >Package.Pcds: > DecDefaultValue =3D Package.Pcds[TokenCName, >TokenSpaceGuidCName, DecType].DefaultValue > self.DecPcdDefault.setdefault((TokenCName, >TokenSpaceGuidCName, DecType), DecDefaultValue) > # > # Collect PCDs defined in DSC common section >@@ -941,10 +945,12 @@ 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: >+ DscDefaultValue =3D ValueExpressionEx(DscDefaultV= alue, >Pcd.DatumType, self._GuidDict)(True) > InfDefaultValue =3D None > > PcdValue =3D DecDefaultValue > if DscDefaultValue: > PcdValue =3D DscDefaultValue >-- >2.6.1.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel