Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
1. Add -m and -s to support only scanning meta-data files or source c…
…ode files

2. Add -r to support specifying report file name on command line
3. Ignore the library of BASE type for error code 10002 and 10003
4. Stop raise error for most parsing error, remain some for critical errors

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1249 7335b38e-4728-0410-8992-fb3ffe349368
  • Loading branch information
hche10x committed Jun 5, 2008
1 parent 057fe4b commit 7af6710
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 48 deletions.
6 changes: 3 additions & 3 deletions Source/Python/Common/DecClassObject.py
Expand Up @@ -206,7 +206,7 @@ def LoadDecFile(self, Filename):
CurrentSection = ItemList[0]
else:
if CurrentSection != ItemList[0]:
EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
if CurrentSection.upper() not in self.KeyList:
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
ItemList.append('')
Expand All @@ -215,7 +215,7 @@ def LoadDecFile(self, Filename):
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
else:
if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
ArchList.append(ItemList[1].upper())
ThirdList.append(ItemList[2])

Expand All @@ -226,7 +226,7 @@ def LoadDecFile(self, Filename):
#
if CurrentSection == TAB_UNKNOWN:
ErrorMsg = "%s is not in any defined section" % Line
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)

#
# Add a section item
Expand Down
14 changes: 7 additions & 7 deletions Source/Python/Common/DscClassObject.py
Expand Up @@ -606,7 +606,7 @@ def GenDynamicDefaultPcds(self, Type = '', ContainerFile = ''):
(Status, SkuInfoList) = self.GenSkuInfoList(Key[6], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2])
if Status == False:
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], SkuInfoList, [])
Pcd.SupArchList = Pcds[Key]
self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
Expand Down Expand Up @@ -663,7 +663,7 @@ def GenDynamicHiiPcds(self, Type = '', ContainerFile = ''):
(Status, SkuInfoList) = self.GenSkuInfoList(Key[8], self.Platform.SkuInfos.SkuInfoList, Key[2], Key[3], Key[4], Key[5], '', '')
if Status == False:
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
Pcd = PcdClass(Key[0], '', Key[1], '', Key[6], Key[5], Key[7], [], SkuInfoList, [])
Pcd.SupArchList = Pcds[Key]
self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
Expand Down Expand Up @@ -720,7 +720,7 @@ def GenDynamicVpdPcds(self, Type = '', ContainerFile = ''):
(Status, SkuInfoList) = self.GenSkuInfoList(Key[5], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '')
if Status == False:
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
Pcd = PcdClass(Key[0], '', Key[1], '', Key[3], '', Key[4], [], SkuInfoList, [])
Pcd.SupArchList = Pcds[Key]
self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
Expand Down Expand Up @@ -963,7 +963,7 @@ def InsertConditionalStatement(self, Filename, FileID, BelongsToItem, IfDefList,
(Value1, Value2, Value3, Model, StartColumn, EndColumn, Enabled) = ('', '', '', -1, -1, -1, 0)
if IfDefList == []:
ErrorMsg = 'Not suited conditional statement in file %s' % Filename
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename, RaiseError = EdkLogger.IsRaiseError)
else:
#
# Get New Dsc item ID
Expand Down Expand Up @@ -1082,7 +1082,7 @@ def LoadDscFile(self, Filename):
CurrentSection = ItemList[0]
else:
if CurrentSection != ItemList[0]:
EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
if CurrentSection.upper() not in self.KeyList:
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
ItemList.append('')
Expand All @@ -1091,7 +1091,7 @@ def LoadDscFile(self, Filename):
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
else:
if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
ArchList.append(ItemList[1].upper())
ThirdList.append(ItemList[2])

Expand All @@ -1102,7 +1102,7 @@ def LoadDscFile(self, Filename):
#
if CurrentSection == TAB_UNKNOWN:
ErrorMsg = "%s is not in any defined section" % Line
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)

#
# Add a section item
Expand Down
2 changes: 1 addition & 1 deletion Source/Python/Common/EdkLogger.py
Expand Up @@ -161,7 +161,7 @@ def warn(ToolName, Message, File=None, Line=None, ExtraData=None):
# @param RaiseError Raise an exception to break the tool's executuion if
# it's True. This is the default behavior.
#
def error(ToolName, ErrorCode, Message=None, File=None, Line=None, ExtraData=None, RaiseError=True):
def error(ToolName, ErrorCode, Message=None, File=None, Line=None, ExtraData=None, RaiseError=IsRaiseError):
# if no tool name given, use caller's source file name as tool name
if ToolName == None or ToolName == "":
ToolName = os.path.basename(traceback.extract_stack()[-2][0])
Expand Down
11 changes: 5 additions & 6 deletions Source/Python/Common/InfClassObject.py
Expand Up @@ -398,7 +398,7 @@ def LoadInfFile(self, Filename):
CurrentSection = ItemList[0]
else:
if CurrentSection != ItemList[0]:
EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
if CurrentSection.upper() not in self.KeyList:
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
ItemList.append('')
Expand All @@ -407,7 +407,7 @@ def LoadInfFile(self, Filename):
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
else:
if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
ArchList.append(ItemList[1].upper())
ThirdList.append(ItemList[2])

