]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Convert "Unicode string" to "byte array" if value type diff
authorZhaozh1x <zhiqiangx.zhao@intel.com>
Thu, 18 Oct 2018 02:42:34 +0000 (10:42 +0800)
committerLiming Gao <liming.gao@intel.com>
Mon, 22 Oct 2018 07:19:27 +0000 (15:19 +0800)
V2:
Fixed 3 typo.
Use startswith(('L"',"L'")) to check if a string is Unicode string.
Use a set PcdValueTypeSet instead of a list PcdValueTypeList to save
memory.

V1:
For the same one VOID* pcd, if the default value type of one SKU is
"Unicode string", the other SKUs are "OtherVOID*"(ASCII string or
byte array),Then convert "Unicode string" to "byte array".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/Workspace/DscBuildData.py

index 17e6f62cacc0827ea16a09612b47f39f6c1da715..b0e88a93ce7fb7bef29817e88e753bee7f974626 100644 (file)
@@ -2878,6 +2878,15 @@ class DscBuildData(PlatformBuildClassObject):
             elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList:\r
                 del pcd.SkuInfoList[TAB_COMMON]\r
 \r
+        #For the same one VOID* pcd, if the default value type of one SKU is "Unicode string",\r
+        #the other SKUs are "OtherVOID*"(ASCII string or byte array),Then convert "Unicode string" to "byte array".\r
+        for pcd in Pcds.values():\r
+            PcdValueTypeSet = set()\r
+            for sku in pcd.SkuInfoList.values():\r
+                PcdValueTypeSet.add("UnicodeString" if sku.DefaultValue.startswith(('L"',"L'")) else "OtherVOID*")\r
+            if len(PcdValueTypeSet) > 1:\r
+                for sku in pcd.SkuInfoList.values():\r
+                    sku.DefaultValue = StringToArray(sku.DefaultValue) if sku.DefaultValue.startswith(('L"',"L'")) else sku.DefaultValue\r
 \r
         map(self.FilterSkuSettings, Pcds.values())\r
         return Pcds\r