From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 24E13AC0EA2 for ; Fri, 1 Mar 2024 11:07:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=eEgVNuxZ2UCdRkpUEF41DcVK730y+9d4DSwK4XXRIzY=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1709291235; v=1; b=tcxYxnwRmb1gTFkpnZQvQoM85p4bBNmutOTTzOeDJT+GUW5INOl625VxKbbX3DABkM/8MFmn 9UJLzvMUwBn6rjoxwooEkPtxEQe+cpWhgWpSGI75vyNa6jLPxeMtYKiNKoHb5/sFBhtdCeB0n46 ujfMzGYm1oU4Ty79D3MnYZgc= X-Received: by 127.0.0.2 with SMTP id 2DSIYY7687511xTBFGb5r1Gk; Fri, 01 Mar 2024 03:07:15 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.20064.1709291235113003614 for ; Fri, 01 Mar 2024 03:07:15 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-103-OGXBuBrgNo2vw5sj-NPNbQ-1; Fri, 01 Mar 2024 06:07:11 -0500 X-MC-Unique: OGXBuBrgNo2vw5sj-NPNbQ-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDE22830DCD; Fri, 1 Mar 2024 11:07:10 +0000 (UTC) X-Received: from [10.39.194.215] (unknown [10.39.194.215]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4511B112D168; Fri, 1 Mar 2024 11:07:10 +0000 (UTC) Message-ID: Date: Fri, 1 Mar 2024 12:07:08 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH] BaseTools: PcdValueInit enhancement To: devel@edk2.groups.io, yuting2.yang@intel.com References: <20240301021011.1371-1-yuting2.yang@intel.com> From: "Laszlo Ersek" In-Reply-To: <20240301021011.1371-1-yuting2.yang@intel.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: xbGwQOk8SyJo7gZn2fIkulhQx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=tcxYxnwR; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 3/1/24 03:10, Yuting Yang wrote: > Enhance PcdValueInit for storage saving >=20 > Cc: Rebecca Cran rebecca@bsdio.com > Cc: Liming Gao gaoliming@byosoft.com.cn > Cc: Bob Feng bob.c.feng@intel.com > Signed-off-by: Yuting Yang > --- > .../Source/Python/Workspace/DscBuildData.py | 43 ++++++++++++++----- > 1 file changed, 33 insertions(+), 10 deletions(-) This patch looks like line noise. I don't intend to review it in depth, but the patch is unsuitable for a cursory read-through. The original code is unreadable to begin with; it seems that at least one removed line is 410 characters long. Please first refactor/reformat the original code so it becomes readable. Then in a second patch, implement the change, but also *document* in the commit message what you are trying to do, why, and (at a high level), how. The current commit message is worthless. Laszlo >=20 > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTool= s/Source/Python/Workspace/DscBuildData.py > index 5df184f9c8..e83188f4b3 100644 > --- a/BaseTools/Source/Python/Workspace/DscBuildData.py > +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py > @@ -1820,6 +1820,7 @@ class DscBuildData(PlatformBuildClassObject): > def GenerateSizeFunction(self, Pcd): > CApp =3D "// Default Value in Dec \n" > CApp =3D CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.To= kenSpaceGuidCName, Pcd.TokenCName) > + CAppList =3D [] > =20 > if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": > CApp +=3D " *Size =3D (sizeof (%s) > *Size ? sizeof (%s) : = *Size);\n" % (Pcd.DatumType,Pcd.DatumType) > @@ -1869,7 +1870,8 @@ class DscBuildData(PlatformBuildClassObject): > (".".join((Pcd.TokenSpaceGuidCNa= me, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")]= [1], FieldList[FieldName.strip(".")][2])) > Value, ValueSize =3D ParseFieldValue(Value) > if not Pcd.IsArray(): > - 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.st= rip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.Da= tumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldLis= t[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); > + CAppInfo =3D ' __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]); > + CAppList.append(CAppInfo.split(' //')[0]) > else: > NewFieldName =3D '' > FieldName_ori =3D FieldName.strip('.') > @@ -1880,7 +1882,8 @@ class DscBuildData(PlatformBuildClassObject): > FieldName =3D NewFieldName + FieldName > while '[' in FieldName and not Pcd.IsArray(): > FieldName =3D FieldName.rsplit('[', 1)[0] > - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s= , %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."= ), Array_Index + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2= ], FieldList[FieldName_ori][0]) > + CAppInfo =3D ' __FLEXIBLE_SIZE(*Size, %s, %s, %= d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), = Array_Index + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], = FieldList[FieldName_ori][0]) > + CAppList.append(CAppInfo.split(' //')[0]) > flexisbale_size_statement_cache =3D set() > for skuname in Pcd.SkuOverrideValues: > if skuname =3D=3D TAB_COMMON: > @@ -1908,7 +1911,10 @@ class DscBuildData(PlatformBuildClassObject): > (".".join((Pcd.Token= SpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName= .strip(".")][1], FieldList[FieldName.strip(".")][2])) > Value, ValueSize =3D ParseFieldValue(Val= ue) > if not Pcd.IsArray(): > - CApp =3D CApp + ' __FLEXIBLE_SIZE(*= Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_S= IZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, Fi= eldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSi= ze, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1]= , FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); > + CAppInfo =3D ' __FLEXIBLE_SIZE(*Siz= e, %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, Field= Name.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize,= Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], F= ieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); > + CAppInfoWithoutComment =3D CAppInfo.= split(' //')[0] > + if CAppInfoWithoutComment not in CAp= pList: > + CAppList.append(CAppInfoWithoutC= omment) > else: > NewFieldName =3D '' > FieldName_ori =3D FieldName.strip('.') > @@ -1919,9 +1925,12 @@ class DscBuildData(PlatformBuildClassObject): > FieldName =3D NewFieldName + FieldName > while '[' in FieldName and not Pcd.IsArr= ay(): > FieldName =3D FieldName.rsplit('[', = 1)[0] > - CApp =3D CApp + ' __FLEXIBLE_SIZE(*= Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldN= ame.strip("."), Array_Index + 1, FieldList[FieldName_ori][1], FieldList[Fie= ldName_ori][2], FieldList[FieldName_ori][0]) > + CAppInfo =3D ' __FLEXIBLE_SIZE(*Siz= e, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName= .strip("."), Array_Index + 1, FieldList[FieldName_ori][1], FieldList[FieldN= ame_ori][2], FieldList[FieldName_ori][0]) > + CAppInfoWithoutComment =3D CAppInfo.= split(' //')[0] > + if CAppInfoWithoutComment not in CAp= pList: > + CAppList.append(CAppInfoWithoutC= omment) > if Pcd.PcdFieldValueFromFdf: > - CApp =3D CApp + "// From fdf \n" > + CAppList.append("// From fdf \n") > for FieldName in Pcd.PcdFieldValueFromFdf: > FieldName =3D "." + FieldName > IsArray =3D _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[Fi= eldName.strip(".")][0]) > @@ -1933,7 +1942,10 @@ class DscBuildData(PlatformBuildClassObject): > (".".join((Pcd.TokenSpaceGuidCName, = Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromFdf[FieldName.= strip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2])) > Value, ValueSize =3D ParseFieldValue(Value) > if not Pcd.IsArray(): > - 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.DatumTyp= e, FieldName.strip("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1],= Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFd= f[FieldName.strip(".")][0]); > + CAppInfo =3D ' __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.DatumType, = FieldName.strip("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pc= d.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[F= ieldName.strip(".")][0]); > + CAppInfoWithoutComment =3D CAppInfo.split(' //')[0] > + if CAppInfoWithoutComment not in CAppList: > + CAppList.append(CAppInfoWithoutComment) > else: > NewFieldName =3D '' > FieldName_ori =3D FieldName.strip('.') > @@ -1944,9 +1956,12 @@ class DscBuildData(PlatformBuildClassObject): > FieldName =3D NewFieldName + FieldName > while '[' in FieldName: > FieldName =3D FieldName.rsplit('[', 1)[0] > - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d= ); // From %s Line %s Value %s \n' % (Pcd.DatumType, FieldName.strip("."), = Array_Index + 1, Pcd.PcdFieldValueFromFdf[FieldName_ori][1], Pcd.PcdFieldVa= lueFromFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0]) > + CAppInfo =3D ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); = // From %s Line %s Value %s \n' % (Pcd.DatumType, FieldName.strip("."), Arr= ay_Index + 1, Pcd.PcdFieldValueFromFdf[FieldName_ori][1], Pcd.PcdFieldValue= FromFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0]) > + CAppInfoWithoutComment =3D CAppInfo.split(' //')[0] > + if CAppInfoWithoutComment not in CAppList: > + CAppList.append(CAppInfoWithoutComment) > if Pcd.PcdFieldValueFromComm: > - CApp =3D CApp + "// From Command Line \n" > + CAppList.append("// From Command Line \n") > for FieldName in Pcd.PcdFieldValueFromComm: > FieldName =3D "." + FieldName > IsArray =3D _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[F= ieldName.strip(".")][0]) > @@ -1958,7 +1973,10 @@ class DscBuildData(PlatformBuildClassObject): > (".".join((Pcd.TokenSpaceGuidCName, = Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName= .strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2])) > Value, ValueSize =3D ParseFieldValue(Value) > if not Pcd.IsArray(): > - 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.DatumTyp= e, FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1]= , Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFrom= Comm[FieldName.strip(".")][0]); > + CAppInfo =3D ' __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.DatumType, = FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], P= cd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromCom= m[FieldName.strip(".")][0]); > + CAppInfoWithoutComment =3D CAppInfo.split(' //')[0] > + if CAppInfoWithoutComment not in CAppList: > + CAppList.append(CAppInfoWithoutComment) > else: > NewFieldName =3D '' > FieldName_ori =3D FieldName.strip('.') > @@ -1969,7 +1987,12 @@ class DscBuildData(PlatformBuildClassObject): > FieldName =3D NewFieldName + FieldName > while '[' in FieldName and not Pcd.IsArray(): > FieldName =3D FieldName.rsplit('[', 1)[0] > - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d= ); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), = Array_Index + 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldV= alueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0]= ) > + CAppInfo =3D ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); = // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), Arr= ay_Index + 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldValu= eFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0]) > + CAppInfoWithoutComment =3D CAppInfo.split(' //')[0] > + if CAppInfoWithoutComment not in CAppList: > + CAppList.append(CAppInfoWithoutComment) > + for item in CAppList: > + CApp +=3D item > if Pcd.GetPcdMaxSize(): > CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); // T= he Pcd maxsize is %d \n" % (Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(), Pcd.G= etPcdMaxSize()) > ArraySizeByAssign =3D self.CalculateActualCap(ActualCap) -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116231): https://edk2.groups.io/g/devel/message/116231 Mute This Topic: https://groups.io/mt/104657038/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-