Expand All @@ -418,7 +418,7 @@ def LoadInfFile(self, Filename):
#
if CurrentSection == TAB_UNKNOWN:
ErrorMsg = "%s is not in any defined section" % Line
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo)
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)

#
# Add a section item
Expand Down Expand Up @@ -578,7 +578,7 @@ def GenModuleHeader(self, ContainerFile):
if len(List) == 2:
ModuleHeader.CustomMakefile[CleanString(List[0])] = CleanString(List[1])
else:
RaiseParserError(Item, 'CUSTOM_MAKEFILE of Defines', File, 'CUSTOM_MAKEFILE=<Family>|<Filename>', D[2])
RaiseParserError(D[1], 'CUSTOM_MAKEFILE of Defines', File, 'CUSTOM_MAKEFILE=<Family>|<Filename>', D[2])
elif D[0] == TAB_INF_DEFINES_ENTRY_POINT:
Image = ModuleExternImageClass()
Image.ModuleEntryPoint = CleanString(D[1])
Expand Down Expand Up @@ -628,8 +628,7 @@ def GenModuleHeader(self, ContainerFile):
if ModuleHeader.ComponentType in gComponentType2ModuleType:
ModuleHeader.ModuleType = gComponentType2ModuleType[ModuleHeader.ComponentType]
elif ModuleHeader.ComponentType != '':
EdkLogger.error("Parser", PARSER_ERROR, "Unsupported R8 component type [%s]" % ModuleHeader.ComponentType,
ExtraData=File)
EdkLogger.error("Parser", PARSER_ERROR, "Unsupported R8 component type [%s]" % ModuleHeader.ComponentType, ExtraData=File, RaiseError = EdkLogger.IsRaiseError)

self.Module.Header[Arch] = ModuleHeader

Expand Down
75 changes: 53 additions & 22 deletions Source/Python/Common/Parsing.py
Expand Up @@ -380,13 +380,20 @@ def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo = -1):
# @retval (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], Type)
#
def GetPcd(Item, Type, ContainerFile, LineNo = -1):
TokenGuid, TokenName, Value, MaximumDatumSize, Token = '', '', '', '', ''
List = GetSplitValueList(Item + TAB_VALUE_SPLIT * 2)

if len(List) < 4 or len(List) > 6:
RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '<PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]', LineNo)
CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo)
TokenInfo = GetSplitValueList(List[0], TAB_SPLIT)
else:
Value = List[1]
MaximumDatumSize = List[2]
Token = List[3]

if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
(TokenGuid, TokenName) = GetSplitValueList(List[0], TAB_SPLIT)

return (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], Type)
return (TokenName, TokenGuid, Value, MaximumDatumSize, Token, Type)

## Get FeatureFlagPcd
#
Expand All @@ -398,14 +405,16 @@ def GetPcd(Item, Type, ContainerFile, LineNo = -1):
# @retval (TokenInfo[1], TokenInfo[0], List[1], Type)
#
def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo = -1):
TokenGuid, TokenName, Value = '', '', ''
List = GetSplitValueList(Item)
if len(List) != 2:
RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '<PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE', LineNo)

CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo)
TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
else:
Value = List[1]
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
(TokenGuid, TokenName) = GetSplitValueList(List[0], DataType.TAB_SPLIT)

return (TokenInfo[1], TokenInfo[0], List[1], Type)
return (TokenName, TokenGuid, Value, Type)

## Get DynamicDefaultPcd
#
Expand All @@ -417,14 +426,18 @@ def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo = -1):
# @retval (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], Type)
#
def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo = -1):
TokenGuid, TokenName, Value, DatumTyp, MaxDatumSize = '', '', '', '', ''
List = GetSplitValueList(Item + TAB_VALUE_SPLIT * 2)
if len(List) < 4 or len(List) > 8:
RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '<PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<DatumTyp>[|<MaxDatumSize>]]', LineNo)

CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo)
TokenInfo = GetSplitValueList(List[0], TAB_SPLIT)
else:
Value = List[1]
DatumTyp = List[2]
MaxDatumSize = List[3]
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
(TokenGuid, TokenName) = GetSplitValueList(List[0], TAB_SPLIT)

return (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], Type)
return (TokenName, TokenGuid, Value, DatumTyp, MaxDatumSize, Type)

## Get DynamicHiiPcd
#
Expand All @@ -436,14 +449,16 @@ def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo = -1):
# @retval (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], List[4], List[5], Type)
#
def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo = -1):
TokenGuid, TokenName, L1, L2, L3, L4, L5 = '', '', '', '', '', '', ''
List = GetSplitValueList(Item + TAB_VALUE_SPLIT * 2)
if len(List) < 6 or len(List) > 8:
RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '<PcdTokenSpaceGuidCName>.<TokenCName>|<String>|<VariableGuidCName>|<VariableOffset>[|<DefaultValue>[|<MaximumDatumSize>]]', LineNo)

CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo)
TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
else:
L1, L2, L3, L4, L5 = List[1], List[2], List[3], List[4], List[5]
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
(TokenGuid, TokenName) = GetSplitValueList(List[0], DataType.TAB_SPLIT)

return (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], List[4], List[5], Type)
return (TokenName, TokenGuid, L1, L2, L3, L4, L5, Type)

## Get DynamicVpdPcd
#
Expand All @@ -455,14 +470,16 @@ def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo = -1):
# @retval (TokenInfo[1], TokenInfo[0], List[1], List[2], Type)
#
def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo = -1):
TokenGuid, TokenName, L1, L2 = '', '', '', ''
List = GetSplitValueList(Item + TAB_VALUE_SPLIT)
if len(List) < 3 or len(List) > 4:
RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '<PcdTokenSpaceGuidCName>.<TokenCName>|<VpdOffset>[|<MaximumDatumSize>]', LineNo)

CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo)
TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
else:
L1, L2 = List[1], List[2]
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
(TokenGuid, TokenName) = GetSplitValueList(List[0], DataType.TAB_SPLIT)

return (TokenInfo[1], TokenInfo[0], List[1], List[2], Type)
return (TokenName, TokenGuid, L1, L2, Type)

## GetComponent
#
Expand Down Expand Up @@ -772,7 +789,8 @@ def GetPackage(Item, ContainerFile, FileRelativePath, LineNo = -1):
#
def GetPcdOfInf(Item, Type, File, LineNo):
Format = '<TokenSpaceGuidCName>.<PcdCName>[|<Value>]'
InfType = ''
TokenGuid, TokenName, Value, InfType = '', '', '', ''

if Type == TAB_PCDS_FIXED_AT_BUILD:
InfType = TAB_INF_FIXED_PCD
elif Type == TAB_PCDS_PATCHABLE_IN_MODULE:
Expand All @@ -786,11 +804,16 @@ def GetPcdOfInf(Item, Type, File, LineNo):
List = GetSplitValueList(Item + DataType.TAB_VALUE_SPLIT)
if len(List) < 2 or len(List) > 3:
RaiseParserError(Item, InfType, File, Format, LineNo)
else:
Value = List[1]
TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
if len(TokenInfo) != 2:
RaiseParserError(Item, InfType, File, Format, LineNo)
else:
TokenGuid = TokenInfo[0]
TokenName = TokenInfo[1]

return (TokenInfo[0], TokenInfo[1], List[1], Type)
return (TokenGuid, TokenName, Value, Type)


## Get Pcd Values of Dec
Expand All @@ -800,14 +823,22 @@ def GetPcdOfInf(Item, Type, File, LineNo):
#
def GetPcdOfDec(Item, Type, File, LineNo = -1):
Format = '<TokenSpaceGuidCName>.<PcdCName>|<Value>|<DatumType>|<Token>'
TokenGuid, TokenName, Value, DatumType, Token = '', '', '', '', ''
List = GetSplitValueList(Item)
if len(List) != 4:
RaiseParserError(Item, 'Pcds' + Type, File, Format, LineNo)
else:
Value = List[1]
DatumType = List[2]
Token = List[3]
TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
if len(TokenInfo) != 2:
RaiseParserError(Item, 'Pcds' + Type, File, Format, LineNo)
else:
TokenGuid = TokenInfo[0]
TokenName = TokenInfo[1]

return (TokenInfo[0], TokenInfo[1], List[1], List[2], List[3], Type)
return (TokenGuid, TokenName, Value, DatumType, Token, Type)

## Parse DEFINE statement
#
Expand Down

0 comments on commit 7af6710

Please sign in to comment.