]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Fix a bug override Pcd by DSC Components section
authorYonghong Zhu <yonghong.zhu@intel.com>
Mon, 26 Feb 2018 07:36:47 +0000 (15:36 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 28 Feb 2018 05:40:07 +0000 (13:40 +0800)
The case is: define a VOID* pcd in DEC file, eg: Value is {0x1}.
then override this PCD on DSC component section, eg: Value is
{0x1, 0x2, 0x3}, the max size of this PCD is calculate wrong
which cause build error.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/Workspace/DscBuildData.py

index 1787decd1d9e8127fc0f70149a63d3feebad302e..e2589cfbaeb32b9dbbb52fb7362c51c7e7af8d1c 100644 (file)
@@ -2421,7 +2421,7 @@ class PlatformAutoGen(AutoGen):
             ToPcd.validlists = FromPcd.validlists\r
             ToPcd.expressions = FromPcd.expressions\r
 \r
-        if ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:\r
+        if FromPcd != None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:\r
             EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \\r
                             % (ToPcd.TokenSpaceGuidCName, TokenCName))\r
             Value = ToPcd.DefaultValue\r
@@ -2494,6 +2494,19 @@ class PlatformAutoGen(AutoGen):
                             break\r
                 if Flag:\r
                     self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)\r
+        # use PCD value to calculate the MaxDatumSize when it is not specified\r
+        for Name, Guid in Pcds:\r
+            Pcd = Pcds[Name, Guid]\r
+            if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:\r
+                Value = Pcd.DefaultValue\r
+                if Value in [None, '']:\r
+                    Pcd.MaxDatumSize = '1'\r
+                elif Value[0] == 'L':\r
+                    Pcd.MaxDatumSize = str((len(Value) - 2) * 2)\r
+                elif Value[0] == '{':\r
+                    Pcd.MaxDatumSize = str(len(Value.split(',')))\r
+                else:\r
+                    Pcd.MaxDatumSize = str(len(Value) - 1)\r
         return Pcds.values()\r
 \r
     ## Resolve library names to library modules\r
index ea8d1847f757abbad6bf6f1f1bddfc5e973fdfbe..66402c52b7364064d4c83ad1af84a1d49be141b7 100644 (file)
@@ -679,8 +679,9 @@ class DscBuildData(PlatformBuildClassObject):
                 for TokenSpaceGuid, PcdCName, Setting, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:\r
                     TokenList = GetSplitValueList(Setting)\r
                     DefaultValue = TokenList[0]\r
-                    if len(TokenList) > 1:\r
-                        MaxDatumSize = TokenList[1]\r
+                    # the format is PcdName| Value | VOID* | MaxDatumSize\r
+                    if len(TokenList) > 2:\r
+                        MaxDatumSize = TokenList[2]\r
                     else:\r
                         MaxDatumSize = ''\r
                     TypeString = self._PCD_TYPE_STRING_[Type]\r