[edk2] [Patch] BaseTools: Fixed incorrect Structure Pcd Value.

BobCF posted 1 patch 6 years, 10 months ago
Failed in applying to current master (apply log)
BaseTools/Source/Python/Workspace/DscBuildData.py | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
[edk2] [Patch] BaseTools: Fixed incorrect Structure Pcd Value.
Posted by BobCF 6 years, 10 months ago
When structurePCD only has overall value assigned
in Dsc under different SKU, the value under default sku is used.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 8833034a1e..0da3efbb43 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1283,11 +1283,14 @@ class DscBuildData(PlatformBuildClassObject):
             if str_pcd_dec:
                 str_pcd_obj_str = StructurePcd()
                 str_pcd_obj_str.copy(str_pcd_dec)
                 if str_pcd_obj:
                     str_pcd_obj_str.copy(str_pcd_obj)
-                str_pcd_obj_str.DefaultFromDSC = str_pcd_obj_str.DefaultValue
+                if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
+                    str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
+                else:
+                    str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
                 for str_pcd_data in StrPcdSet[str_pcd]:
                     if str_pcd_data[3] in SkuIds:
                         str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5])
                 S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str
             else:
@@ -1301,12 +1304,14 @@ class DscBuildData(PlatformBuildClassObject):
                     str_pcd_obj_str = StructurePcd()
                     str_pcd_obj_str.copy(self._DecPcds[Pcd])
                     str_pcd_obj = Pcds.get(Pcd, None)
                     if str_pcd_obj:
                         str_pcd_obj_str.copy(str_pcd_obj)
-                        if str_pcd_obj.DefaultValue:
-                            str_pcd_obj_str.DefaultFromDSC = str_pcd_obj.DefaultValue
+                        if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
+                            str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
+                        else:
+                            str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
                     S_pcd_set[Pcd] = str_pcd_obj_str
         if S_pcd_set:
             GlobalData.gStructurePcd[self.Arch] = S_pcd_set
         for stru_pcd in S_pcd_set.values():
             for skuid in SkuIds:
@@ -1695,29 +1700,30 @@ class DscBuildData(PlatformBuildClassObject):
             for skuname in self.SkuIdMgr.GetSkuChain(SkuName):
                 inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]
                 storeset = [DefaultStoreName] if DefaultStoreName == 'STANDARD' else ['STANDARD', DefaultStoreName]
                 for defaultstorenameitem in storeset:
                     CApp = CApp + "// SkuName: %s,  DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)
-                    for FieldList in [Pcd.DefaultFromDSC,inherit_OverrideValues.get(defaultstorenameitem)]:
+                    pcddefaultvalue = Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue
+                    for FieldList in [pcddefaultvalue,inherit_OverrideValues.get(defaultstorenameitem)]:
                         if not FieldList:
                             continue
-                        if Pcd.DefaultFromDSC and FieldList == Pcd.DefaultFromDSC:
+                        if pcddefaultvalue and FieldList == pcddefaultvalue:
                             IsArray = self.IsFieldValueAnArray(FieldList)
                             if IsArray:
                                 try:
                                     FieldList = ValueExpressionEx(FieldList, "VOID*")(True)
                                 except BadExpression:
                                     EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" %
                                                     (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))
                             Value, ValueSize = ParseFieldValue (FieldList)
                             if isinstance(Value, str):
-                                CApp = CApp + '  Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC)
+                                CApp = CApp + '  Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
                             elif IsArray:
                             #
                             # Use memcpy() to copy value into field
                             #
-                                CApp = CApp + '  Value     = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC)
+                                CApp = CApp + '  Value     = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
                                 CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
                             continue
                         for FieldName in FieldList:
                             IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
                             if IsArray:
