[edk2-devel] [Patch] BaseTools: Remove the redundant __FLEXIBLE_SIZE from PcdValueInit.c

Bob Feng posted 1 patch 2 years, 1 month ago
Failed in applying to current master (apply log)
BaseTools/Source/Python/Workspace/DscBuildData.py | 5 +++++
1 file changed, 5 insertions(+)
[edk2-devel] [Patch] BaseTools: Remove the redundant __FLEXIBLE_SIZE from PcdValueInit.c
Posted by Bob Feng 2 years, 1 month ago
For the multiple SKU cases, basetools generates multiple redundant
__FLEXIBLE_SIZE statement that is from the same line in dsc file.

This behavior causes the generated PcdValueInit.c file to have huge size,
and the compilation time is very long.

This patch is going to fix this issue.

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index d29b9bf13d..fc1e773417 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1874,10 +1874,11 @@ class DscBuildData(PlatformBuildClassObject):
                         FieldName = FieldName.split(']', 1)[1]
                     FieldName = NewFieldName + FieldName
                     while '[' in FieldName and not Pcd.IsArray():
                         FieldName = FieldName.rsplit('[', 1)[0]
                         CApp = 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])
+        flexisbale_size_statement_cache = set()
         for skuname in Pcd.SkuOverrideValues:
             if skuname == TAB_COMMON:
                 continue
             for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]:
                 CApp = CApp + "// SkuName: %s,  DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)
@@ -1886,10 +1887,14 @@ class DscBuildData(PlatformBuildClassObject):
                         ActualCap.append(index)
                     for FieldList in [Pcd.SkuOverrideValues[skuname][defaultstorenameitem][index]]:
                         if not FieldList:
                             continue
                         for FieldName in FieldList:
+                            fieldinfo = tuple(FieldList[FieldName])
+                            if fieldinfo in flexisbale_size_statement_cache:
+                                continue
+                            flexisbale_size_statement_cache.add(fieldinfo)
                             FieldName = "." + FieldName
                             IsArray = _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
                             if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):
                                 try:
                                     Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
-- 
2.29.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87589): https://edk2.groups.io/g/devel/message/87589
Mute This Topic: https://groups.io/mt/89796157/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [Patch] BaseTools: Remove the redundant __FLEXIBLE_SIZE from PcdValueInit.c
Posted by Yuwei Chen 2 years, 1 month ago
This patch reduces compilation time , it looks good to me. 

Reviewed-by: Yuwei Chen<yuwei.chen@intel.com>

> -----Original Message-----
> From: Feng, Bob C <bob.c.feng@intel.com>
> Sent: Tuesday, March 15, 2022 8:17 PM
> To: devel@edk2.groups.io
> Cc: Gao, Liming <gaoliming@byosoft.com.cn>; Chen, Christine
> <yuwei.chen@intel.com>
> Subject: [Patch] BaseTools: Remove the redundant __FLEXIBLE_SIZE from
> PcdValueInit.c
> 
> For the multiple SKU cases, basetools generates multiple redundant
> __FLEXIBLE_SIZE statement that is from the same line in dsc file.
> 
> This behavior causes the generated PcdValueInit.c file to have huge size, and
> the compilation time is very long.
> 
> This patch is going to fix this issue.
> 
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>Cc: Liming Gao
> <gaoliming@byosoft.com.cn>Cc: Yuwei Chen <yuwei.chen@intel.com>
> ---
>  BaseTools/Source/Python/Workspace/DscBuildData.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
> b/BaseTools/Source/Python/Workspace/DscBuildData.py
> index d29b9bf13d..fc1e773417 100644
> --- a/BaseTools/Source/Python/Workspace/DscBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
> @@ -1874,10 +1874,11 @@ class DscBuildData(PlatformBuildClassObject):
>                          FieldName = FieldName.split(']', 1)[1]                     FieldName =
> NewFieldName + FieldName                     while '[' in FieldName and not
> Pcd.IsArray():                         FieldName = FieldName.rsplit('[', 1)[0]
> CApp = 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])+        flexisbale_size_statement_cache = set()
> for skuname in Pcd.SkuOverrideValues:             if skuname == TAB_COMMON:
> continue             for defaultstorenameitem in
> Pcd.SkuOverrideValues[skuname]:                 CApp = CApp + "// SkuName: %s,
> DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)@@ -1886,10
> +1887,14 @@ class DscBuildData(PlatformBuildClassObject):
>                          ActualCap.append(index)                     for FieldList in
> [Pcd.SkuOverrideValues[skuname][defaultstorenameitem][index]]:
> if not FieldList:                             continue                         for FieldName in
> FieldList:+                            fieldinfo = tuple(FieldList[FieldName])+
> if fieldinfo in flexisbale_size_statement_cache:+                                continue+
> flexisbale_size_statement_cache.add(fieldinfo)                             FieldName =
> "." + FieldName                             IsArray =
> _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])                             if
> IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and
> FieldList[FieldName.strip(".")][0].endswith('}')):                                 try:
> Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID,
> self._GuidDict)(True)--
> 2.29.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87774): https://edk2.groups.io/g/devel/message/87774
Mute This Topic: https://groups.io/mt/89796157/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-