public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Correct Structure Pcd value in the report
@ 2018-03-02 14:52 Yonghong Zhu
  2018-03-03  4:34 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-03-02 14:52 UTC (permalink / raw)
  To: edk2-devel

The patch "Fixed build failed issue" changed structure Pcd Object, so
we need update build report to correct structure Pcd Value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/build/BuildReport.py | 72 ++++++++++++++++++++++++----
 1 file changed, 63 insertions(+), 9 deletions(-)

diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index b2cc6ee..f4d2c75 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -956,11 +956,11 @@ class PcdReport(object):
                     DscDefaultValBak = DscDefaultValue
                     DscDefaultValue = self.FdfPcdSet.get((Pcd.TokenCName, Key), DscDefaultValue)
                     if DscDefaultValue != DscDefaultValBak:
                         try:
                             DscDefaultValue = ValueExpressionEx(DscDefaultValue, Pcd.DatumType, self._GuidDict)(True)
-                        except BadExpression, Value:
+                        except BadExpression, DscDefaultValue:
                             EdkLogger.error('BuildReport', FORMAT_INVALID, "PCD Value: %s, Type: %s" %(DscDefaultValue, Pcd.DatumType))
 
                     InfDefaultValue = None
                     
                     PcdValue = DecDefaultValue
@@ -1031,13 +1031,46 @@ class PcdReport(object):
                             SkuInfoList = Pcd.SkuInfoList
                         Pcd = GlobalData.gStructurePcd[self.Arch][(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)]
                         Pcd.DatumType = Pcd.StructName
                         if TypeName in ('DYNVPD', 'DEXVPD'):
                             Pcd.SkuInfoList = SkuInfoList
-                        if Pcd.SkuOverrideValues:
-                            DscMatch = True
+                        if Pcd.PcdFieldValueFromComm:
+                            BuildOptionMatch = True
                             DecMatch = False
+                        elif Pcd.SkuOverrideValues:
+                            DscOverride = False
+                            if not Pcd.SkuInfoList:
+                                OverrideValues = Pcd.SkuOverrideValues
+                                if OverrideValues:
+                                    Keys = OverrideValues.keys()
+                                    Data = OverrideValues[Keys[0]]
+                                    Struct = Data.values()[0]
+                                    DscOverride = self.ParseStruct(Struct)
+                            else:
+                                SkuList = sorted(Pcd.SkuInfoList.keys())
+                                for Sku in SkuList:
+                                    SkuInfo = Pcd.SkuInfoList[Sku]
+                                    if TypeName in ('DYNHII', 'DEXHII'):
+                                        if SkuInfo.DefaultStoreDict:
+                                            DefaultStoreList = sorted(SkuInfo.DefaultStoreDict.keys())
+                                            for DefaultStore in DefaultStoreList:
+                                                OverrideValues = Pcd.SkuOverrideValues[Sku]
+                                                DscOverride = self.ParseStruct(OverrideValues[DefaultStore])
+                                                if DscOverride:
+                                                    break
+                                    else:
+                                        OverrideValues = Pcd.SkuOverrideValues[Sku]
+                                        if OverrideValues:
+                                            Keys = OverrideValues.keys()
+                                            OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[Keys[0]])
+                                            DscOverride = self.ParseStruct(OverrideFieldStruct)
+                                    if DscOverride:
+                                        break
+                            if DscOverride:
+                                DscMatch = True
+                                DecMatch = False
+
                     #
                     # Report PCD item according to their override relationship
                     #
                     if DecMatch and InfMatch:
                         self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, '  ')
@@ -1080,10 +1113,18 @@ class PcdReport(object):
             FileWrite(File, gSectionEnd)
         else:
             if not ReportSubType and ModulePcdSet:
                 FileWrite(File, gSubSectionEnd)
 
+    def ParseStruct(self, struct):
+        HasDscOverride = False
+        if struct:
+            for _, Values in struct.items():
+                if Values[1] and Values[1].endswith('.dsc'):
+                    HasDscOverride = True
+                    break
+        return HasDscOverride
 
     def PrintPcdDefault(self, File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue):
         if not DscMatch and DscDefaultValue != None:
             Value = DscDefaultValue.strip()
             IsByteArray, ArrayList = ByteArrayForamt(Value)