-- 
2.14.3.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] BaseTools: Fixed incorrect Structure Pcd Value.
Posted by Gao, Liming 6 years, 10 months ago
Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Feng, Bob C
>Sent: Wednesday, February 07, 2018 12:10 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: Fixed incorrect Structure Pcd Value.
>
>When structurePCD only has overall value assigned
>in Dsc under different SKU, the value under default sku is used.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng <bob.c.feng@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>---
> BaseTools/Source/Python/Workspace/DscBuildData.py | 20
>+++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index 8833034a1e..0da3efbb43 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -1283,11 +1283,14 @@ class DscBuildData(PlatformBuildClassObject):
>             if str_pcd_dec:
>                 str_pcd_obj_str = StructurePcd()
>                 str_pcd_obj_str.copy(str_pcd_dec)
>                 if str_pcd_obj:
>                     str_pcd_obj_str.copy(str_pcd_obj)
>-                str_pcd_obj_str.DefaultFromDSC = str_pcd_obj_str.DefaultValue
>+                if str_pcd_obj.Type in
>[self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
>self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
>+                    str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
>str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
>str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in
>DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
>+                else:
>+                    str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
>str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
>str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in
>DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
>                 for str_pcd_data in StrPcdSet[str_pcd]:
>                     if str_pcd_data[3] in SkuIds:
>                         str_pcd_obj_str.AddOverrideValue(str_pcd_data[2],
>str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else
>str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else
>str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5])
>                 S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str
>             else:
>@@ -1301,12 +1304,14 @@ class DscBuildData(PlatformBuildClassObject):
>                     str_pcd_obj_str = StructurePcd()
>                     str_pcd_obj_str.copy(self._DecPcds[Pcd])
>                     str_pcd_obj = Pcds.get(Pcd, None)
>                     if str_pcd_obj:
>                         str_pcd_obj_str.copy(str_pcd_obj)
>-                        if str_pcd_obj.DefaultValue:
>-                            str_pcd_obj_str.DefaultFromDSC = str_pcd_obj.DefaultValue
>+                        if str_pcd_obj.Type in
>[self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
>self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
>+                            str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
>str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
>str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in
>DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
>+                        else:
>+                            str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
>str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
>str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in
>DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
>                     S_pcd_set[Pcd] = str_pcd_obj_str
>         if S_pcd_set:
>             GlobalData.gStructurePcd[self.Arch] = S_pcd_set
>         for stru_pcd in S_pcd_set.values():
>             for skuid in SkuIds:
>@@ -1695,29 +1700,30 @@ class DscBuildData(PlatformBuildClassObject):
>             for skuname in self.SkuIdMgr.GetSkuChain(SkuName):
>                 inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]
>                 storeset = [DefaultStoreName] if DefaultStoreName == 'STANDARD'
>else ['STANDARD', DefaultStoreName]
>                 for defaultstorenameitem in storeset:
>                     CApp = CApp + "// SkuName: %s,  DefaultStoreName: %s \n" %
>(skuname, defaultstorenameitem)
>-                    for FieldList in
>[Pcd.DefaultFromDSC,inherit_OverrideValues.get(defaultstorenameitem)]:
>+                    pcddefaultvalue =
>Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem,
>Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue
>+                    for FieldList in
>[pcddefaultvalue,inherit_OverrideValues.get(defaultstorenameitem)]:
>                         if not FieldList:
>                             continue
>-                        if Pcd.DefaultFromDSC and FieldList == Pcd.DefaultFromDSC:
>+                        if pcddefaultvalue and FieldList == pcddefaultvalue:
>                             IsArray = self.IsFieldValueAnArray(FieldList)
>                             if IsArray:
>                                 try:
>                                     FieldList = ValueExpressionEx(FieldList, "VOID*")(True)
>                                 except BadExpression:
>                                     EdkLogger.error("Build", FORMAT_INVALID, "Invalid value
>format for %s.%s, from DSC: %s" %
>                                                     (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,
>FieldList))
>                             Value, ValueSize = ParseFieldValue (FieldList)
>                             if isinstance(Value, str):
>-                                CApp = CApp + '  Pcd = %s; // From DSC Default Value %s\n' %
>(Value, Pcd.DefaultFromDSC)
>+                                CApp = CApp + '  Pcd = %s; // From DSC Default Value %s\n' %
>(Value, Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem,
>Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
>                             elif IsArray:
>                             #
>                             # Use memcpy() to copy value into field
>                             #
>-                                CApp = CApp + '  Value     = %s; // From DSC Default
>Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC)
>+                                CApp = CApp + '  Value     = %s; // From DSC Default
>Value %s\n' % (self.IntToCString(Value, ValueSize),
>Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem,
>Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)
>                                 CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
>                             continue
>                         for FieldName in FieldList:
>                             IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
>                             if IsArray:
>--
>2.14.3.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel