BaseTools: Fix parse PCD GUID expression issue
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>
This commit is contained in:
committed by
mergify[bot]
parent
242ab73d7f
commit
ceacd9e992
@ -39,6 +39,7 @@ from Common.LongFilePathSupport import LongFilePath as LongFilePath
|
|||||||
from Common.MultipleWorkspace import MultipleWorkspace as mws
|
from Common.MultipleWorkspace import MultipleWorkspace as mws
|
||||||
from CommonDataClass.Exceptions import BadExpression
|
from CommonDataClass.Exceptions import BadExpression
|
||||||
from Common.caching import cached_property
|
from Common.caching import cached_property
|
||||||
|
import struct
|
||||||
|
|
||||||
ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
|
ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
|
||||||
## Regular expression used to find out place holders in string template
|
## Regular expression used to find out place holders in string template
|
||||||
@ -1155,13 +1156,12 @@ def ParseFieldValue (Value):
|
|||||||
if Value[0] == '"' and Value[-1] == '"':
|
if Value[0] == '"' and Value[-1] == '"':
|
||||||
Value = Value[1:-1]
|
Value = Value[1:-1]
|
||||||
try:
|
try:
|
||||||
Value = str(uuid.UUID(Value).bytes_le)
|
Value = uuid.UUID(Value).bytes_le
|
||||||
if Value.startswith("b'"):
|
ValueL, ValueH = struct.unpack('2Q', Value)
|
||||||
Value = Value[2:-1]
|
Value = (ValueH << 64 ) | ValueL
|
||||||
Value = "'" + Value + "'"
|
|
||||||
except ValueError as Message:
|
except ValueError as Message:
|
||||||
raise BadExpression(Message)
|
raise BadExpression(Message)
|
||||||
Value, Size = ParseFieldValue(Value)
|
|
||||||
return Value, 16
|
return Value, 16
|
||||||
if Value.startswith('L"') and Value.endswith('"'):
|
if Value.startswith('L"') and Value.endswith('"'):
|
||||||
# Unicode String
|
# Unicode String
|
||||||
|
Reference in New Issue
Block a user