@@ -1112,10 +1153,12 @@ class PcdReport(object):
                     FileWrite(File, '%s' % (Array))
             else:
                 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)
 
     def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, Flag = '  '):
         if not Pcd.SkuInfoList:
             Value = Pcd.DefaultValue
             IsByteArray, ArrayList = ByteArrayForamt(Value)
@@ -1129,11 +1172,12 @@ class PcdReport(object):
                 OverrideValues = Pcd.SkuOverrideValues
                 if OverrideValues:
                     Keys = OverrideValues.keys()
                     Data = OverrideValues[Keys[0]]
                     Struct = Data.values()[0]
-                    self.PrintStructureInfo(File, Struct)
+                    OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct)
+                    self.PrintStructureInfo(File, OverrideFieldStruct)
             self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue)
         else:
             FirstPrint = True
             SkuList = sorted(Pcd.SkuInfoList.keys())
             for Sku in SkuList:
@@ -1189,12 +1233,12 @@ class PcdReport(object):
                                     else:
                                         FileWrite(File, ' %-*s   : %6s %10s %10s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', Value))
                             FileWrite(File, '%*s: %s: %s' % (self.MaxLen + 4, SkuInfo.VariableGuid, SkuInfo.VariableName, SkuInfo.VariableOffset))
                             if IsStructure:
                                 OverrideValues = Pcd.SkuOverrideValues[Sku]
-                                Struct = OverrideValues[DefaultStore]
-                                self.PrintStructureInfo(File, Struct)
+                                OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[DefaultStore])
+                                self.PrintStructureInfo(File, OverrideFieldStruct)
                             self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue)
                 else:
                     Value = SkuInfo.DefaultValue
                     IsByteArray, ArrayList = ByteArrayForamt(Value)
                     if FirstPrint:
@@ -1228,16 +1272,26 @@ class PcdReport(object):
                         FileWrite(File, '%*s' % (self.MaxLen + 4, SkuInfo.VpdOffset))
                     if IsStructure:
                         OverrideValues = Pcd.SkuOverrideValues[Sku]
                         if OverrideValues:
                             Keys = OverrideValues.keys()
-                            Struct = OverrideValues[Keys[0]]
-                            self.PrintStructureInfo(File, Struct)
+                            OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[Keys[0]])
+                            self.PrintStructureInfo(File, OverrideFieldStruct)
                     self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue)
 
+    def OverrideFieldValue(self, Pcd, OverrideStruct):
+        OverrideFieldStruct = collections.OrderedDict()
+        if OverrideStruct:
+            for Key, Values in OverrideStruct.items():
+                if Values[1] and Values[1].endswith('.dsc'):
+                    OverrideFieldStruct[Key] = Values
+        if Pcd.PcdFieldValueFromComm:
+            for Key, Values in Pcd.PcdFieldValueFromComm.items():
+                OverrideFieldStruct[Key] = Values
+        return OverrideFieldStruct
+
     def PrintStructureInfo(self, File, Struct):
-        NewInfo = collections.OrderedDict()
         for Key, Value in Struct.items():
             if Value[1] and 'build command options' in Value[1]:
                 FileWrite(File, '    *B  %-*s = %s' % (self.MaxLen + 4, '.' + Key, Value[0]))
             else:
                 FileWrite(File, '        %-*s = %s' % (self.MaxLen + 4, '.' + Key, Value[0]))
-- 
2.6.1.windows.1



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

* Re: [Patch] BaseTools: Correct Structure Pcd value in the report
  2018-03-02 14:52 [Patch] BaseTools: Correct Structure Pcd value in the report Yonghong Zhu
