From nobody Mon Dec 23 11:03:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1517554172283603.1831373983131; Thu, 1 Feb 2018 22:49:32 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BF8292239363B; Thu, 1 Feb 2018 22:43:52 -0800 (PST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 426262238B5BF for ; Thu, 1 Feb 2018 22:43:51 -0800 (PST) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:49:28 -0800 Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga006.jf.intel.com with ESMTP; 01 Feb 2018 22:49:28 -0800 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 1 Feb 2018 22:49:27 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 1 Feb 2018 22:49:27 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.192]) with mapi id 14.03.0319.002; Fri, 2 Feb 2018 14:49:25 +0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=yunhuax.feng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="dat'59?scan'59,208,59";a="15320781" From: "Feng, YunhuaX" To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH] BaseTools: StructurePcd array Value support flexible format Thread-Index: AdOb8fYaDOvso8mtTN6BKwYnV2JzLQ== Date: Fri, 2 Feb 2018 06:49:24 +0000 Message-ID: <47C64442C08CCD4089DC43B6B5E46BC48229AB@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: <47C64442C08CCD4089DC43B6B5E46BC48229AB@shsmsx102.ccr.corp.intel.com> x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 Subject: [edk2] [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: , Cc: "Gao, Liming" Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Yonghong Zhu =20 --- 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 " % + (".".join((Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName, FieldName)), FieldList[FieldName][1],FieldList[FieldN= ame][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" % + (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 " % + (".".join((Pcd.TokenSpaceG= uidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[F= ieldName][2])) + try: Value, ValueSize =3D ParseFieldValue (FieldLis= t[FieldName][0]) except Exception: --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel