From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 8C2C321E082B2 for ; Fri, 2 Mar 2018 20:28:04 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 20:34:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,415,1515484800"; d="scan'208";a="208475027" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 02 Mar 2018 20:34:13 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Mar 2018 20:34:13 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Mar 2018 20:34:13 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.125]) by shsmsx102.ccr.corp.intel.com ([169.254.2.124]) with mapi id 14.03.0319.002; Sat, 3 Mar 2018 12:34:11 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" Thread-Topic: [Patch V2] BaseTools: DSC Components section support flexible PCD Thread-Index: AQHTsoywi1yreIgEEEuM7B2861BKhaO97J6Q Date: Sat, 3 Mar 2018 04:34:11 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1D6AFF@SHSMSX104.ccr.corp.intel.com> References: <1520039538-11204-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1520039538-11204-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch V2] BaseTools: DSC Components section support flexible PCD 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: Sat, 03 Mar 2018 04:28:05 -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: Saturday, March 3, 2018 9:12 AM > To: edk2-devel@lists.01.org > Cc: Feng, YunhuaX ; Gao, Liming > Subject: [Patch V2] BaseTools: DSC Components section support flexible PC= D >=20 > From: Yunhua Feng >=20 > DSC Components section support flexible PCD, and for binary driver, we > need patch this value. Update the split char ',' not ', ' because some > value may have space, while others may not have this space. >=20 > Cc: Liming Gao > Cc: Yonghong Zhu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Yunhua Feng > Signed-off-by: Yonghong Zhu > --- > BaseTools/Source/Python/GenFds/FfsInfStatement.py | 15 ++++++++++++= +++ > BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 3 ++- > 2 files changed, 17 insertions(+), 1 deletion(-) >=20 > diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTool= s/Source/Python/GenFds/FfsInfStatement.py > index b0b242b..dfff892 100644 > --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py > +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py > @@ -44,10 +44,11 @@ from PatchPcdValue.PatchPcdValue import PatchBinaryFi= le > from Common.LongFilePathSupport import CopyLongFilePath > from Common.LongFilePathSupport import OpenLongFilePath as open > import Common.GlobalData as GlobalData > from DepexSection import DepexSection > from Common.Misc import SaveFileOnChange > +from Common.Expression import * >=20 > ## generate FFS from INF > # > # > class FfsInfStatement(FfsInfStatementClassObject): > @@ -277,10 +278,24 @@ class FfsInfStatement(FfsInfStatementClassObject): > BuildOptionOverride =3D True > break >=20 > if not DscOverride and not FdfOverride and not BuildOptionOv= erride: > continue > + > + # Support Flexible PCD format > + if DefaultValue: > + try: > + DefaultValue =3D ValueExpressionEx(DefaultValue, Pcd= .DatumType, Platform._GuidDict)(True) > + except BadExpression: > + EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s]= Value "%s"' %(Pcd.TokenSpaceGuidCName, > Pcd.TokenCName, DefaultValue), File=3Dself.InfFileName) > + > + if Pcd.DefaultValue: > + try: > + Pcd.DefaultValue =3D ValueExpressionEx(Pcd.DefaultVa= lue, Pcd.DatumType, Platform._GuidDict)(True) > + except BadExpression: > + EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s]= Value "%s"' %(Pcd.TokenSpaceGuidCName, > Pcd.TokenCName, Pcd.DefaultValue),File=3Dself.InfFileName) > + > # Check value, if value are equal, no need to patch > if Pcd.DatumType =3D=3D "VOID*": > if Pcd.DefaultValue =3D=3D DefaultValue or DefaultValue = in [None, '']: > continue > # Get the string size from FDF or DSC > diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/Bas= eTools/Source/Python/PatchPcdValue/PatchPcdValue.py > index 882da81..942ba88 100644 > --- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py > +++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py > @@ -159,14 +159,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName= , ValueString, MaxSize=3D0): > Index =3D Index + 2 > elif ValueString.startswith("{") and ValueString.endswith("}"): > # > # Patch {0x1, 0x2, ...} byte by byte > # > - ValueList =3D ValueString[1 : len(ValueString) - 1].split(',= ') > + ValueList =3D ValueString[1 : len(ValueString) - 1].split(',= ') > Index =3D 0 > try: > for ByteString in ValueList: > + ByteString =3D ByteString.strip() > if ByteString.upper().startswith('0X'): > ByteValue =3D int(ByteString, 16) > else: > ByteValue =3D int(ByteString) > ByteList[ValueOffset + Index] =3D ByteValue % 0x100 > -- > 2.6.1.windows.1