@ 2018-03-03  4:34 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-03-03  4:34 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yonghong Zhu
> Sent: Friday, March 2, 2018 10:53 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [Patch] BaseTools: Correct Structure Pcd value in the report
> 
> The patch "Fixed build failed issue" changed structure Pcd Object, so
> we need update build report to correct structure Pcd Value.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
>  BaseTools/Source/Python/build/BuildReport.py | 72 ++++++++++++++++++++++++----
>  1 file changed, 63 insertions(+), 9 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
> index b2cc6ee..f4d2c75 100644
> --- a/BaseTools/Source/Python/build/BuildReport.py
> +++ b/BaseTools/Source/Python/build/BuildReport.py
> @@ -956,11 +956,11 @@ class PcdReport(object):
>                      DscDefaultValBak = DscDefaultValue
>                      DscDefaultValue = self.FdfPcdSet.get((Pcd.TokenCName, Key), DscDefaultValue)
>                      if DscDefaultValue != DscDefaultValBak:
>                          try:
>                              DscDefaultValue = ValueExpressionEx(DscDefaultValue, Pcd.DatumType, self._GuidDict)(True)
> -                        except BadExpression, Value:
> +                        except BadExpression, DscDefaultValue:
>                              EdkLogger.error('BuildReport', FORMAT_INVALID, "PCD Value: %s, Type: %s" %(DscDefaultValue,
> Pcd.DatumType))
> 
>                      InfDefaultValue = None
> 
>                      PcdValue = DecDefaultValue
> @@ -1031,13 +1031,46 @@ class PcdReport(object):
>                              SkuInfoList = Pcd.SkuInfoList
>                          Pcd = GlobalData.gStructurePcd[self.Arch][(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)]
>                          Pcd.DatumType = Pcd.StructName
>                          if TypeName in ('DYNVPD', 'DEXVPD'):
>                              Pcd.SkuInfoList = SkuInfoList
> -                        if Pcd.SkuOverrideValues:
> -                            DscMatch = True
> +                        if Pcd.PcdFieldValueFromComm:
> +                            BuildOptionMatch = True
>                              DecMatch = False
> +                        elif Pcd.SkuOverrideValues:
> +                            DscOverride = False
> +                            if not Pcd.SkuInfoList:
> +                                OverrideValues = Pcd.SkuOverrideValues
> +                                if OverrideValues:
> +                                    Keys = OverrideValues.keys()
> +                                    Data = OverrideValues[Keys[0]]
> +                                    Struct = Data.values()[0]
> +                                    DscOverride = self.ParseStruct(Struct)
> +                            else:
> +                                SkuList = sorted(Pcd.SkuInfoList.keys())
> +                                for Sku in SkuList:
> +                                    SkuInfo = Pcd.SkuInfoList[Sku]
> +                                    if TypeName in ('DYNHII', 'DEXHII'):
> +                                        if SkuInfo.DefaultStoreDict:
> +                                            DefaultStoreList = sorted(SkuInfo.DefaultStoreDict.keys())
> +                                            for DefaultStore in DefaultStoreList:
> +                                                OverrideValues = Pcd.SkuOverrideValues[Sku]
> +                                                DscOverride = self.ParseStruct(OverrideValues[DefaultStore])
> +                                                if DscOverride:
> +                                                    break
> +                                    else:
> +                                        OverrideValues = Pcd.SkuOverrideValues[Sku]
> +                                        if OverrideValues:
> +                                            Keys = OverrideValues.keys()
> +                                            OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[Keys[0]])
> +                                            DscOverride = self.ParseStruct(OverrideFieldStruct)
> +                                    if DscOverride:
> +                                        break
> +                            if DscOverride:
> +                                DscMatch = True
> +                                DecMatch = False
> +
>                      #
>                      # Report PCD item according to their override relationship
>                      #
>                      if DecMatch and InfMatch:
>                          self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValBak,
> InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, '  ')
> @@ -1080,10 +1113,18 @@ class PcdReport(object):
>              FileWrite(File, gSectionEnd)
>          else:
>              if not ReportSubType and ModulePcdSet:
>                  FileWrite(File, gSubSectionEnd)
> 
> +    def ParseStruct(self, struct):
> +        HasDscOverride = False
> +        if struct:
> +            for _, Values in struct.items():
> +                if Values[1] and Values[1].endswith('.dsc'):
> +                    HasDscOverride = True
> +                    break
> +        return HasDscOverride
> 
>      def PrintPcdDefault(self, File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch,
> DecDefaultValue):
>          if not DscMatch and DscDefaultValue != None:
>              Value = DscDefaultValue.strip()
>              IsByteArray, ArrayList = ByteArrayForamt(Value)
> @@ -1112,10 +1153,12 @@ class PcdReport(object):
>                      FileWrite(File, '%s' % (Array))
>              else:
>                  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)
> 
>      def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValue, InfMatch,
> InfDefaultValue, DecMatch, DecDefaultValue, Flag = '  '):
>          if not Pcd.SkuInfoList:
>              Value = Pcd.DefaultValue
>              IsByteArray, ArrayList = ByteArrayForamt(Value)
> @@ -1129,11 +1172,12 @@ class PcdReport(object):
>                  OverrideValues = Pcd.SkuOverrideValues
>                  if OverrideValues:
>                      Keys = OverrideValues.keys()
>                      Data = OverrideValues[Keys[0]]
>                      Struct = Data.values()[0]
> -                    self.PrintStructureInfo(File, Struct)
> +                    OverrideFieldStruct = self.OverrideFieldValue(Pcd, Struct)
> +                    self.PrintStructureInfo(File, OverrideFieldStruct)
>              self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch,
> DecDefaultValue)
>          else:
>              FirstPrint = True
>              SkuList = sorted(Pcd.SkuInfoList.keys())
>              for Sku in SkuList:
> @@ -1189,12 +1233,12 @@ class PcdReport(object):
>                                      else:
>                                          FileWrite(File, ' %-*s   : %6s %10s %10s %10s = %s' % (self.MaxLen, ' ', TypeName,
> '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', Value))
>                              FileWrite(File, '%*s: %s: %s' % (self.MaxLen + 4, SkuInfo.VariableGuid, SkuInfo.VariableName,
> SkuInfo.VariableOffset))
>                              if IsStructure:
>                                  OverrideValues = Pcd.SkuOverrideValues[Sku]
> -                                Struct = OverrideValues[DefaultStore]
> -                                self.PrintStructureInfo(File, Struct)
> +                                OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[DefaultStore])
> +                                self.PrintStructureInfo(File, OverrideFieldStruct)
>                              self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue,
> DecMatch, DecDefaultValue)
>                  else:
>                      Value = SkuInfo.DefaultValue
>                      IsByteArray, ArrayList = ByteArrayForamt(Value)
>                      if FirstPrint:
> @@ -1228,16 +1272,26 @@ class PcdReport(object):
>                          FileWrite(File, '%*s' % (self.MaxLen + 4, SkuInfo.VpdOffset))
>                      if IsStructure:
>                          OverrideValues = Pcd.SkuOverrideValues[Sku]
>                          if OverrideValues:
>                              Keys = OverrideValues.keys()
> -                            Struct = OverrideValues[Keys[0]]
> -                            self.PrintStructureInfo(File, Struct)
> +                            OverrideFieldStruct = self.OverrideFieldValue(Pcd, OverrideValues[Keys[0]])
> +                            self.PrintStructureInfo(File, OverrideFieldStruct)
>                      self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch,
> DecDefaultValue)
> 
> +    def OverrideFieldValue(self, Pcd, OverrideStruct):
> +        OverrideFieldStruct = collections.OrderedDict()
> +        if OverrideStruct:
> +            for Key, Values in OverrideStruct.items():
> +                if Values[1] and Values[1].endswith('.dsc'):
> +                    OverrideFieldStruct[Key] = Values
> +        if Pcd.PcdFieldValueFromComm:
> +            for Key, Values in Pcd.PcdFieldValueFromComm.items():
> +                OverrideFieldStruct[Key] = Values
> +        return OverrideFieldStruct
> +
>      def PrintStructureInfo(self, File, Struct):
> -        NewInfo = collections.OrderedDict()
>          for Key, Value in Struct.items():
>              if Value[1] and 'build command options' in Value[1]:
>                  FileWrite(File, '    *B  %-*s = %s' % (self.MaxLen + 4, '.' + Key, Value[0]))
>              else:
>                  FileWrite(File, '        %-*s = %s' % (self.MaxLen + 4, '.' + Key, Value[0]))
> --
> 2.6.1.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

end of thread, other threads:[~2018-03-03  4:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-02 14:52 [Patch] BaseTools: Correct Structure Pcd value in the report Yonghong Zhu
2018-03-03  4:34 ` Gao, Liming

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