]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Fix parse PCD GUID expression issue
authorFeng, YunhuaX <YunhuaX.Feng@intel.com>
Sat, 9 May 2020 00:14:44 +0000 (08:14 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 13 May 2020 06:37:18 +0000 (06:37 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2686

The build tool will give an incorrect GUID value if the GUID includes character ' or " ASCII value.
This patch is going to fix this issue.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/Python/Common/Misc.py

index da5fb380f0354d6e885aa716d2c9b2fead249d63..ad556710802e8a0b839c8145daa27c0f920c87f0 100755 (executable)
@@ -39,6 +39,7 @@ from Common.LongFilePathSupport import LongFilePath as LongFilePath
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
 from CommonDataClass.Exceptions import BadExpression\r
 from Common.caching import cached_property\r
+import struct\r
 \r
 ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")\r
 ## Regular expression used to find out place holders in string template\r
@@ -1155,13 +1156,12 @@ def ParseFieldValue (Value):
         if Value[0] == '"' and Value[-1] == '"':\r
             Value = Value[1:-1]\r
         try:\r
-            Value = str(uuid.UUID(Value).bytes_le)\r
-            if Value.startswith("b'"):\r
-                Value = Value[2:-1]\r
-            Value = "'" + Value + "'"\r
+            Value = uuid.UUID(Value).bytes_le\r
+            ValueL, ValueH = struct.unpack('2Q', Value)\r
+            Value = (ValueH << 64 ) | ValueL\r
+\r
         except ValueError as Message:\r
             raise BadExpression(Message)\r
-        Value, Size = ParseFieldValue(Value)\r
         return Value, 16\r
     if Value.startswith('L"') and Value.endswith('"'):\r
         # Unicode String\r