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


Bob Feng
 

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@...>=0D
Cc: Liming Gao <gaoliming@...>=0D
Cc: Yuwei Chen <yuwei.chen@...>
---
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 =3D FieldName.split(']', 1)[1]=0D
FieldName =3D NewFieldName + FieldName=0D
while '[' in FieldName and not Pcd.IsArray():=0D
FieldName =3D FieldName.rsplit('[', 1)[0]=0D
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])=0D
+ flexisbale_size_statement_cache =3D set()=0D
for skuname in Pcd.SkuOverrideValues:=0D
if skuname =3D=3D TAB_COMMON:=0D
continue=0D
for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]:=0D
CApp =3D CApp + "// SkuName: %s, DefaultStoreName: %s \n"=
% (skuname, defaultstorenameitem)=0D
@@ -1886,10 +1887,14 @@ class DscBuildData(PlatformBuildClassObject):
ActualCap.append(index)=0D
for FieldList in [Pcd.SkuOverrideValues[skuname][defau=
ltstorenameitem][index]]:=0D
if not FieldList:=0D
continue=0D
for FieldName in FieldList:=0D
+ fieldinfo =3D tuple(FieldList[FieldName])=0D
+ if fieldinfo in flexisbale_size_statement_cach=
e:=0D
+ continue=0D
+ flexisbale_size_statement_cache.add(fieldinfo)=
=0D
FieldName =3D "." + FieldName=0D
IsArray =3D _IsFieldValueAnArray(FieldList[Fie=
ldName.strip(".")][0])=0D
if IsArray and not (FieldList[FieldName.strip(=
".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswit=
h('}')):=0D
try:=0D
Value =3D ValueExpressionEx(FieldList[=
FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)=0D
--=20
2.29.1.windows.1

Join devel@edk2.groups.io to automatically receive all group messages.