BaseTools: Report error when GUID format is incorrect

Flexible GUID format of PCD value support following format, so tool should report
error when it is not correct.
1. { GUID("11E13869-1896-4A07-8B21-D8B23DD2A2B4") }
2. { GUID({ 0x11e13869, 0x1896, 0x4a07,{
    0x8b, 0x21, 0xd8, 0xb2, 0x3d, 0xd2, 0xa2, 0xb4 } }) }
3. { GUID(gEfiBlockIoProtocolGuid) }

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Feng, YunhuaX 2018-02-05 11:42:33 +08:00 committed by Yonghong Zhu
parent 8ad5f10a2b
commit 4344a788c4
1 changed files with 4 additions and 10 deletions

View File

@ -1535,16 +1535,10 @@ def ParseFieldValue (Value):
if Value.startswith('GUID') and Value.endswith(')'):
Value = Value.split('(', 1)[1][:-1].strip()
if Value[0] == '{' and Value[-1] == '}':
Value = Value[1:-1].strip()
Value = Value.split('{', 1)
Value = ['%02x' % int(Item, 16) for Item in (Value[0] + Value[1][:-1]).split(',')]
if len(Value[0]) != 8:
Value[0] = '%08X' % int(Value[0], 16)
if len(Value[1]) != 4:
Value[1] = '%04X' % int(Value[1], 16)
if len(Value[2]) != 4:
Value[2] = '%04X' % int(Value[2], 16)
Value = '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '-' + ''.join(Value[5:11])
TmpValue = GuidStructureStringToGuidString(Value)
if len(TmpValue) == 0:
raise BadExpression("Invalid GUID value string %s" % Value)
Value = TmpValue
if Value[0] == '"' and Value[-1] == '"':
Value = Value[1:-1]
try: