public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Display both Hex and integer value format of PCD value
@ 2018-06-05 12:37 Yonghong Zhu
  2018-06-06  0:47 ` Zhu, Yonghong
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-06-05 12:37 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yunhua Feng, Liming Gao

From: Yunhua Feng <yunhuax.feng@intel.com>

If the PCD's datum type is UINT8, UINT16, UINT32 or UINT64, then in
the report will display both hexadecimal format and integer format
of PCD value.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 BaseTools/Source/Python/build/BuildReport.py | 40 ++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index ad05c4a..61ea645 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -1138,29 +1138,44 @@ class PcdReport(object):
             if IsByteArray:
                 FileWrite(File, '    %*s = %s' % (self.MaxLen + 19, 'DSC DEFAULT', "{"))
                 for Array in ArrayList:
                     FileWrite(File, '%s' % (Array))
             else:
+                if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
+                    if Value.startswith(('0x', '0X')):
+                        Value = '{} ({:d})'.format(Value, int(Value, 0))
+                    else:
+                        Value = "0x{:X} ({})".format(int(Value, 0), Value)
                 FileWrite(File, '    %*s = %s' % (self.MaxLen + 19, 'DSC DEFAULT', Value))
         if not InfMatch and InfDefaultValue is not None:
             Value = InfDefaultValue.strip()
             IsByteArray, ArrayList = ByteArrayForamt(Value)
             if IsByteArray:
                 FileWrite(File, '    %*s = %s' % (self.MaxLen + 19, 'INF DEFAULT', "{"))
                 for Array in ArrayList:
                     FileWrite(File, '%s' % (Array))
             else:
+                if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
+                    if Value.startswith(('0x', '0X')):
+                        Value = '{} ({:d})'.format(Value, int(Value, 0))
+                    else:
+                        Value = "0x{:X} ({})".format(int(Value, 0), Value)
                 FileWrite(File, '    %*s = %s' % (self.MaxLen + 19, 'INF DEFAULT', Value))
 
         if not DecMatch and DecDefaultValue is not None:
             Value = DecDefaultValue.strip()
             IsByteArray, ArrayList = ByteArrayForamt(Value)
             if IsByteArray:
                 FileWrite(File, '    %*s = %s' % (self.MaxLen + 19, 'DEC DEFAULT', "{"))
                 for Array in ArrayList:
                     FileWrite(File, '%s' % (Array))
             else:
+                if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
+                    if Value.startswith(('0x', '0X')):
+                        Value = '{} ({:d})'.format(Value, int(Value, 0))
+                    else:
+                        Value = "0x{:X} ({})".format(int(Value, 0), Value)
                 FileWrite(File, '    %*s = %s' % (self.MaxLen + 19, 'DEC DEFAULT', Value))
             if IsStructure:
                 self.PrintStructureInfo(File, Pcd.DefaultValues)
         if DecMatch and IsStructure:
             self.PrintStructureInfo(File, Pcd.DefaultValues)
@@ -1172,10 +1187,15 @@ class PcdReport(object):
             if IsByteArray:
                 FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '{'))
                 for Array in ArrayList:
                     FileWrite(File, '%s' % (Array))
             else:
+                if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
+                    if Value.startswith(('0x','0X')):
+                        Value = '{} ({:d})'.format(Value, int(Value, 0))
+                    else:
+                        Value = "0x{:X} ({})".format(int(Value, 0), Value)
                 FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value))
             if IsStructure:
                 OverrideValues = Pcd.SkuOverrideValues
                 if OverrideValues:
                     Keys = OverrideValues.keys()
@@ -1208,10 +1228,15 @@ class PcdReport(object):
                                     else:
                                         FileWrite(File, ' %-*s   : %6s %10s %10s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', '{'))
                                     for Array in ArrayList:
                                         FileWrite(File, '%s' % (Array))
                                 else:
+                                    if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
+                                        if Value.startswith(('0x', '0X')):
+                                            Value = '{} ({:d})'.format(Value, int(Value, 0))
+                                        else:
+                                            Value = "0x{:X} ({})".format(int(Value, 0), Value)
                                     if self.DefaultStoreSingle and self.SkuSingle:
                                         FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value))
                                     elif self.DefaultStoreSingle and not self.SkuSingle:
                                         FileWrite(File, ' %-*s   : %6s %10s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', Value))
                                     elif not self.DefaultStoreSingle and self.SkuSingle:
@@ -1229,10 +1254,15 @@ class PcdReport(object):
                                     else:
                                         FileWrite(File, ' %-*s   : %6s %10s %10s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', '{'))
                                     for Array in ArrayList:
                                         FileWrite(File, '%s' % (Array))
                                 else:
+                                    if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
+                                        if Value.startswith(('0x', '0X')):
+                                            Value = '{} ({:d})'.format(Value, int(Value, 0))
+                                        else:
+                                            Value = "0x{:X} ({})".format(int(Value, 0), Value)
                                     if self.DefaultStoreSingle and self.SkuSingle:
                                         FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')',  Value))
                                     elif self.DefaultStoreSingle and not self.SkuSingle:
                                         FileWrite(File, ' %-*s   : %6s %10s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', Value))
                                     elif not self.DefaultStoreSingle and self.SkuSingle:
@@ -1256,10 +1286,15 @@ class PcdReport(object):
                             else:
                                 FileWrite(File, ' %-*s   : %6s %10s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', "{"))
                             for Array in ArrayList:
                                 FileWrite(File, '%s' % (Array))
                         else:
+                            if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
+                                if Value.startswith(('0x', '0X')):
+                                    Value = '{} ({:d})'.format(Value, int(Value, 0))
+                                else:
+                                    Value = "0x{:X} ({})".format(int(Value, 0), Value)
                             if self.SkuSingle:
                                 FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value))
                             else:
                                 FileWrite(File, ' %-*s   : %6s %10s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', Value))
                     else:
@@ -1269,10 +1304,15 @@ class PcdReport(object):
                             else:
                                 FileWrite(File, ' %-*s   : %6s %10s %10s = %s' % (self.MaxLen, ' ' , TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', "{"))
                             for Array in ArrayList:
                                 FileWrite(File, '%s' % (Array))
                         else:
+                            if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:
+                                if Value.startswith(('0x', '0X')):
+                                    Value = '{} ({:d})'.format(Value, int(Value, 0))
+                                else:
+                                    Value = "0x{:X} ({})".format(int(Value, 0), Value)
                             if self.SkuSingle:
                                 FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, ' ' , TypeName, '(' + Pcd.DatumType + ')', Value))
                             else:
                                 FileWrite(File, ' %-*s   : %6s %10s %10s = %s' % (self.MaxLen, ' ' , TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', Value))
                     if TypeName in ('DYNVPD', 'DEXVPD'):
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-06  0:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-05 12:37 [Patch] BaseTools: Display both Hex and integer value format of PCD value Yonghong Zhu
2018-06-06  0:47 ` Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox