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.115; helo=mga14.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 034242237A4FD for ; Sat, 3 Feb 2018 19:01:13 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Feb 2018 19:06:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,457,1511856000"; d="scan'208";a="15688902" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga006.jf.intel.com with ESMTP; 03 Feb 2018 19:06:53 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 3 Feb 2018 19:06:52 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by shsmsx102.ccr.corp.intel.com ([169.254.2.124]) with mapi id 14.03.0319.002; Sun, 4 Feb 2018 11:06:51 +0800 From: "Zhu, Yonghong" To: "Feng, YunhuaX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH] BaseTools: StructurePcd array Value support flexible format Thread-Index: AdOb8fYaDOvso8mtTN6BKwYnV2JzLQBczB9g Date: Sun, 4 Feb 2018 03:06:50 +0000 Message-ID: References: <47C64442C08CCD4089DC43B6B5E46BC48229AB@shsmsx102.ccr.corp.intel.com> In-Reply-To: <47C64442C08CCD4089DC43B6B5E46BC48229AB@shsmsx102.ccr.corp.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: StructurePcd array Value support flexible 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: Sun, 04 Feb 2018 03:01:14 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Feng, YunhuaX=20 Sent: Friday, February 02, 2018 2:49 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong ; Gao, Liming Subject: [PATCH] BaseTools: StructurePcd array Value support flexible forma= t if StructurePcd set item value is array, support flexible format like as: gEfiStructuredPcdPkgTokenSpaceGuid.Test.Array | {flexible format} {flexible= format} =3D {L"ABC"} | {L'ABC'} | {"ABC"} | {UINT8(0x10)} | {UINT16(0x10)} | {UINT32(0x10)} | {UINT64(0x10)} | {DEVICE_PATH("PciRoot(0)/Pci(0,0)")} | {GUID(gPcdPkgTokenSpaceGuid)} | {L"ABC", L'ABC', UINT8(0x10)....} Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Workspace/DscBuildData.py | 35 +++++++++++++++++++= ++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index ad5b267fd1..1da4f03ab8 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1528,7 +1528,12 @@ class DscBuildData(PlatformBuildClassObject): FieldName =3D "." + FieldName IsArray =3D self.IsFieldValueAnArray(FieldList[FieldNa= me.strip(".")][0]) if IsArray: - Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName.strip(".")][0]) + try: + Value =3D ValueExpressionEx(FieldList[FieldNam= e.strip(".")][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "Inva= lid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip("."= )][1], FieldList[FieldName.strip(".")][2])) + Value, ValueSize =3D ParseFieldValue(Value) CApp =3D CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %= d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? = 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip= ("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.Datum= Type, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[F= ieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); else: NewFieldName =3D '' @@ -1550,7 +1555,12 @@ class DscBuildData(PlatformBuildClassObject): FieldName =3D "." + FieldName IsArray =3D self.IsFieldValueAnArray(FieldList[Fie= ldName.strip(".")][0]) if IsArray: - Value, ValueSize =3D ParseFieldValue (FieldLis= t[FieldName.strip(".")][0]) + try: + Value =3D ValueExpressionEx(FieldList[Fiel= dName.strip(".")][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "= Invalid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceG= uidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip= (".")][1], FieldList[FieldName.strip(".")][2])) + Value, ValueSize =3D ParseFieldValue(Value) CApp =3D CApp + ' __FLEXIBLE_SIZE(Size, %s, %= s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)= ) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.str= ip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.Dat= umType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList= [FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); else: NewFieldName =3D '' @@ -1588,6 +1598,13 @@ class DscBuildData(PlatformBuildClassObject): continue for FieldName in FieldList: IsArray =3D self.IsFieldValueAnArray(FieldList[FieldNa= me][0]) + if IsArray: + try: + FieldList[FieldName][0] =3D ValueExpressionEx(= FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "Inva= lid value format for %s. From %s Line %d " % + =20 + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)),=20 + FieldList[FieldName][1],FieldList[FieldName][2])) + try: Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName][0]) except Exception: @@ -1613,6 +1630,13 @@ class DscBuildData(PlatformBuildClassObject): continue if Pcd.DefaultFromDSC and FieldList =3D=3D Pcd.Default= FromDSC: IsArray =3D self.IsFieldValueAnArray(FieldList) + if IsArray: + try: + FieldList =3D ValueExpressionEx(FieldList,= "VOID*")(True) + except BadExpression: + EdkLogger.error("Build", FORMAT_INVALID, "= Invalid value format for %s.%s, from DSC: %s" % + =20 + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList)) + Value, ValueSize =3D ParseFieldValue (FieldList) if isinstance(Value, str): CApp =3D CApp + ' Pcd =3D %s; // From DSC Def= ault Value %s\n' % (Value, Pcd.DefaultFromDSC) @@ -1626,6 +1650,13 @@ class= DscBuildData(PlatformBuildClassObject): =20 for FieldName in FieldList: IsArray =3D self.IsFieldValueAnArray(FieldList[Fie= ldName][0]) + if IsArray: + try: + FieldList[FieldName][0] =3D ValueExpressio= nEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "= Invalid value format for %s. From %s Line %d " % + =20 + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)),=20 + FieldList[FieldName][1], FieldList[FieldName][2])) + try: Value, ValueSize =3D ParseFieldValue (FieldLis= t[FieldName][0]) except Exception: -- 2.12.2.windows.2