mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-28 16:14:04 +02:00
BaseTools: Check pcd DefaultValue and SkuId EBNF.
1. When assign dynamic hii pcd value in dsc file, missed the DefaultValue, build should be fail. 2. Check the EBNF of SkuId. 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: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
b8bcaafb39
commit
24bd035c90
@ -1508,6 +1508,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
|
|||||||
Size = -1
|
Size = -1
|
||||||
return [VpdOffset, str(Size), Value], IsValid, 2
|
return [VpdOffset, str(Size), Value], IsValid, 2
|
||||||
elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII):
|
elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII):
|
||||||
|
IsValid = (3 <= len(FieldList) <= 5)
|
||||||
HiiString = FieldList[0]
|
HiiString = FieldList[0]
|
||||||
Guid = Offset = Value = Attribute = ''
|
Guid = Offset = Value = Attribute = ''
|
||||||
if len(FieldList) > 1:
|
if len(FieldList) > 1:
|
||||||
@ -1516,9 +1517,10 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
|
|||||||
Offset = FieldList[2]
|
Offset = FieldList[2]
|
||||||
if len(FieldList) > 3:
|
if len(FieldList) > 3:
|
||||||
Value = FieldList[3]
|
Value = FieldList[3]
|
||||||
|
if not Value:
|
||||||
|
IsValid = False
|
||||||
if len(FieldList) > 4:
|
if len(FieldList) > 4:
|
||||||
Attribute = FieldList[4]
|
Attribute = FieldList[4]
|
||||||
IsValid = (3 <= len(FieldList) <= 5)
|
|
||||||
return [HiiString, Guid, Offset, Value, Attribute], IsValid, 3
|
return [HiiString, Guid, Offset, Value, Attribute], IsValid, 3
|
||||||
return [], False, 0
|
return [], False, 0
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ LIBS = -lCommon
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
|
variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
|
||||||
|
SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
|
||||||
## regular expressions for finding decimal and hex numbers
|
## regular expressions for finding decimal and hex numbers
|
||||||
Pattern = re.compile('^[1-9]\d*|0$')
|
Pattern = re.compile('^[1-9]\d*|0$')
|
||||||
HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
|
HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
|
||||||
@ -631,8 +631,8 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
|
if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
|
||||||
EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",
|
EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",
|
||||||
File=self.MetaFile, Line=Record[-1])
|
File=self.MetaFile, Line=Record[-1])
|
||||||
if not IsValidWord(Record[1]):
|
if not SkuIdPattern.match(Record[1]) or (Record[2] and not SkuIdPattern.match(Record[2])):
|
||||||
EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'",
|
EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z_)(a-zA-Z0-9_)*'",
|
||||||
File=self.MetaFile, Line=Record[-1])
|
File=self.MetaFile, Line=Record[-1])
|
||||||
self._SkuIds[Record[1].upper()] = (str(DscBuildData.ToInt(Record[0])), Record[1].upper(), Record[2].upper())
|
self._SkuIds[Record[1].upper()] = (str(DscBuildData.ToInt(Record[0])), Record[1].upper(), Record[2].upper())
|
||||||
if TAB_DEFAULT not in self._SkuIds:
|
if TAB_DEFAULT not in self._SkuIds:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user