* [edk2-devel] [PATCH] BaseTools: PcdValueInit enhancement
@ 2024-03-01 2:10 Yuting Yang
2024-03-01 11:07 ` Laszlo Ersek
0 siblings, 1 reply; 2+ messages in thread
From: Yuting Yang @ 2024-03-01 2:10 UTC (permalink / raw)
To: devel
Enhance PcdValueInit for storage saving
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 <yuting2.yang@intel.com>
---
.../Source/Python/Workspace/DscBuildData.py | 43 ++++++++++++++-----
1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/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 = "// Default Value in Dec \n"
CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+ CAppList = []
if Pcd.IsArray() and Pcd.Capacity[-1] != "-1":
CApp += " *Size = (sizeof (%s) > *Size ? sizeof (%s) : *Size);\n" % (Pcd.DatumType,Pcd.DatumType)
@@ -1869,7 +1870,8 @@ class DscBuildData(PlatformBuildClassObject):
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
Value, ValueSize = ParseFieldValue(Value)
if not Pcd.IsArray():
- CApp = 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.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
+ CAppInfo = ' __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("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
+ CAppList.append(CAppInfo.split(' //')[0])
else:
NewFieldName = ''
FieldName_ori = FieldName.strip('.')
@@ -1880,7 +1882,8 @@ class DscBuildData(PlatformBuildClassObject):
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])
+ CAppInfo = ' __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 = set()
for skuname in Pcd.SkuOverrideValues:
if skuname == TAB_COMMON:
@@ -1908,7 +1911,10 @@ class DscBuildData(PlatformBuildClassObject):
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
Value, ValueSize = ParseFieldValue(Value)
if not Pcd.IsArray():
- CApp = 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.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
+ CAppInfo = ' __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("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
else:
NewFieldName = ''
FieldName_ori = FieldName.strip('.')
@@ -1919,9 +1925,12 @@ class DscBuildData(PlatformBuildClassObject):
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])
+ CAppInfo = ' __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])
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
if Pcd.PcdFieldValueFromFdf:
- CApp = CApp + "// From fdf \n"
+ CAppList.append("// From fdf \n")
for FieldName in Pcd.PcdFieldValueFromFdf:
FieldName = "." + FieldName
IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.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 = ParseFieldValue(Value)
if not Pcd.IsArray():
- CApp = 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.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]);
+ CAppInfo = ' __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], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]);
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
else:
NewFieldName = ''
FieldName_ori = FieldName.strip('.')
@@ -1944,9 +1956,12 @@ class DscBuildData(PlatformBuildClassObject):
FieldName = NewFieldName + FieldName
while '[' in FieldName:
FieldName = FieldName.rsplit('[', 1)[0]
- CApp = 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.PcdFieldValueFromFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0])
+ CAppInfo = ' __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.PcdFieldValueFromFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0])
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
if Pcd.PcdFieldValueFromComm:
- CApp = CApp + "// From Command Line \n"
+ CAppList.append("// From Command Line \n")
for FieldName in Pcd.PcdFieldValueFromComm:
FieldName = "." + FieldName
IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.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 = ParseFieldValue(Value)
if not Pcd.IsArray():
- CApp = 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.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]);
+ CAppInfo = ' __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], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]);
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
else:
NewFieldName = ''
FieldName_ori = FieldName.strip('.')
@@ -1969,7 +1987,12 @@ class DscBuildData(PlatformBuildClassObject):
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, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldValueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])
+ CAppInfo = ' __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.PcdFieldValueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])
+ CAppInfoWithoutComment = CAppInfo.split(' //')[0]
+ if CAppInfoWithoutComment not in CAppList:
+ CAppList.append(CAppInfoWithoutComment)
+ for item in CAppList:
+ CApp += item
if Pcd.GetPcdMaxSize():
CApp = CApp + " *Size = (%d > *Size ? %d : *Size); // The Pcd maxsize is %d \n" % (Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize())
ArraySizeByAssign = self.CalculateActualCap(ActualCap)
--
2.26.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116201): https://edk2.groups.io/g/devel/message/116201
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-devel] [PATCH] BaseTools: PcdValueInit enhancement
2024-03-01 2:10 [edk2-devel] [PATCH] BaseTools: PcdValueInit enhancement Yuting Yang
@ 2024-03-01 11:07 ` Laszlo Ersek
0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2024-03-01 11:07 UTC (permalink / raw)
To: devel, yuting2.yang
On 3/1/24 03:10, Yuting Yang wrote:
> Enhance PcdValueInit for storage saving
>
> 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 <yuting2.yang@intel.com>
> ---
> .../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
>
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/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 = "// Default Value in Dec \n"
> CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
> + CAppList = []
>
> if Pcd.IsArray() and Pcd.Capacity[-1] != "-1":
> CApp += " *Size = (sizeof (%s) > *Size ? sizeof (%s) : *Size);\n" % (Pcd.DatumType,Pcd.DatumType)
> @@ -1869,7 +1870,8 @@ class DscBuildData(PlatformBuildClassObject):
> (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
> Value, ValueSize = ParseFieldValue(Value)
> if not Pcd.IsArray():
> - CApp = 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.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
> + CAppInfo = ' __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("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
> + CAppList.append(CAppInfo.split(' //')[0])
> else:
> NewFieldName = ''
> FieldName_ori = FieldName.strip('.')
> @@ -1880,7 +1882,8 @@ class DscBuildData(PlatformBuildClassObject):
> 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])
> + CAppInfo = ' __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 = set()
> for skuname in Pcd.SkuOverrideValues:
> if skuname == TAB_COMMON:
> @@ -1908,7 +1911,10 @@ class DscBuildData(PlatformBuildClassObject):
> (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
> Value, ValueSize = ParseFieldValue(Value)
> if not Pcd.IsArray():
> - CApp = 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.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
> + CAppInfo = ' __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("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
> + CAppInfoWithoutComment = CAppInfo.split(' //')[0]
> + if CAppInfoWithoutComment not in CAppList:
> + CAppList.append(CAppInfoWithoutComment)
> else:
> NewFieldName = ''
> FieldName_ori = FieldName.strip('.')
> @@ -1919,9 +1925,12 @@ class DscBuildData(PlatformBuildClassObject):
> 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])
> + CAppInfo = ' __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])
> + CAppInfoWithoutComment = CAppInfo.split(' //')[0]
> + if CAppInfoWithoutComment not in CAppList:
> + CAppList.append(CAppInfoWithoutComment)
> if Pcd.PcdFieldValueFromFdf:
> - CApp = CApp + "// From fdf \n"
> + CAppList.append("// From fdf \n")
> for FieldName in Pcd.PcdFieldValueFromFdf:
> FieldName = "." + FieldName
> IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.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 = ParseFieldValue(Value)
> if not Pcd.IsArray():
> - CApp = 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.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]);
> + CAppInfo = ' __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], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]);
> + CAppInfoWithoutComment = CAppInfo.split(' //')[0]
> + if CAppInfoWithoutComment not in CAppList:
> + CAppList.append(CAppInfoWithoutComment)
> else:
> NewFieldName = ''
> FieldName_ori = FieldName.strip('.')
> @@ -1944,9 +1956,12 @@ class DscBuildData(PlatformBuildClassObject):
> FieldName = NewFieldName + FieldName
> while '[' in FieldName:
> FieldName = FieldName.rsplit('[', 1)[0]
> - CApp = 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.PcdFieldValueFromFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0])
> + CAppInfo = ' __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.PcdFieldValueFromFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0])
> + CAppInfoWithoutComment = CAppInfo.split(' //')[0]
> + if CAppInfoWithoutComment not in CAppList:
> + CAppList.append(CAppInfoWithoutComment)
> if Pcd.PcdFieldValueFromComm:
> - CApp = CApp + "// From Command Line \n"
> + CAppList.append("// From Command Line \n")
> for FieldName in Pcd.PcdFieldValueFromComm:
> FieldName = "." + FieldName
> IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.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 = ParseFieldValue(Value)
> if not Pcd.IsArray():
> - CApp = 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.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]);
> + CAppInfo = ' __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], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]);
> + CAppInfoWithoutComment = CAppInfo.split(' //')[0]
> + if CAppInfoWithoutComment not in CAppList:
> + CAppList.append(CAppInfoWithoutComment)
> else:
> NewFieldName = ''
> FieldName_ori = FieldName.strip('.')
> @@ -1969,7 +1987,12 @@ class DscBuildData(PlatformBuildClassObject):
> 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, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldValueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])
> + CAppInfo = ' __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.PcdFieldValueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])
> + CAppInfoWithoutComment = CAppInfo.split(' //')[0]
> + if CAppInfoWithoutComment not in CAppList:
> + CAppList.append(CAppInfoWithoutComment)
> + for item in CAppList:
> + CApp += item
> if Pcd.GetPcdMaxSize():
> CApp = CApp + " *Size = (%d > *Size ? %d : *Size); // The Pcd maxsize is %d \n" % (Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize())
> ArraySizeByAssign = self.CalculateActualCap(ActualCap)
-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-01 11:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01 2:10 [edk2-devel] [PATCH] BaseTools: PcdValueInit enhancement Yuting Yang
2024-03-01 11:07 ` Laszlo Ersek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox