]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/Misc.py
BaseTools: Fix the bug for CArray PCD override in command line
[mirror_edk2.git] / BaseTools / Source / Python / Common / Misc.py
index 1a5968a221654c725dfc8625931d429d471b98c0..dbb711e96cefa02ea50d4f981c3d46beda31d0d1 100644 (file)
@@ -2006,7 +2006,7 @@ class SkuClass():
             except Exception:\r
                 EdkLogger.error("build", PARAMETER_INVALID,\r
                             ExtraData = "SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"\r
-                                      % (k, " ".join(SkuIds.keys())))\r
+                                      % (k, " ".join(SkuIds.keys())))\r
         if len(self.SkuIdSet) == 2 and 'DEFAULT' in self.SkuIdSet and SkuIdentifier != 'ALL':\r
             self.SkuIdSet.remove('DEFAULT')\r
             self.SkuIdNumberSet.remove('0U')\r
@@ -2016,7 +2016,7 @@ class SkuClass():
             else:\r
                 EdkLogger.error("build", PARAMETER_INVALID,\r
                             ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"\r
-                                      % (each, " ".join(SkuIds.keys())))\r
+                                      % (each, " ".join(SkuIds.keys())))\r
         \r
     def __SkuUsageType(self): \r
         \r
@@ -2062,6 +2062,32 @@ def PackRegistryFormatGuid(Guid):
                 int(Guid[4][-2:], 16)\r
                 )\r
 \r
+def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):\r
+    if PcdDatumType == 'VOID*':\r
+        if Value.startswith('L'):\r
+            if not Value[1]:\r
+                EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
+            Value = Value[0] + '"' + Value[1:] + '"'\r
+        elif Value.startswith('H'):\r
+            if not Value[1]:\r
+                EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
+            Value = Value[1:]\r
+        else:\r
+            if not Value[0]:\r
+                EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
+            Value = '"' + Value + '"'\r
+\r
+    IsValid, Cause = CheckPcdDatum(PcdDatumType, Value)\r
+    if not IsValid:\r
+        EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))\r
+    if PcdDatumType == 'BOOLEAN':\r
+        Value = Value.upper()\r
+        if Value == 'TRUE' or Value == '1':\r
+            Value = '1'\r
+        elif Value == 'FALSE' or Value == '0':\r
+            Value = '0'\r
+    return  Value\r
+\r
 ##\r
 #\r
 # This acts like the main() function for the script, unless it is 'import'ed into another\r