BaseTools: create and use a standard shared variable for '*'
add a variable for the string '*' and then use it instead of lots of '*' Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by : Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
@ -31,6 +31,7 @@ TAB_OPTION_START = '<'
|
||||
TAB_OPTION_END = '>'
|
||||
TAB_SLASH = '\\'
|
||||
TAB_BACK_SLASH = '/'
|
||||
TAB_STAR = '*'
|
||||
TAB_LINE_BREAK = '\n'
|
||||
TAB_PRINTCHAR_VT = '\x0b'
|
||||
TAB_PRINTCHAR_BS = '\b'
|
||||
|
@ -244,7 +244,7 @@ class ValueExpression(BaseExpression):
|
||||
'IN' : 'in'
|
||||
}
|
||||
|
||||
NonLetterOpLst = ['+', '-', '*', '/', '%', '&', '|', '^', '~', '<<', '>>', '!', '=', '>', '<', '?', ':']
|
||||
NonLetterOpLst = ['+', '-', TAB_STAR, '/', '%', '&', '|', '^', '~', '<<', '>>', '!', '=', '>', '<', '?', ':']
|
||||
|
||||
|
||||
SymbolPattern = re.compile("("
|
||||
@ -498,7 +498,7 @@ class ValueExpression(BaseExpression):
|
||||
|
||||
# A [ * B]*
|
||||
def _MulExpr(self):
|
||||
return self._ExprFuncTemplate(self._UnaryExpr, {"*", "/", "%"})
|
||||
return self._ExprFuncTemplate(self._UnaryExpr, {TAB_STAR, "/", "%"})
|
||||
|
||||
# [!]*A
|
||||
def _UnaryExpr(self):
|
||||
|
@ -1088,7 +1088,7 @@ class tdict:
|
||||
_ListType = type([])
|
||||
_TupleType = type(())
|
||||
_Wildcard = 'COMMON'
|
||||
_ValidWildcardList = ['COMMON', 'DEFAULT', 'ALL', '*', 'PLATFORM']
|
||||
_ValidWildcardList = ['COMMON', 'DEFAULT', 'ALL', TAB_STAR, 'PLATFORM']
|
||||
|
||||
def __init__(self, _Single_=False, _Level_=2):
|
||||
self._Level_ = _Level_
|
||||
|
@ -29,7 +29,8 @@ from Common import GlobalData
|
||||
from Common.MultipleWorkspace import MultipleWorkspace as mws
|
||||
from .DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\
|
||||
TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE\
|
||||
, TAB_TOD_DEFINES_FAMILY, TAB_TOD_DEFINES_BUILDRULEFAMILY
|
||||
, TAB_TOD_DEFINES_FAMILY, TAB_TOD_DEFINES_BUILDRULEFAMILY,\
|
||||
TAB_STAR, TAB_TAT_DEFINES_TOOL_CHAIN_CONF
|
||||
|
||||
|
||||
##
|
||||
@ -97,7 +98,7 @@ class ToolDefClassObject(object):
|
||||
# adding/removing items from the original dict.
|
||||
for Key in list(self.ToolsDefTxtDictionary.keys()):
|
||||
List = Key.split('_')
|
||||
if List[Index] == '*':
|
||||
if List[Index] == TAB_STAR:
|
||||
for String in self.ToolsDefTxtDatabase[KeyList[Index]]:
|
||||
List[Index] = String
|
||||
NewKey = '%s_%s_%s_%s_%s' % tuple(List)
|
||||
@ -202,20 +203,20 @@ class ToolDefClassObject(object):
|
||||
if len(List) != 5:
|
||||
EdkLogger.verbose("Line %d: Not a valid name of definition: %s" % ((Index + 1), Name))
|
||||
continue
|
||||
elif List[4] == '*':
|
||||
elif List[4] == TAB_STAR:
|
||||
EdkLogger.verbose("Line %d: '*' is not allowed in last field: %s" % ((Index + 1), Name))
|
||||
continue
|
||||
else:
|
||||
self.ToolsDefTxtDictionary[Name] = Value
|
||||
if List[0] != '*':
|
||||
if List[0] != TAB_STAR:
|
||||
self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET] += [List[0]]
|
||||
if List[1] != '*':
|
||||
if List[1] != TAB_STAR:
|
||||
self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG] += [List[1]]
|
||||
if List[2] != '*':
|
||||
if List[2] != TAB_STAR:
|
||||
self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH] += [List[2]]
|
||||
if List[3] != '*':
|
||||
if List[3] != TAB_STAR:
|
||||
self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE] += [List[3]]
|
||||
if List[4] == TAB_TOD_DEFINES_FAMILY and List[2] == '*' and List[3] == '*':
|
||||
if List[4] == TAB_TOD_DEFINES_FAMILY and List[2] == TAB_STAR and List[3] == TAB_STAR:
|
||||
if TAB_TOD_DEFINES_FAMILY not in self.ToolsDefTxtDatabase:
|
||||
self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY] = {}
|
||||
self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][List[1]] = Value
|
||||
@ -226,7 +227,7 @@ class ToolDefClassObject(object):
|
||||
self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMILY][List[1]] = Value
|
||||
elif self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][List[1]] != Value:
|
||||
EdkLogger.verbose("Line %d: No override allowed for the family of a tool chain: %s" % ((Index + 1), Name))
|
||||
if List[4] == TAB_TOD_DEFINES_BUILDRULEFAMILY and List[2] == '*' and List[3] == '*':
|
||||
if List[4] == TAB_TOD_DEFINES_BUILDRULEFAMILY and List[2] == TAB_STAR and List[3] == TAB_STAR:
|
||||
if TAB_TOD_DEFINES_BUILDRULEFAMILY not in self.ToolsDefTxtDatabase \
|
||||
or List[1] not in self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY]:
|
||||
EdkLogger.verbose("Line %d: The family is not specified, but BuildRuleFamily is specified for the tool chain: %s" % ((Index + 1), Name))
|
||||
@ -270,8 +271,8 @@ class ToolDefClassObject(object):
|
||||
def ToolDefDict(ConfDir):
|
||||
Target = TargetTxtDict(ConfDir)
|
||||
ToolDef = ToolDefClassObject()
|
||||
if DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF in Target.TargetTxtDictionary:
|
||||
ToolsDefFile = Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
|
||||
if TAB_TAT_DEFINES_TOOL_CHAIN_CONF in Target.TargetTxtDictionary:
|
||||
ToolsDefFile = Target.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
|
||||
if ToolsDefFile:
|
||||
ToolDef.LoadToolDefFile(os.path.normpath(ToolsDefFile))
|
||||
else:
|
||||
|
@ -57,7 +57,7 @@ FILE_COMMENT_TEMPLATE = \
|
||||
# <PcdName> ::= <TokenSpaceCName> "." <PcdCName>
|
||||
# <TokenSpaceCName> ::= C Variable Name of the Token Space GUID
|
||||
# <PcdCName> ::= C Variable Name of the PCD
|
||||
# <Offset> ::= {"*"} {<HexNumber>}
|
||||
# <Offset> ::= {TAB_STAR} {<HexNumber>}
|
||||
# <HexNumber> ::= "0x" (a-fA-F0-9){1,8}
|
||||
# <Size> ::= <HexNumber>
|
||||
# <Value> ::= {<HexNumber>} {<NonNegativeInt>} {<QString>} {<Array>}
|
||||
@ -92,7 +92,7 @@ class VpdInfoFile:
|
||||
if (Vpd is None):
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOWN_ERROR, "Invalid VPD PCD entry.")
|
||||
|
||||
if not (Offset >= 0 or Offset == "*"):
|
||||
if not (Offset >= 0 or Offset == TAB_STAR):
|
||||
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid offset parameter: %s." % Offset)
|
||||
|
||||
if Vpd.DatumType == TAB_VOID:
|
||||
@ -186,8 +186,8 @@ class VpdInfoFile:
|
||||
VpdObjectTokenCName = PcdItem[0]
|
||||
for sku in VpdObject.SkuInfoList:
|
||||
if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:
|
||||
if self._VpdArray[VpdObject][sku] == "*":
|
||||
if Offset == "*":
|
||||
if self._VpdArray[VpdObject][sku] == TAB_STAR:
|
||||
if Offset == TAB_STAR:
|
||||
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
|
||||
self._VpdArray[VpdObject][sku] = Offset
|
||||
Found = True
|
||||
|
Reference in New Issue
Block a user