BaseTools: Clean up source files
1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
#
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -75,31 +75,31 @@ class _DecBase:
|
||||
# Data parsed by 'self' are saved to this object
|
||||
#
|
||||
self.ItemObject = None
|
||||
|
||||
|
||||
def GetDataObject(self):
|
||||
return self.ItemObject
|
||||
|
||||
|
||||
def GetLocalMacro(self):
|
||||
return self._LocalMacro
|
||||
|
||||
|
||||
## BlockStart
|
||||
#
|
||||
# Called if a new section starts
|
||||
#
|
||||
def BlockStart(self):
|
||||
self._LocalMacro = {}
|
||||
|
||||
|
||||
## _CheckReDefine
|
||||
#
|
||||
# @param Key: to be checked if multi-defined
|
||||
# @param Scope: Format: [[SectionName, Arch], ...].
|
||||
# @param Scope: Format: [[SectionName, Arch], ...].
|
||||
# If scope is none, use global scope
|
||||
#
|
||||
def _CheckReDefine(self, Key, Scope = None):
|
||||
if not Scope:
|
||||
Scope = self._RawData.CurrentScope
|
||||
return
|
||||
|
||||
|
||||
SecArch = []
|
||||
#
|
||||
# Copy scope to SecArch, avoid Scope be changed outside
|
||||
@@ -108,7 +108,7 @@ class _DecBase:
|
||||
if Key not in self._ItemDict:
|
||||
self._ItemDict[Key] = [[SecArch, self._RawData.LineIndex]]
|
||||
return
|
||||
|
||||
|
||||
for Value in self._ItemDict[Key]:
|
||||
for SubValue in Scope:
|
||||
#
|
||||
@@ -132,18 +132,18 @@ class _DecBase:
|
||||
self._LoggerError(ST.ERR_DECPARSE_REDEFINE % (Key, Value[1]))
|
||||
return
|
||||
self._ItemDict[Key].append([SecArch, self._RawData.LineIndex])
|
||||
|
||||
|
||||
## CheckRequiredFields
|
||||
# Some sections need to check if some fields exist, define section for example
|
||||
# Derived class can re-implement, top parser will call this function after all parsing done
|
||||
#
|
||||
#
|
||||
def CheckRequiredFields(self):
|
||||
if self._RawData:
|
||||
pass
|
||||
return True
|
||||
|
||||
|
||||
## IsItemRequired
|
||||
# In DEC spec, sections must have at least one statement except user
|
||||
# In DEC spec, sections must have at least one statement except user
|
||||
# extension.
|
||||
# For example: "[guids" [<attribs>] "]" <EOL> <statements>+
|
||||
# sub class can override this method to indicate if statement is a must.
|
||||
@@ -152,12 +152,12 @@ class _DecBase:
|
||||
if self._RawData:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def _LoggerError(self, ErrorString):
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
Line = self._RawData.LineIndex,
|
||||
ExtraData=ErrorString + ST.ERR_DECPARSE_LINE % self._RawData.CurrentLine)
|
||||
|
||||
|
||||
def _ReplaceMacro(self, String):
|
||||
if gMACRO_PATTERN.findall(String):
|
||||
String = ReplaceMacro(String, self._LocalMacro, False,
|
||||
@@ -169,11 +169,11 @@ class _DecBase:
|
||||
MacroUsed = gMACRO_PATTERN.findall(String)
|
||||
if MacroUsed:
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE,
|
||||
File=self._RawData.Filename,
|
||||
File=self._RawData.Filename,
|
||||
Line = self._RawData.LineIndex,
|
||||
ExtraData = ST.ERR_DECPARSE_MACRO_RESOLVE % (str(MacroUsed), String))
|
||||
return String
|
||||
|
||||
|
||||
def _MacroParser(self, String):
|
||||
TokenList = GetSplitValueList(String, ' ', 1)
|
||||
if len(TokenList) < 2 or TokenList[1] == '':
|
||||
@@ -184,7 +184,7 @@ class _DecBase:
|
||||
self._LoggerError(ST.ERR_DECPARSE_MACRO_NAME)
|
||||
elif not IsValidToken(MACRO_PATTERN, TokenList[0]):
|
||||
self._LoggerError(ST.ERR_DECPARSE_MACRO_NAME_UPPER % TokenList[0])
|
||||
|
||||
|
||||
if len(TokenList) == 1:
|
||||
self._LocalMacro[TokenList[0]] = ''
|
||||
else:
|
||||
@@ -202,7 +202,7 @@ class _DecBase:
|
||||
#
|
||||
return None
|
||||
|
||||
|
||||
|
||||
## _TailCommentStrategy
|
||||
#
|
||||
# This function can be derived to parse tail comment
|
||||
@@ -216,7 +216,7 @@ class _DecBase:
|
||||
if self._RawData:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
## _StopCurrentParsing
|
||||
#
|
||||
# Called in Parse if current parsing should be stopped when encounter some
|
||||
@@ -229,7 +229,7 @@ class _DecBase:
|
||||
if self._RawData:
|
||||
pass
|
||||
return Line[0] == DT.TAB_SECTION_START and Line[-1] == DT.TAB_SECTION_END
|
||||
|
||||
|
||||
## _TryBackSlash
|
||||
#
|
||||
# Split comment and DEC content, concatenate lines if end of char is '\'
|
||||
@@ -246,7 +246,7 @@ class _DecBase:
|
||||
if Line == '':
|
||||
self._LoggerError(ST.ERR_DECPARSE_BACKSLASH_EMPTY)
|
||||
break
|
||||
|
||||
|
||||
if Comment:
|
||||
CommentList.append((Comment, self._RawData.LineIndex))
|
||||
if Line[-1] != DT.TAB_SLASH:
|
||||
@@ -269,7 +269,7 @@ class _DecBase:
|
||||
if not Line or Line[-1] == DT.TAB_SLASH:
|
||||
self._LoggerError(ST.ERR_DECPARSE_BACKSLASH_EMPTY)
|
||||
CatLine += Line
|
||||
|
||||
|
||||
#
|
||||
# All MACRO values defined by the DEFINE statements in any section
|
||||
# (except [Userextensions] sections for Intel) of the INF or DEC file
|
||||
@@ -286,17 +286,17 @@ class _DecBase:
|
||||
self._RawData.CurrentLine = CatLine
|
||||
|
||||
return CatLine, CommentList
|
||||
|
||||
|
||||
## Parse
|
||||
# This is a template method in which other member functions which might
|
||||
# override by sub class are called. It is responsible for reading file
|
||||
# This is a template method in which other member functions which might
|
||||
# override by sub class are called. It is responsible for reading file
|
||||
# line by line, and call other member functions to parse. This function
|
||||
# should not be re-implement by sub class.
|
||||
#
|
||||
def Parse(self):
|
||||
HeadComments = []
|
||||
TailComments = []
|
||||
|
||||
|
||||
#======================================================================
|
||||
# CurComments may pointer to HeadComments or TailComments
|
||||
#======================================================================
|
||||
@@ -304,7 +304,7 @@ class _DecBase:
|
||||
CurObj = None
|
||||
ItemNum = 0
|
||||
FromBuf = False
|
||||
|
||||
|
||||
#======================================================================
|
||||
# Used to report error information if empty section found
|
||||
#======================================================================
|
||||
@@ -333,20 +333,20 @@ class _DecBase:
|
||||
# Set tail comments to previous statement if not empty.
|
||||
#==========================================================
|
||||
CurObj.SetTailComment(CurObj.GetTailComment()+TailComments)
|
||||
|
||||
|
||||
if not FromBuf:
|
||||
del TailComments[:]
|
||||
CurComments = TailComments
|
||||
Comments = []
|
||||
if Comment:
|
||||
Comments = [(Comment, self._RawData.LineIndex)]
|
||||
|
||||
|
||||
#==============================================================
|
||||
# Try if last char of line has backslash
|
||||
#==============================================================
|
||||
Line, Comments = self._TryBackSlash(Line, Comments)
|
||||
CurComments.extend(Comments)
|
||||
|
||||
|
||||
#==============================================================
|
||||
# Macro found
|
||||
#==============================================================
|
||||
@@ -356,7 +356,7 @@ class _DecBase:
|
||||
del TailComments[:]
|
||||
CurComments = HeadComments
|
||||
continue
|
||||
|
||||
|
||||
if self._StopCurrentParsing(Line):
|
||||
#==========================================================
|
||||
# This line does not belong to this parse,
|
||||
@@ -364,7 +364,7 @@ class _DecBase:
|
||||
#==========================================================
|
||||
self._RawData.SetNext(Line, HeadComments, TailComments)
|
||||
break
|
||||
|
||||
|
||||
Obj = self._ParseItem()
|
||||
ItemNum += 1
|
||||
if Obj:
|
||||
@@ -387,7 +387,7 @@ class _DecBase:
|
||||
CurComments.append(((Comment, self._RawData.LineIndex)))
|
||||
else:
|
||||
del CurComments[:]
|
||||
|
||||
|
||||
if self._IsStatementRequired() and ItemNum == 0:
|
||||
Logger.Error(
|
||||
TOOL_NAME, FILE_PARSE_FAILURE,
|
||||
@@ -405,7 +405,7 @@ class _DecDefine(_DecBase):
|
||||
self.ItemObject = DecDefineObject(RawData.Filename)
|
||||
self._LocalMacro = self._RawData.Macros
|
||||
self._DefSecNum = 0
|
||||
|
||||
|
||||
#
|
||||
# Each field has a function to validate
|
||||
#
|
||||
@@ -416,12 +416,12 @@ class _DecDefine(_DecBase):
|
||||
DT.TAB_DEC_DEFINES_PACKAGE_VERSION : self._SetPackageVersion,
|
||||
DT.TAB_DEC_DEFINES_PKG_UNI_FILE : self._SetPackageUni,
|
||||
}
|
||||
|
||||
|
||||
def BlockStart(self):
|
||||
self._DefSecNum += 1
|
||||
if self._DefSecNum > 1:
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_MULTISEC)
|
||||
|
||||
|
||||
## CheckRequiredFields
|
||||
#
|
||||
# Check required fields: DEC_SPECIFICATION, PACKAGE_NAME
|
||||
@@ -430,21 +430,21 @@ class _DecDefine(_DecBase):
|
||||
def CheckRequiredFields(self):
|
||||
Ret = False
|
||||
if self.ItemObject.GetPackageSpecification() == '':
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
ExtraData=ST.ERR_DECPARSE_DEFINE_REQUIRED % DT.TAB_DEC_DEFINES_DEC_SPECIFICATION)
|
||||
elif self.ItemObject.GetPackageName() == '':
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
ExtraData=ST.ERR_DECPARSE_DEFINE_REQUIRED % DT.TAB_DEC_DEFINES_PACKAGE_NAME)
|
||||
elif self.ItemObject.GetPackageGuid() == '':
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
ExtraData=ST.ERR_DECPARSE_DEFINE_REQUIRED % DT.TAB_DEC_DEFINES_PACKAGE_GUID)
|
||||
elif self.ItemObject.GetPackageVersion() == '':
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
|
||||
ExtraData=ST.ERR_DECPARSE_DEFINE_REQUIRED % DT.TAB_DEC_DEFINES_PACKAGE_VERSION)
|
||||
else:
|
||||
Ret = True
|
||||
return Ret
|
||||
|
||||
|
||||
def _ParseItem(self):
|
||||
Line = self._RawData.CurrentLine
|
||||
TokenList = GetSplitValueList(Line, DT.TAB_EQUAL_SPLIT, 1)
|
||||
@@ -456,13 +456,13 @@ class _DecDefine(_DecBase):
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_UNKNOWKEY % TokenList[0])
|
||||
else:
|
||||
self.DefineValidation[TokenList[0]](TokenList[1])
|
||||
|
||||
|
||||
DefineItem = DecDefineItemObject()
|
||||
DefineItem.Key = TokenList[0]
|
||||
DefineItem.Value = TokenList[1]
|
||||
self.ItemObject.AddItem(DefineItem, self._RawData.CurrentScope)
|
||||
return DefineItem
|
||||
|
||||
|
||||
def _SetDecSpecification(self, Token):
|
||||
if self.ItemObject.GetPackageSpecification():
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_DEC_SPECIFICATION)
|
||||
@@ -470,21 +470,21 @@ class _DecDefine(_DecBase):
|
||||
if not IsValidDecVersionVal(Token):
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_SPEC)
|
||||
self.ItemObject.SetPackageSpecification(Token)
|
||||
|
||||
|
||||
def _SetPackageName(self, Token):
|
||||
if self.ItemObject.GetPackageName():
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PACKAGE_NAME)
|
||||
if not IsValidWord(Token):
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGNAME)
|
||||
self.ItemObject.SetPackageName(Token)
|
||||
|
||||
|
||||
def _SetPackageGuid(self, Token):
|
||||
if self.ItemObject.GetPackageGuid():
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PACKAGE_GUID)
|
||||
if not CheckGuidRegFormat(Token):
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGGUID)
|
||||
self.ItemObject.SetPackageGuid(Token)
|
||||
|
||||
|
||||
def _SetPackageVersion(self, Token):
|
||||
if self.ItemObject.GetPackageVersion():
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PACKAGE_VERSION)
|
||||
@@ -494,7 +494,7 @@ class _DecDefine(_DecBase):
|
||||
if not DT.TAB_SPLIT in Token:
|
||||
Token = Token + '.0'
|
||||
self.ItemObject.SetPackageVersion(Token)
|
||||
|
||||
|
||||
def _SetPackageUni(self, Token):
|
||||
if self.ItemObject.GetPackageUniFile():
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PKG_UNI_FILE)
|
||||
@@ -508,13 +508,13 @@ class _DecInclude(_DecBase):
|
||||
def __init__(self, RawData):
|
||||
_DecBase.__init__(self, RawData)
|
||||
self.ItemObject = DecIncludeObject(RawData.Filename)
|
||||
|
||||
|
||||
def _ParseItem(self):
|
||||
Line = self._RawData.CurrentLine
|
||||
|
||||
|
||||
if not IsValidPath(Line, self._RawData.PackagePath):
|
||||
self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Line)
|
||||
|
||||
self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Line)
|
||||
|
||||
Item = DecIncludeItemObject(StripRoot(self._RawData.PackagePath, Line), self._RawData.PackagePath)
|
||||
self.ItemObject.AddItem(Item, self._RawData.CurrentScope)
|
||||
return Item
|
||||
@@ -527,32 +527,32 @@ class _DecLibraryclass(_DecBase):
|
||||
def __init__(self, RawData):
|
||||
_DecBase.__init__(self, RawData)
|
||||
self.ItemObject = DecLibraryclassObject(RawData.Filename)
|
||||
|
||||
|
||||
def _ParseItem(self):
|
||||
Line = self._RawData.CurrentLine
|
||||
TokenList = GetSplitValueList(Line, DT.TAB_VALUE_SPLIT)
|
||||
if len(TokenList) != 2:
|
||||
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_SPLIT)
|
||||
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_SPLIT)
|
||||
if TokenList[0] == '' or TokenList[1] == '':
|
||||
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_EMPTY)
|
||||
if not IsValidToken('[A-Z][0-9A-Za-z]*', TokenList[0]):
|
||||
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_LIB)
|
||||
|
||||
|
||||
self._CheckReDefine(TokenList[0])
|
||||
|
||||
|
||||
Value = TokenList[1]
|
||||
#
|
||||
# Must end with .h
|
||||
#
|
||||
if not Value.endswith('.h'):
|
||||
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_PATH_EXT)
|
||||
|
||||
|
||||
#
|
||||
# Path must be existed
|
||||
#
|
||||
if not IsValidPath(Value, self._RawData.PackagePath):
|
||||
self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Value)
|
||||
|
||||
|
||||
Item = DecLibraryclassItemObject(TokenList[0], StripRoot(self._RawData.PackagePath, Value),
|
||||
self._RawData.PackagePath)
|
||||
self.ItemObject.AddItem(Item, self._RawData.CurrentScope)
|
||||
@@ -571,38 +571,38 @@ class _DecPcd(_DecBase):
|
||||
# Key is token space and token number (integer), value is C name
|
||||
#
|
||||
self.TokenMap = {}
|
||||
|
||||
|
||||
def _ParseItem(self):
|
||||
Line = self._RawData.CurrentLine
|
||||
TokenList = Line.split(DT.TAB_VALUE_SPLIT)
|
||||
if len(TokenList) < 4:
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_SPLIT)
|
||||
|
||||
|
||||
#
|
||||
# Token space guid C name
|
||||
#
|
||||
PcdName = GetSplitValueList(TokenList[0], DT.TAB_SPLIT)
|
||||
if len(PcdName) != 2 or PcdName[0] == '' or PcdName[1] == '':
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_NAME)
|
||||
|
||||
|
||||
Guid = PcdName[0]
|
||||
if not IsValidToken(CVAR_PATTERN, Guid):
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_CVAR_GUID)
|
||||
|
||||
|
||||
#
|
||||
# PCD C name
|
||||
#
|
||||
CName = PcdName[1]
|
||||
if not IsValidToken(CVAR_PATTERN, CName):
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_CVAR_PCDCNAME)
|
||||
|
||||
|
||||
self._CheckReDefine(Guid + DT.TAB_SPLIT + CName)
|
||||
|
||||
|
||||
#
|
||||
# Default value, may be C array, string or number
|
||||
#
|
||||
Data = DT.TAB_VALUE_SPLIT.join(TokenList[1:-2]).strip()
|
||||
|
||||
|
||||
#
|
||||
# PCD data type
|
||||
#
|
||||
@@ -623,18 +623,18 @@ class _DecPcd(_DecBase):
|
||||
if long(Token) > 4294967295:
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_INT % Token)
|
||||
Token = hex(long(Token))[:-1]
|
||||
|
||||
|
||||
IntToken = long(Token, 0)
|
||||
if (Guid, IntToken) in self.TokenMap:
|
||||
if self.TokenMap[Guid, IntToken] != CName:
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_UNIQUE%(Token))
|
||||
else:
|
||||
self.TokenMap[Guid, IntToken] = CName
|
||||
|
||||
|
||||
Item = DecPcdItemObject(Guid, CName, Data, DataType, Token)
|
||||
self.ItemObject.AddItem(Item, self._RawData.CurrentScope)
|
||||
return Item
|
||||
|
||||
|
||||
## _DecGuid
|
||||
#
|
||||
# Parse GUID, PPI, Protocol section
|
||||
@@ -651,21 +651,21 @@ class _DecGuid(_DecBase):
|
||||
DT.TAB_PPIS.upper() : self.PpiObj,
|
||||
DT.TAB_PROTOCOLS.upper() : self.ProtocolObj
|
||||
}
|
||||
|
||||
|
||||
def GetDataObject(self):
|
||||
if self._RawData.CurrentScope:
|
||||
return self.ObjectDict[self._RawData.CurrentScope[0][0]]
|
||||
return None
|
||||
|
||||
|
||||
def GetGuidObject(self):
|
||||
return self.GuidObj
|
||||
|
||||
|
||||
def GetPpiObject(self):
|
||||
return self.PpiObj
|
||||
|
||||
|
||||
def GetProtocolObject(self):
|
||||
return self.ProtocolObj
|
||||
|
||||
|
||||
def _ParseItem(self):
|
||||
Line = self._RawData.CurrentLine
|
||||
TokenList = GetSplitValueList(Line, DT.TAB_EQUAL_SPLIT, 1)
|
||||
@@ -677,9 +677,9 @@ class _DecGuid(_DecBase):
|
||||
self._LoggerError(ST.ERR_DECPARSE_CGUID_GUID)
|
||||
if not IsValidToken(CVAR_PATTERN, TokenList[0]):
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_CVAR_GUID)
|
||||
|
||||
|
||||
self._CheckReDefine(TokenList[0])
|
||||
|
||||
|
||||
if TokenList[1][0] != '{':
|
||||
if not CheckGuidRegFormat(TokenList[1]):
|
||||
self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGGUID)
|
||||
@@ -691,7 +691,7 @@ class _DecGuid(_DecBase):
|
||||
GuidString = GuidStructureStringToGuidString(TokenList[1])
|
||||
if TokenList[1][0] != '{' or TokenList[1][-1] != '}' or GuidString == '':
|
||||
self._LoggerError(ST.ERR_DECPARSE_CGUID_GUIDFORMAT)
|
||||
|
||||
|
||||
#
|
||||
# Check C format GUID
|
||||
#
|
||||
@@ -713,7 +713,7 @@ class _DecUserExtension(_DecBase):
|
||||
self.ItemObject = DecUserExtensionObject(RawData.Filename)
|
||||
self._Headers = []
|
||||
self._CurItems = []
|
||||
|
||||
|
||||
def BlockStart(self):
|
||||
self._CurItems = []
|
||||
for Header in self._RawData.CurrentScope:
|
||||
@@ -721,7 +721,7 @@ class _DecUserExtension(_DecBase):
|
||||
self._LoggerError(ST.ERR_DECPARSE_UE_DUPLICATE)
|
||||
else:
|
||||
self._Headers.append(Header)
|
||||
|
||||
|
||||
for Item in self._CurItems:
|
||||
if Item.UserId == Header[1] and Item.IdString == Header[2]:
|
||||
Item.ArchAndModuleType.append(Header[3])
|
||||
@@ -734,7 +734,7 @@ class _DecUserExtension(_DecBase):
|
||||
self._CurItems.append(Item)
|
||||
self.ItemObject.AddItem(Item, None)
|
||||
self._LocalMacro = {}
|
||||
|
||||
|
||||
def _ParseItem(self):
|
||||
Line = self._RawData.CurrentLine
|
||||
Item = None
|
||||
@@ -749,8 +749,8 @@ class _DecUserExtension(_DecBase):
|
||||
#
|
||||
# Top dec parser
|
||||
#
|
||||
class Dec(_DecBase, _DecComments):
|
||||
def __init__(self, DecFile, Parse = True):
|
||||
class Dec(_DecBase, _DecComments):
|
||||
def __init__(self, DecFile, Parse = True):
|
||||
try:
|
||||
Content = ConvertSpecialChar(open(DecFile, 'rb').readlines())
|
||||
except BaseException:
|
||||
@@ -776,20 +776,20 @@ class Dec(_DecBase, _DecComments):
|
||||
NewContent.append(Line + '\r')
|
||||
|
||||
RawData = FileContent(DecFile, NewContent)
|
||||
|
||||
|
||||
_DecComments.__init__(self)
|
||||
_DecBase.__init__(self, RawData)
|
||||
|
||||
|
||||
self.BinaryHeadComment = []
|
||||
self.PcdErrorCommentDict = {}
|
||||
|
||||
|
||||
self._Define = _DecDefine(RawData)
|
||||
self._Include = _DecInclude(RawData)
|
||||
self._Guid = _DecGuid(RawData)
|
||||
self._LibClass = _DecLibraryclass(RawData)
|
||||
self._Pcd = _DecPcd(RawData)
|
||||
self._UserEx = _DecUserExtension(RawData)
|
||||
|
||||
|
||||
#
|
||||
# DEC file supported data types (one type per section)
|
||||
#
|
||||
@@ -815,7 +815,7 @@ class Dec(_DecBase, _DecComments):
|
||||
# Parsing done, check required fields
|
||||
#
|
||||
self.CheckRequiredFields()
|
||||
|
||||
|
||||
def CheckRequiredFields(self):
|
||||
for SectionParser in self._SectionParser.values():
|
||||
if not SectionParser.CheckRequiredFields():
|
||||
@@ -831,7 +831,7 @@ class Dec(_DecBase, _DecComments):
|
||||
FileHeaderLineIndex = -1
|
||||
BinaryHeaderLineIndex = -1
|
||||
TokenSpaceGuidCName = ''
|
||||
|
||||
|
||||
#
|
||||
# Parse PCD error comment section
|
||||
#
|
||||
@@ -853,13 +853,13 @@ class Dec(_DecBase, _DecComments):
|
||||
self._RawData.CurrentLine = self._RawData.CurrentLine.replace(DT.TAB_COMMENT_SPLIT, '').strip()
|
||||
if self._RawData.CurrentLine != '':
|
||||
if DT.TAB_VALUE_SPLIT not in self._RawData.CurrentLine:
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCDERRORMSG_MISS_VALUE_SPLIT)
|
||||
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCDERRORMSG_MISS_VALUE_SPLIT)
|
||||
|
||||
PcdErrorNumber, PcdErrorMsg = GetSplitValueList(self._RawData.CurrentLine, DT.TAB_VALUE_SPLIT, 1)
|
||||
PcdErrorNumber = ParsePcdErrorCode(PcdErrorNumber, self._RawData.Filename, self._RawData.LineIndex)
|
||||
if not PcdErrorMsg.strip():
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_MISS_ERRORMSG)
|
||||
|
||||
|
||||
self.PcdErrorCommentDict[(TokenSpaceGuidCName, PcdErrorNumber)] = PcdErrorMsg.strip()
|
||||
else:
|
||||
TokenSpaceGuidCName = ''
|
||||
@@ -870,27 +870,27 @@ class Dec(_DecBase, _DecComments):
|
||||
|
||||
while not self._RawData.IsEndOfFile():
|
||||
Line, Comment = CleanString(self._RawData.GetNextLine())
|
||||
|
||||
|
||||
#
|
||||
# Header must be pure comment
|
||||
#
|
||||
if Line != '':
|
||||
self._RawData.UndoNextLine()
|
||||
break
|
||||
|
||||
|
||||
if Comment and Comment.startswith(DT.TAB_SPECIAL_COMMENT) and Comment.find(DT.TAB_HEADER_COMMENT) > 0 \
|
||||
and not Comment[2:Comment.find(DT.TAB_HEADER_COMMENT)].strip():
|
||||
IsFileHeader = True
|
||||
IsBinaryHeader = False
|
||||
FileHeaderLineIndex = self._RawData.LineIndex
|
||||
|
||||
|
||||
#
|
||||
# Get license information before '@file'
|
||||
#
|
||||
# Get license information before '@file'
|
||||
#
|
||||
if not IsFileHeader and not IsBinaryHeader and Comment and Comment.startswith(DT.TAB_COMMENT_SPLIT) and \
|
||||
DT.TAB_BINARY_HEADER_COMMENT not in Comment:
|
||||
self._HeadComment.append((Comment, self._RawData.LineIndex))
|
||||
|
||||
|
||||
if Comment and IsFileHeader and \
|
||||
not(Comment.startswith(DT.TAB_SPECIAL_COMMENT) \
|
||||
and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0):
|
||||
@@ -899,15 +899,15 @@ class Dec(_DecBase, _DecComments):
|
||||
# Double '#' indicates end of header comments
|
||||
#
|
||||
if (not Comment or Comment == DT.TAB_SPECIAL_COMMENT) and IsFileHeader:
|
||||
IsFileHeader = False
|
||||
IsFileHeader = False
|
||||
continue
|
||||
|
||||
|
||||
if Comment and Comment.startswith(DT.TAB_SPECIAL_COMMENT) \
|
||||
and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0:
|
||||
IsBinaryHeader = True
|
||||
IsFileHeader = False
|
||||
BinaryHeaderLineIndex = self._RawData.LineIndex
|
||||
|
||||
|
||||
if Comment and IsBinaryHeader:
|
||||
self.BinaryHeadComment.append((Comment, self._RawData.LineIndex))
|
||||
#
|
||||
@@ -916,23 +916,23 @@ class Dec(_DecBase, _DecComments):
|
||||
if (not Comment or Comment == DT.TAB_SPECIAL_COMMENT) and IsBinaryHeader:
|
||||
IsBinaryHeader = False
|
||||
break
|
||||
|
||||
|
||||
if FileHeaderLineIndex > -1 and not IsFileHeader and not IsBinaryHeader:
|
||||
break
|
||||
|
||||
if FileHeaderLineIndex > BinaryHeaderLineIndex and FileHeaderLineIndex > -1 and BinaryHeaderLineIndex > -1:
|
||||
self._LoggerError(ST.ERR_BINARY_HEADER_ORDER)
|
||||
|
||||
|
||||
if FileHeaderLineIndex == -1:
|
||||
# self._LoggerError(ST.ERR_NO_SOURCE_HEADER)
|
||||
Logger.Error(TOOL_NAME, FORMAT_INVALID,
|
||||
Logger.Error(TOOL_NAME, FORMAT_INVALID,
|
||||
ST.ERR_NO_SOURCE_HEADER,
|
||||
File=self._RawData.Filename)
|
||||
return
|
||||
|
||||
|
||||
def _StopCurrentParsing(self, Line):
|
||||
return False
|
||||
|
||||
|
||||
def _ParseItem(self):
|
||||
self._SectionHeaderParser()
|
||||
if len(self._RawData.CurrentScope) == 0:
|
||||
@@ -955,8 +955,8 @@ class Dec(_DecBase, _DecComments):
|
||||
if Token.upper() != DT.TAB_USER_EXTENSIONS.upper():
|
||||
self._LoggerError(ST.ERR_DECPARSE_SECTION_UE)
|
||||
UserExtension = Token.upper()
|
||||
Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex)
|
||||
|
||||
Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex)
|
||||
|
||||
#
|
||||
# UserID
|
||||
#
|
||||
@@ -991,7 +991,7 @@ class Dec(_DecBase, _DecComments):
|
||||
Par.AssertEnd(ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex)
|
||||
if 'COMMON' in ArchList and len(ArchList) > 1:
|
||||
self._LoggerError(ST.ERR_DECPARSE_SECTION_COMMON)
|
||||
|
||||
|
||||
## Section header parser
|
||||
#
|
||||
# The section header is always in following format:
|
||||
@@ -1001,7 +1001,7 @@ class Dec(_DecBase, _DecComments):
|
||||
def _SectionHeaderParser(self):
|
||||
if self._RawData.CurrentLine[0] != DT.TAB_SECTION_START or self._RawData.CurrentLine[-1] != DT.TAB_SECTION_END:
|
||||
self._LoggerError(ST.ERR_DECPARSE_SECTION_IDENTIFY)
|
||||
|
||||
|
||||
RawSection = self._RawData.CurrentLine[1:-1].strip().upper()
|
||||
#
|
||||
# Check defines section which is only allowed to occur once and
|
||||
@@ -1039,7 +1039,7 @@ class Dec(_DecBase, _DecComments):
|
||||
self._LoggerError(ST.ERR_DECPARSE_SECTION_SUBTOOMANY % Item)
|
||||
|
||||
if DT.TAB_PCDS_FEATURE_FLAG_NULL.upper() in SectionNames and len(SectionNames) > 1:
|
||||
self._LoggerError(ST.ERR_DECPARSE_SECTION_FEATUREFLAG % DT.TAB_PCDS_FEATURE_FLAG_NULL)
|
||||
self._LoggerError(ST.ERR_DECPARSE_SECTION_FEATUREFLAG % DT.TAB_PCDS_FEATURE_FLAG_NULL)
|
||||
#
|
||||
# S1 is always Arch
|
||||
#
|
||||
@@ -1064,7 +1064,7 @@ class Dec(_DecBase, _DecComments):
|
||||
for Sec in SectionNames:
|
||||
if not Sec.startswith(DT.TAB_PCDS.upper()):
|
||||
self._LoggerError(ST.ERR_DECPARSE_SECTION_NAME % str(SectionNames))
|
||||
|
||||
|
||||
def GetDefineSectionMacro(self):
|
||||
return self._Define.GetLocalMacro()
|
||||
def GetDefineSectionObject(self):
|
||||
@@ -1084,11 +1084,11 @@ class Dec(_DecBase, _DecComments):
|
||||
def GetUserExtensionSectionObject(self):
|
||||
return self._UserEx.GetDataObject()
|
||||
def GetPackageSpecification(self):
|
||||
return self._Define.GetDataObject().GetPackageSpecification()
|
||||
return self._Define.GetDataObject().GetPackageSpecification()
|
||||
def GetPackageName(self):
|
||||
return self._Define.GetDataObject().GetPackageName()
|
||||
return self._Define.GetDataObject().GetPackageName()
|
||||
def GetPackageGuid(self):
|
||||
return self._Define.GetDataObject().GetPackageGuid()
|
||||
return self._Define.GetDataObject().GetPackageGuid()
|
||||
def GetPackageVersion(self):
|
||||
return self._Define.GetDataObject().GetPackageVersion()
|
||||
def GetPackageUniFile(self):
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file is used to define helper class and function for DEC parser
|
||||
#
|
||||
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -104,7 +104,7 @@ def StripRoot(Root, Path):
|
||||
# Remove spaces
|
||||
#
|
||||
# @param Line: The string to be cleaned
|
||||
# @param CommentCharacter: Comment char, used to ignore comment content,
|
||||
# @param CommentCharacter: Comment char, used to ignore comment content,
|
||||
# default is DataType.TAB_COMMENT_SPLIT
|
||||
#
|
||||
def CleanString(Line, CommentCharacter=TAB_COMMENT_SPLIT, \
|
||||
@@ -291,7 +291,7 @@ def IsValidPcdDatum(Type, Value):
|
||||
Valid, Cause = IsValidLogicalExpr(Value, True)
|
||||
if not Valid:
|
||||
return False, Cause
|
||||
|
||||
|
||||
return True, ""
|
||||
|
||||
## ParserHelper
|
||||
@@ -366,7 +366,7 @@ class ParserHelper:
|
||||
|
||||
## AssertChar
|
||||
#
|
||||
# Assert char at current index of string is AssertChar, or will report
|
||||
# Assert char at current index of string is AssertChar, or will report
|
||||
# error message
|
||||
#
|
||||
# @param AssertChar: AssertChar
|
||||
|
@@ -3,9 +3,9 @@
|
||||
#
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -133,7 +133,7 @@ def GetPackageListInfo(FileNameString, WorkSpace, LineNo):
|
||||
continue
|
||||
|
||||
#
|
||||
# Found [Packages] section
|
||||
# Found [Packages] section
|
||||
#
|
||||
if RePackageHeader.match(Line):
|
||||
PackageHederFlag = True
|
||||
@@ -174,7 +174,7 @@ def GetPackageListInfo(FileNameString, WorkSpace, LineNo):
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
#
|
||||
Line = InfExpandMacro(Line, (FileNameString, Line, LineNo), DefineSectionMacros, PackageSectionMacros, True)
|
||||
|
||||
Line = GetSplitValueList(Line, "#", 1)[0]
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for [Binaries] sections in INF file
|
||||
# This file contained the parser for [Binaries] sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -35,7 +35,7 @@ class InfBinarySectionParser(InfParserSectionRoot):
|
||||
#
|
||||
def InfBinaryParser(self, SectionString, InfSectionObject, FileName):
|
||||
#
|
||||
# Macro defined in this section
|
||||
# Macro defined in this section
|
||||
#
|
||||
SectionMacros = {}
|
||||
ValueList = []
|
||||
@@ -56,8 +56,8 @@ class InfBinarySectionParser(InfParserSectionRoot):
|
||||
|
||||
StillCommentFalg = False
|
||||
HeaderComments = []
|
||||
LineComment = None
|
||||
|
||||
LineComment = None
|
||||
|
||||
AllSectionContent = ''
|
||||
#
|
||||
# Parse section content
|
||||
@@ -65,16 +65,16 @@ class InfBinarySectionParser(InfParserSectionRoot):
|
||||
for Line in SectionString:
|
||||
BinLineContent = Line[0]
|
||||
BinLineNo = Line[1]
|
||||
|
||||
|
||||
if BinLineContent.strip() == '':
|
||||
continue
|
||||
|
||||
|
||||
CurrentLineObj = CurrentLine()
|
||||
CurrentLineObj.FileName = FileName
|
||||
CurrentLineObj.LineString = BinLineContent
|
||||
CurrentLineObj.LineNo = BinLineNo
|
||||
#
|
||||
# Found Header Comments
|
||||
# Found Header Comments
|
||||
#
|
||||
if BinLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
|
||||
#
|
||||
@@ -85,7 +85,7 @@ class InfBinarySectionParser(InfParserSectionRoot):
|
||||
AllSectionContent += BinLineContent + DT.END_OF_LINE
|
||||
continue
|
||||
#
|
||||
# First time encounter comment
|
||||
# First time encounter comment
|
||||
#
|
||||
else:
|
||||
#
|
||||
@@ -98,14 +98,14 @@ class InfBinarySectionParser(InfParserSectionRoot):
|
||||
continue
|
||||
else:
|
||||
StillCommentFalg = False
|
||||
|
||||
|
||||
if len(HeaderComments) >= 1:
|
||||
LineComment = InfLineCommentObject()
|
||||
LineCommentContent = ''
|
||||
for Item in HeaderComments:
|
||||
LineCommentContent += Item[0] + DT.END_OF_LINE
|
||||
LineComment.SetHeaderComments(LineCommentContent)
|
||||
|
||||
|
||||
#
|
||||
# Find Tail comment.
|
||||
#
|
||||
@@ -114,8 +114,8 @@ class InfBinarySectionParser(InfParserSectionRoot):
|
||||
BinLineContent = BinLineContent[:BinLineContent.find(DT.TAB_COMMENT_SPLIT)]
|
||||
if LineComment is None:
|
||||
LineComment = InfLineCommentObject()
|
||||
LineComment.SetTailComments(TailComments)
|
||||
|
||||
LineComment.SetTailComments(TailComments)
|
||||
|
||||
#
|
||||
# Find Macro
|
||||
#
|
||||
@@ -126,22 +126,22 @@ class InfBinarySectionParser(InfParserSectionRoot):
|
||||
if MacroDef[0] is not None:
|
||||
SectionMacros[MacroDef[0]] = MacroDef[1]
|
||||
LineComment = None
|
||||
HeaderComments = []
|
||||
HeaderComments = []
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
LineContent = InfExpandMacro(BinLineContent,
|
||||
(FileName, BinLineContent, BinLineNo),
|
||||
self.FileLocalMacros,
|
||||
#
|
||||
LineContent = InfExpandMacro(BinLineContent,
|
||||
(FileName, BinLineContent, BinLineNo),
|
||||
self.FileLocalMacros,
|
||||
SectionMacros, True)
|
||||
|
||||
AllSectionContent += LineContent + DT.END_OF_LINE
|
||||
|
||||
AllSectionContent += LineContent + DT.END_OF_LINE
|
||||
TokenList = GetSplitValueList(LineContent, DT.TAB_VALUE_SPLIT, 1)
|
||||
ValueList[0:len(TokenList)] = TokenList
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
# Should equal to UI/SEC_UI/UNI_UI
|
||||
#
|
||||
ValueList[0] = ValueList[0].strip()
|
||||
@@ -149,84 +149,84 @@ class InfBinarySectionParser(InfParserSectionRoot):
|
||||
ValueList[0] == DT.BINARY_FILE_TYPE_SEC_UI or \
|
||||
ValueList[0] == DT.BINARY_FILE_TYPE_UI:
|
||||
if len(ValueList) == 2:
|
||||
TokenList = GetSplitValueList(ValueList[1],
|
||||
DT.TAB_VALUE_SPLIT,
|
||||
TokenList = GetSplitValueList(ValueList[1],
|
||||
DT.TAB_VALUE_SPLIT,
|
||||
2)
|
||||
NewValueList = []
|
||||
NewValueList.append(ValueList[0])
|
||||
for Item in TokenList:
|
||||
NewValueList.append(Item)
|
||||
UiBinaryList.append((NewValueList,
|
||||
LineComment,
|
||||
CurrentLineObj))
|
||||
#
|
||||
UiBinaryList.append((NewValueList,
|
||||
LineComment,
|
||||
CurrentLineObj))
|
||||
#
|
||||
# Should equal to VER/SEC_VER/UNI_VER
|
||||
#
|
||||
elif ValueList[0] == DT.BINARY_FILE_TYPE_UNI_VER or \
|
||||
ValueList[0] == DT.BINARY_FILE_TYPE_SEC_VER or \
|
||||
ValueList[0] == DT.BINARY_FILE_TYPE_VER:
|
||||
if len(ValueList) == 2:
|
||||
TokenList = GetSplitValueList(ValueList[1],
|
||||
DT.TAB_VALUE_SPLIT,
|
||||
TokenList = GetSplitValueList(ValueList[1],
|
||||
DT.TAB_VALUE_SPLIT,
|
||||
2)
|
||||
NewValueList = []
|
||||
NewValueList.append(ValueList[0])
|
||||
for Item in TokenList:
|
||||
NewValueList.append(Item)
|
||||
VerBinaryList.append((NewValueList,
|
||||
LineComment,
|
||||
NewValueList.append(Item)
|
||||
VerBinaryList.append((NewValueList,
|
||||
LineComment,
|
||||
CurrentLineObj))
|
||||
else:
|
||||
if len(ValueList) == 2:
|
||||
if ValueList[0].strip() == 'SUBTYPE_GUID':
|
||||
TokenList = GetSplitValueList(ValueList[1],
|
||||
DT.TAB_VALUE_SPLIT,
|
||||
TokenList = GetSplitValueList(ValueList[1],
|
||||
DT.TAB_VALUE_SPLIT,
|
||||
5)
|
||||
else:
|
||||
TokenList = GetSplitValueList(ValueList[1],
|
||||
DT.TAB_VALUE_SPLIT,
|
||||
TokenList = GetSplitValueList(ValueList[1],
|
||||
DT.TAB_VALUE_SPLIT,
|
||||
4)
|
||||
|
||||
|
||||
NewValueList = []
|
||||
NewValueList.append(ValueList[0])
|
||||
for Item in TokenList:
|
||||
NewValueList.append(Item)
|
||||
ComBinaryList.append((NewValueList,
|
||||
LineComment,
|
||||
NewValueList.append(Item)
|
||||
ComBinaryList.append((NewValueList,
|
||||
LineComment,
|
||||
CurrentLineObj))
|
||||
elif len(ValueList) == 1:
|
||||
NewValueList = []
|
||||
NewValueList.append(ValueList[0])
|
||||
ComBinaryList.append((NewValueList,
|
||||
LineComment,
|
||||
ComBinaryList.append((NewValueList,
|
||||
LineComment,
|
||||
CurrentLineObj))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ValueList = []
|
||||
LineComment = None
|
||||
TailComments = ''
|
||||
HeaderComments = []
|
||||
HeaderComments = []
|
||||
continue
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
ArchList = []
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
if Item[1] not in ArchList:
|
||||
ArchList.append(Item[1])
|
||||
ArchList.append(Item[1])
|
||||
InfSectionObject.SetSupArchList(Item[1])
|
||||
|
||||
InfSectionObject.SetAllContent(AllSectionContent)
|
||||
if not InfSectionObject.SetBinary(UiBinaryList,
|
||||
VerBinaryList,
|
||||
ComBinaryList,
|
||||
|
||||
InfSectionObject.SetAllContent(AllSectionContent)
|
||||
if not InfSectionObject.SetBinary(UiBinaryList,
|
||||
VerBinaryList,
|
||||
ComBinaryList,
|
||||
ArchList):
|
||||
Logger.Error('InfParser',
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[Binaries]"),
|
||||
File=FileName,
|
||||
Line=Item[3])
|
||||
|
||||
Line=Item[3])
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for BuildOption sections in INF file
|
||||
# This file contained the parser for BuildOption sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -36,10 +36,10 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
|
||||
#
|
||||
#
|
||||
def InfBuildOptionParser(self, SectionString, InfSectionObject, FileName):
|
||||
|
||||
|
||||
BuildOptionList = []
|
||||
SectionContent = ''
|
||||
|
||||
|
||||
if not GlobalData.gIS_BINARY_INF:
|
||||
ValueList = []
|
||||
LineNo = 0
|
||||
@@ -49,24 +49,24 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
|
||||
LineNo = Line[1]
|
||||
TailComments = ''
|
||||
ReplaceFlag = False
|
||||
|
||||
|
||||
if LineContent.strip() == '':
|
||||
SectionContent += LineContent + DT.END_OF_LINE
|
||||
continue
|
||||
SectionContent += LineContent + DT.END_OF_LINE
|
||||
continue
|
||||
#
|
||||
# Found Comment
|
||||
#
|
||||
if LineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
|
||||
SectionContent += LineContent + DT.END_OF_LINE
|
||||
SectionContent += LineContent + DT.END_OF_LINE
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# Find Tail comment.
|
||||
#
|
||||
if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1:
|
||||
TailComments = LineContent[LineContent.find(DT.TAB_COMMENT_SPLIT):]
|
||||
LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]
|
||||
|
||||
LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]
|
||||
|
||||
TokenList = GetSplitValueList(LineContent, DT.TAB_DEQUAL_SPLIT, 1)
|
||||
if len(TokenList) == 2:
|
||||
#
|
||||
@@ -82,21 +82,21 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
|
||||
if len(TokenList) == 2:
|
||||
TokenList.append('False')
|
||||
else:
|
||||
Logger.Error('InfParser',
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID,
|
||||
ExtraData=LineContent,
|
||||
ExtraData=LineContent,
|
||||
File=FileName,
|
||||
Line=LineNo)
|
||||
|
||||
Line=LineNo)
|
||||
|
||||
ValueList[0:len(TokenList)] = TokenList
|
||||
|
||||
|
||||
#
|
||||
# Replace with [Defines] section Macro
|
||||
#
|
||||
ValueList[0] = InfExpandMacro(ValueList[0], (FileName, LineContent, LineNo),
|
||||
ValueList[0] = InfExpandMacro(ValueList[0], (FileName, LineContent, LineNo),
|
||||
self.FileLocalMacros, None)
|
||||
ValueList[1] = InfExpandMacro(ValueList[1], (FileName, LineContent, LineNo),
|
||||
ValueList[1] = InfExpandMacro(ValueList[1], (FileName, LineContent, LineNo),
|
||||
self.FileLocalMacros, None, True)
|
||||
EqualString = ''
|
||||
if not ReplaceFlag:
|
||||
@@ -108,30 +108,30 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
|
||||
|
||||
Family = GetSplitValueList(ValueList[0], DT.TAB_COLON_SPLIT, 1)
|
||||
if len(Family) == 2:
|
||||
if not IsValidFamily(Family[0]):
|
||||
Logger.Error('InfParser',
|
||||
if not IsValidFamily(Family[0]):
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID,
|
||||
ExtraData=LineContent,
|
||||
ExtraData=LineContent,
|
||||
File=FileName,
|
||||
Line=LineNo)
|
||||
if not IsValidBuildOptionName(Family[1]):
|
||||
Logger.Error('InfParser',
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID,
|
||||
ExtraData=LineContent,
|
||||
ExtraData=LineContent,
|
||||
File=FileName,
|
||||
Line=LineNo)
|
||||
if len(Family) == 1:
|
||||
if not IsValidBuildOptionName(Family[0]):
|
||||
Logger.Error('InfParser',
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID,
|
||||
ExtraData=LineContent,
|
||||
ExtraData=LineContent,
|
||||
File=FileName,
|
||||
Line=LineNo)
|
||||
|
||||
BuildOptionList.append(ValueList)
|
||||
|
||||
BuildOptionList.append(ValueList)
|
||||
ValueList = []
|
||||
continue
|
||||
else:
|
||||
@@ -147,20 +147,20 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
|
||||
if not (Item[1] == '' or Item[1] == '') and Item[1] not in ArchList:
|
||||
ArchList.append(Item[1])
|
||||
InfSectionObject.SetSupArchList(Item[1])
|
||||
|
||||
|
||||
InfSectionObject.SetAllContent(SectionContent)
|
||||
if not InfSectionObject.SetBuildOptions(BuildOptionList, ArchList, SectionContent):
|
||||
Logger.Error('InfParser',
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[BuilOptions]"),
|
||||
File=FileName,
|
||||
Line=LastItem[3])
|
||||
Line=LastItem[3])
|
||||
|
||||
## InfBuildOptionParser
|
||||
#
|
||||
#
|
||||
def InfAsBuiltBuildOptionParser(SectionString, FileName):
|
||||
BuildOptionList = []
|
||||
BuildOptionList = []
|
||||
#
|
||||
# AsBuild Binary INF file.
|
||||
#
|
||||
@@ -171,7 +171,7 @@ def InfAsBuiltBuildOptionParser(SectionString, FileName):
|
||||
Count += 1
|
||||
LineContent = Line[0]
|
||||
LineNo = Line[1]
|
||||
|
||||
|
||||
#
|
||||
# The last line
|
||||
#
|
||||
@@ -186,33 +186,33 @@ def InfAsBuiltBuildOptionParser(SectionString, FileName):
|
||||
else:
|
||||
if len(BuildOptionItem) > 0:
|
||||
BuildOptionList.append(BuildOptionItem)
|
||||
|
||||
break
|
||||
|
||||
|
||||
break
|
||||
|
||||
if LineContent.strip() == '':
|
||||
AsBuildOptionFlag = False
|
||||
continue
|
||||
|
||||
|
||||
if LineContent.strip().startswith("##") and AsBuildOptionFlag:
|
||||
if len(BuildOptionItem) > 0:
|
||||
BuildOptionList.append(BuildOptionItem)
|
||||
|
||||
BuildOptionList.append(BuildOptionItem)
|
||||
|
||||
BuildOptionItem = []
|
||||
|
||||
|
||||
if not LineContent.strip().startswith("#"):
|
||||
Logger.Error('InfParser',
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_BO_CONTATIN_ASBUILD_AND_COMMON,
|
||||
File=FileName,
|
||||
Line=LineNo,
|
||||
ST.ERR_BO_CONTATIN_ASBUILD_AND_COMMON,
|
||||
File=FileName,
|
||||
Line=LineNo,
|
||||
ExtraData=LineContent)
|
||||
|
||||
|
||||
if IsAsBuildOptionInfo(LineContent):
|
||||
AsBuildOptionFlag = True
|
||||
continue
|
||||
|
||||
|
||||
if AsBuildOptionFlag:
|
||||
BuildOptionInfo = GetHelpStringByRemoveHashKey(LineContent)
|
||||
BuildOptionItem.append(BuildOptionInfo)
|
||||
|
||||
return BuildOptionList
|
||||
|
||||
return BuildOptionList
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for define sections in INF file
|
||||
# This file contained the parser for define sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -33,32 +33,32 @@ from Logger import StringTable as ST
|
||||
from Parser.InfParserMisc import InfParserSectionRoot
|
||||
|
||||
## __GetValidateArchList
|
||||
#
|
||||
#
|
||||
#
|
||||
def GetValidateArchList(LineContent):
|
||||
|
||||
|
||||
TempArch = ''
|
||||
ArchList = []
|
||||
ValidateAcrhPatten = re.compile(r"^\s*#\s*VALID_ARCHITECTURES\s*=\s*.*$", re.DOTALL)
|
||||
|
||||
|
||||
if ValidateAcrhPatten.match(LineContent):
|
||||
TempArch = GetSplitValueList(LineContent, DT.TAB_EQUAL_SPLIT, 1)[1]
|
||||
|
||||
|
||||
TempArch = GetSplitValueList(TempArch, '(', 1)[0]
|
||||
|
||||
|
||||
ArchList = re.split('\s+', TempArch)
|
||||
NewArchList = []
|
||||
for Arch in ArchList:
|
||||
if IsValidArch(Arch):
|
||||
NewArchList.append(Arch)
|
||||
|
||||
|
||||
ArchList = NewArchList
|
||||
|
||||
return ArchList
|
||||
|
||||
return ArchList
|
||||
|
||||
class InfDefinSectionParser(InfParserSectionRoot):
|
||||
def InfDefineParser(self, SectionString, InfSectionObject, FileName, SectionComment):
|
||||
|
||||
|
||||
if SectionComment:
|
||||
pass
|
||||
#
|
||||
@@ -74,18 +74,18 @@ class InfDefinSectionParser(InfParserSectionRoot):
|
||||
# Add WORKSPACE to global Marco dict.
|
||||
#
|
||||
self.FileLocalMacros['WORKSPACE'] = GlobalData.gWORKSPACE
|
||||
|
||||
|
||||
for Line in SectionString:
|
||||
LineContent = Line[0]
|
||||
LineNo = Line[1]
|
||||
TailComments = ''
|
||||
LineComment = None
|
||||
|
||||
|
||||
LineInfo = ['', -1, '']
|
||||
LineInfo[0] = FileName
|
||||
LineInfo[1] = LineNo
|
||||
LineInfo[2] = LineContent
|
||||
|
||||
|
||||
if LineContent.strip() == '':
|
||||
continue
|
||||
#
|
||||
@@ -106,7 +106,7 @@ class InfDefinSectionParser(InfParserSectionRoot):
|
||||
SectionContent += LineContent + DT.END_OF_LINE
|
||||
continue
|
||||
#
|
||||
# First time encounter comment
|
||||
# First time encounter comment
|
||||
#
|
||||
else:
|
||||
#
|
||||
@@ -119,14 +119,14 @@ class InfDefinSectionParser(InfParserSectionRoot):
|
||||
continue
|
||||
else:
|
||||
StillCommentFalg = False
|
||||
|
||||
|
||||
if len(HeaderComments) >= 1:
|
||||
LineComment = InfLineCommentObject()
|
||||
LineCommentContent = ''
|
||||
for Item in HeaderComments:
|
||||
LineCommentContent += Item[0] + DT.END_OF_LINE
|
||||
LineComment.SetHeaderComments(LineCommentContent)
|
||||
|
||||
|
||||
#
|
||||
# Find Tail comment.
|
||||
#
|
||||
@@ -136,62 +136,62 @@ class InfDefinSectionParser(InfParserSectionRoot):
|
||||
if LineComment is None:
|
||||
LineComment = InfLineCommentObject()
|
||||
LineComment.SetTailComments(TailComments)
|
||||
|
||||
|
||||
#
|
||||
# Find Macro
|
||||
#
|
||||
Name, Value = MacroParser((LineContent, LineNo),
|
||||
FileName,
|
||||
DT.MODEL_META_DATA_HEADER,
|
||||
Name, Value = MacroParser((LineContent, LineNo),
|
||||
FileName,
|
||||
DT.MODEL_META_DATA_HEADER,
|
||||
self.FileLocalMacros)
|
||||
if Name is not None:
|
||||
self.FileLocalMacros[Name] = Value
|
||||
continue
|
||||
continue
|
||||
|
||||
#
|
||||
# Replace with [Defines] section Macro
|
||||
#
|
||||
LineContent = InfExpandMacro(LineContent,
|
||||
(FileName, LineContent, LineNo),
|
||||
self.FileLocalMacros,
|
||||
LineContent = InfExpandMacro(LineContent,
|
||||
(FileName, LineContent, LineNo),
|
||||
self.FileLocalMacros,
|
||||
None, True)
|
||||
|
||||
|
||||
SectionContent += LineContent + DT.END_OF_LINE
|
||||
|
||||
|
||||
TokenList = GetSplitValueList(LineContent, DT.TAB_EQUAL_SPLIT, 1)
|
||||
if len(TokenList) < 2:
|
||||
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE,
|
||||
LineInfo=LineInfo)
|
||||
LineInfo=LineInfo)
|
||||
_ValueList[0:len(TokenList)] = TokenList
|
||||
if not _ValueList[0]:
|
||||
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_NAME,
|
||||
LineInfo=LineInfo)
|
||||
if not _ValueList[1]:
|
||||
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE,
|
||||
LineInfo=LineInfo)
|
||||
|
||||
Name, Value = _ValueList[0], _ValueList[1]
|
||||
|
||||
LineInfo=LineInfo)
|
||||
|
||||
Name, Value = _ValueList[0], _ValueList[1]
|
||||
|
||||
InfDefMemberObj = InfDefMember(Name, Value)
|
||||
if (LineComment is not None):
|
||||
InfDefMemberObj.Comments.SetHeaderComments(LineComment.GetHeaderComments())
|
||||
InfDefMemberObj.Comments.SetTailComments(LineComment.GetTailComments())
|
||||
|
||||
|
||||
InfDefMemberObj.CurrentLine.SetFileName(self.FullPath)
|
||||
InfDefMemberObj.CurrentLine.SetLineString(LineContent)
|
||||
InfDefMemberObj.CurrentLine.SetLineNo(LineNo)
|
||||
|
||||
|
||||
_ContentList.append(InfDefMemberObj)
|
||||
HeaderComments = []
|
||||
TailComments = ''
|
||||
|
||||
|
||||
#
|
||||
# Current Define section archs
|
||||
#
|
||||
if not ArchList:
|
||||
ArchList = ['COMMON']
|
||||
|
||||
InfSectionObject.SetAllContent(SectionContent)
|
||||
|
||||
|
||||
InfSectionObject.SetAllContent(SectionContent)
|
||||
|
||||
InfSectionObject.SetDefines(_ContentList, Arch=ArchList)
|
||||
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for [Depex] sections in INF file
|
||||
# This file contained the parser for [Depex] sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -29,7 +29,7 @@ from Parser.InfParserMisc import InfParserSectionRoot
|
||||
class InfDepexSectionParser(InfParserSectionRoot):
|
||||
## InfDepexParser
|
||||
#
|
||||
# For now, only separate Depex String and comments.
|
||||
# For now, only separate Depex String and comments.
|
||||
# Have two types of section header.
|
||||
# 1. [Depex.Arch.ModuleType, ...]
|
||||
# 2. [Depex.Arch|FFE, ...]
|
||||
@@ -44,7 +44,7 @@ class InfDepexSectionParser(InfParserSectionRoot):
|
||||
for Line in SectionString:
|
||||
LineContent = Line[0]
|
||||
LineNo = Line[1]
|
||||
|
||||
|
||||
#
|
||||
# Found comment
|
||||
#
|
||||
@@ -54,34 +54,34 @@ class InfDepexSectionParser(InfParserSectionRoot):
|
||||
#
|
||||
# Replace with [Defines] section Macro
|
||||
#
|
||||
LineContent = InfExpandMacro(LineContent,
|
||||
(FileName, LineContent, Line[1]),
|
||||
self.FileLocalMacros,
|
||||
LineContent = InfExpandMacro(LineContent,
|
||||
(FileName, LineContent, Line[1]),
|
||||
self.FileLocalMacros,
|
||||
None, True)
|
||||
|
||||
|
||||
CommentCount = LineContent.find(DT.TAB_COMMENT_SPLIT)
|
||||
|
||||
|
||||
if CommentCount > -1:
|
||||
DepexComment.append((LineContent[CommentCount:], LineNo))
|
||||
DepexComment.append((LineContent[CommentCount:], LineNo))
|
||||
LineContent = LineContent[:CommentCount-1]
|
||||
|
||||
|
||||
|
||||
|
||||
CommentCount = -1
|
||||
DepexContent.append((LineContent, LineNo))
|
||||
|
||||
|
||||
TokenList = GetSplitValueList(LineContent, DT.TAB_COMMENT_SPLIT)
|
||||
ValueList[0:len(TokenList)] = TokenList
|
||||
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
KeyList = []
|
||||
LastItem = ''
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
LastItem = Item
|
||||
if (Item[1], Item[2], Item[3]) not in KeyList:
|
||||
KeyList.append((Item[1], Item[2], Item[3]))
|
||||
|
||||
KeyList.append((Item[1], Item[2], Item[3]))
|
||||
|
||||
NewCommentList = []
|
||||
FormatCommentLn = -1
|
||||
ReFormatComment = re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)
|
||||
@@ -90,15 +90,15 @@ class InfDepexSectionParser(InfParserSectionRoot):
|
||||
if ReFormatComment.match(CommentContent) is not None:
|
||||
FormatCommentLn = CommentItem[1] + 1
|
||||
continue
|
||||
|
||||
|
||||
if CommentItem[1] != FormatCommentLn:
|
||||
NewCommentList.append(CommentContent)
|
||||
else:
|
||||
FormatCommentLn = CommentItem[1] + 1
|
||||
|
||||
|
||||
if not InfSectionObject.SetDepex(DepexContent, KeyList = KeyList, CommentList = NewCommentList):
|
||||
Logger.Error('InfParser',
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[Depex]"),
|
||||
File=FileName,
|
||||
Line=LastItem[3])
|
||||
File=FileName,
|
||||
Line=LastItem[3])
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for [Guids], [Ppis], [Protocols] sections in INF file
|
||||
# This file contained the parser for [Guids], [Ppis], [Protocols] sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -37,7 +37,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
#
|
||||
def InfGuidParser(self, SectionString, InfSectionObject, FileName):
|
||||
#
|
||||
# Macro defined in this section
|
||||
# Macro defined in this section
|
||||
#
|
||||
SectionMacros = {}
|
||||
ValueList = []
|
||||
@@ -88,7 +88,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
#
|
||||
ValueList = [InfExpandMacro(Value, (FileName, LineContent, LineNo),
|
||||
self.FileLocalMacros, SectionMacros, True)
|
||||
for Value in ValueList]
|
||||
@@ -104,7 +104,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
ArchList = []
|
||||
LineIndex = -1
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
@@ -124,7 +124,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
#
|
||||
def InfPpiParser(self, SectionString, InfSectionObject, FileName):
|
||||
#
|
||||
# Macro defined in this section
|
||||
# Macro defined in this section
|
||||
#
|
||||
SectionMacros = {}
|
||||
ValueList = []
|
||||
@@ -175,7 +175,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
#
|
||||
ValueList = [InfExpandMacro(Value, (FileName, LineContent, LineNo), self.FileLocalMacros, SectionMacros)
|
||||
for Value in ValueList]
|
||||
|
||||
@@ -189,7 +189,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
ArchList = []
|
||||
LineIndex = -1
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
@@ -206,7 +206,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
## InfUserExtensionParser
|
||||
#
|
||||
#
|
||||
#
|
||||
def InfUserExtensionParser(self, SectionString, InfSectionObject, FileName):
|
||||
|
||||
UserExtensionContent = ''
|
||||
@@ -226,7 +226,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Current section UserId, IdString
|
||||
#
|
||||
#
|
||||
IdContentList = []
|
||||
LastItem = ''
|
||||
SectionLineNo = None
|
||||
@@ -265,14 +265,14 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
IdContentList.append((UserId, IdString, Arch))
|
||||
else:
|
||||
#
|
||||
# Each UserExtensions section header must have a unique set
|
||||
# Each UserExtensions section header must have a unique set
|
||||
# of UserId, IdString and Arch values.
|
||||
# This means that the same UserId can be used in more than one
|
||||
# section header, provided the IdString or Arch values are
|
||||
# different. The same IdString values can be used in more than
|
||||
# one section header if the UserId or Arch values are
|
||||
# different. The same UserId and the same IdString can be used
|
||||
# in a section header if the Arch values are different in each
|
||||
# This means that the same UserId can be used in more than one
|
||||
# section header, provided the IdString or Arch values are
|
||||
# different. The same IdString values can be used in more than
|
||||
# one section header if the UserId or Arch values are
|
||||
# different. The same UserId and the same IdString can be used
|
||||
# in a section header if the Arch values are different in each
|
||||
# of the section headers.
|
||||
#
|
||||
Logger.Error('InfParser',
|
||||
@@ -294,7 +294,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
def InfProtocolParser(self, SectionString, InfSectionObject, FileName):
|
||||
#
|
||||
# Macro defined in this section
|
||||
# Macro defined in this section
|
||||
#
|
||||
SectionMacros = {}
|
||||
ValueList = []
|
||||
@@ -345,7 +345,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
#
|
||||
ValueList = [InfExpandMacro(Value, (FileName, LineContent, LineNo), self.FileLocalMacros, SectionMacros)
|
||||
for Value in ValueList]
|
||||
|
||||
@@ -359,7 +359,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
ArchList = []
|
||||
LineIndex = -1
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for [Libraries] sections in INF file
|
||||
# This file contained the parser for [Libraries] sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -34,14 +34,14 @@ from Parser.InfParserMisc import InfParserSectionRoot
|
||||
class InfLibrarySectionParser(InfParserSectionRoot):
|
||||
## InfLibraryParser
|
||||
#
|
||||
#
|
||||
#
|
||||
def InfLibraryParser(self, SectionString, InfSectionObject, FileName):
|
||||
#
|
||||
# For Common INF file
|
||||
#
|
||||
if not GlobalData.gIS_BINARY_INF:
|
||||
#
|
||||
# Macro defined in this section
|
||||
# Macro defined in this section
|
||||
#
|
||||
SectionMacros = {}
|
||||
ValueList = []
|
||||
@@ -60,7 +60,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
|
||||
continue
|
||||
|
||||
#
|
||||
# Found Header Comments
|
||||
# Found Header Comments
|
||||
#
|
||||
if LibLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
|
||||
#
|
||||
@@ -70,7 +70,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
|
||||
LibHeaderComments.append(Line)
|
||||
continue
|
||||
#
|
||||
# First time encounter comment
|
||||
# First time encounter comment
|
||||
#
|
||||
else:
|
||||
#
|
||||
@@ -118,7 +118,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
#
|
||||
ValueList = [InfExpandMacro(Value, (FileName, LibLineContent, LibLineNo),
|
||||
self.FileLocalMacros, SectionMacros, True)
|
||||
for Value in ValueList]
|
||||
@@ -134,7 +134,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
KeyList = []
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
if (Item[1], Item[2]) not in KeyList:
|
||||
@@ -188,7 +188,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
KeyList = []
|
||||
Item = ['', '', '']
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for [Packages] sections in INF file
|
||||
# This file contained the parser for [Packages] sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -31,29 +31,29 @@ from Parser.InfParserMisc import InfParserSectionRoot
|
||||
class InfPackageSectionParser(InfParserSectionRoot):
|
||||
## InfPackageParser
|
||||
#
|
||||
#
|
||||
#
|
||||
def InfPackageParser(self, SectionString, InfSectionObject, FileName):
|
||||
#
|
||||
# Macro defined in this section
|
||||
# Macro defined in this section
|
||||
#
|
||||
SectionMacros = {}
|
||||
ValueList = []
|
||||
PackageList = []
|
||||
StillCommentFalg = False
|
||||
HeaderComments = []
|
||||
LineComment = None
|
||||
LineComment = None
|
||||
#
|
||||
# Parse section content
|
||||
#
|
||||
for Line in SectionString:
|
||||
PkgLineContent = Line[0]
|
||||
PkgLineNo = Line[1]
|
||||
|
||||
PkgLineNo = Line[1]
|
||||
|
||||
if PkgLineContent.strip() == '':
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# Find Header Comments
|
||||
# Find Header Comments
|
||||
#
|
||||
if PkgLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
|
||||
#
|
||||
@@ -63,7 +63,7 @@ class InfPackageSectionParser(InfParserSectionRoot):
|
||||
HeaderComments.append(Line)
|
||||
continue
|
||||
#
|
||||
# First time encounter comment
|
||||
# First time encounter comment
|
||||
#
|
||||
else:
|
||||
#
|
||||
@@ -75,14 +75,14 @@ class InfPackageSectionParser(InfParserSectionRoot):
|
||||
continue
|
||||
else:
|
||||
StillCommentFalg = False
|
||||
|
||||
|
||||
if len(HeaderComments) >= 1:
|
||||
LineComment = InfLineCommentObject()
|
||||
LineCommentContent = ''
|
||||
for Item in HeaderComments:
|
||||
LineCommentContent += Item[0] + DT.END_OF_LINE
|
||||
LineComment.SetHeaderComments(LineCommentContent)
|
||||
|
||||
|
||||
#
|
||||
# Find Tail comment.
|
||||
#
|
||||
@@ -91,7 +91,7 @@ class InfPackageSectionParser(InfParserSectionRoot):
|
||||
PkgLineContent = PkgLineContent[:PkgLineContent.find(DT.TAB_COMMENT_SPLIT)]
|
||||
if LineComment is None:
|
||||
LineComment = InfLineCommentObject()
|
||||
LineComment.SetTailComments(TailComments)
|
||||
LineComment.SetTailComments(TailComments)
|
||||
#
|
||||
# Find Macro
|
||||
#
|
||||
@@ -102,39 +102,39 @@ class InfPackageSectionParser(InfParserSectionRoot):
|
||||
if Name is not None:
|
||||
SectionMacros[Name] = Value
|
||||
LineComment = None
|
||||
HeaderComments = []
|
||||
HeaderComments = []
|
||||
continue
|
||||
|
||||
TokenList = GetSplitValueList(PkgLineContent, DT.TAB_VALUE_SPLIT, 1)
|
||||
ValueList[0:len(TokenList)] = TokenList
|
||||
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
ValueList = [InfExpandMacro(Value, (FileName, PkgLineContent, PkgLineNo),
|
||||
#
|
||||
ValueList = [InfExpandMacro(Value, (FileName, PkgLineContent, PkgLineNo),
|
||||
self.FileLocalMacros, SectionMacros, True)
|
||||
for Value in ValueList]
|
||||
|
||||
PackageList.append((ValueList, LineComment,
|
||||
|
||||
PackageList.append((ValueList, LineComment,
|
||||
(PkgLineContent, PkgLineNo, FileName)))
|
||||
ValueList = []
|
||||
LineComment = None
|
||||
TailComments = ''
|
||||
HeaderComments = []
|
||||
HeaderComments = []
|
||||
continue
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
ArchList = []
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
if Item[1] not in ArchList:
|
||||
ArchList.append(Item[1])
|
||||
|
||||
ArchList.append(Item[1])
|
||||
|
||||
if not InfSectionObject.SetPackages(PackageList, Arch = ArchList):
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR\
|
||||
%("[Packages]"),
|
||||
File=FileName,
|
||||
Line=Item[3])
|
||||
Line=Item[3])
|
||||
|
@@ -3,9 +3,9 @@
|
||||
#
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -49,24 +49,24 @@ from Parser.InfParserMisc import IsBinaryInf
|
||||
#
|
||||
def OpenInfFile(Filename):
|
||||
FileLinesList = []
|
||||
|
||||
|
||||
try:
|
||||
FInputfile = open(Filename, "rb", 0)
|
||||
try:
|
||||
FileLinesList = FInputfile.readlines()
|
||||
except BaseException:
|
||||
Logger.Error("InfParser",
|
||||
FILE_READ_FAILURE,
|
||||
Logger.Error("InfParser",
|
||||
FILE_READ_FAILURE,
|
||||
ST.ERR_FILE_OPEN_FAILURE,
|
||||
File=Filename)
|
||||
finally:
|
||||
FInputfile.close()
|
||||
except BaseException:
|
||||
Logger.Error("InfParser",
|
||||
FILE_READ_FAILURE,
|
||||
Logger.Error("InfParser",
|
||||
FILE_READ_FAILURE,
|
||||
ST.ERR_FILE_OPEN_FAILURE,
|
||||
File=Filename)
|
||||
|
||||
|
||||
return FileLinesList
|
||||
|
||||
## InfParser
|
||||
@@ -74,20 +74,20 @@ def OpenInfFile(Filename):
|
||||
# This class defined the structure used in InfParser object
|
||||
#
|
||||
# @param InfObject: Inherited from InfSectionParser class
|
||||
# @param Filename: Input value for Filename of INF file, default is
|
||||
# @param Filename: Input value for Filename of INF file, default is
|
||||
# None
|
||||
# @param WorkspaceDir: Input value for current workspace directory,
|
||||
# @param WorkspaceDir: Input value for current workspace directory,
|
||||
# default is None
|
||||
#
|
||||
class InfParser(InfSectionParser):
|
||||
|
||||
def __init__(self, Filename = None, WorkspaceDir = None):
|
||||
|
||||
|
||||
#
|
||||
# Call parent class construct function
|
||||
#
|
||||
super(InfParser, self).__init__()
|
||||
|
||||
|
||||
self.WorkspaceDir = WorkspaceDir
|
||||
self.SupArchList = DT.ARCH_LIST
|
||||
self.EventList = []
|
||||
@@ -107,7 +107,7 @@ class InfParser(InfSectionParser):
|
||||
# @param Filename: Input value for filename of INF file
|
||||
#
|
||||
def ParseInfFile(self, Filename):
|
||||
|
||||
|
||||
Filename = NormPath(Filename)
|
||||
(Path, Name) = os.path.split(Filename)
|
||||
self.FullPath = Filename
|
||||
@@ -120,30 +120,30 @@ class InfParser(InfSectionParser):
|
||||
# Initialize common data
|
||||
#
|
||||
LineNo = 0
|
||||
CurrentSection = DT.MODEL_UNKNOWN
|
||||
CurrentSection = DT.MODEL_UNKNOWN
|
||||
SectionLines = []
|
||||
|
||||
|
||||
#
|
||||
# Flags
|
||||
#
|
||||
HeaderCommentStart = False
|
||||
HeaderCommentStart = False
|
||||
HeaderCommentEnd = False
|
||||
HeaderStarLineNo = -1
|
||||
BinaryHeaderCommentStart = False
|
||||
BinaryHeaderCommentStart = False
|
||||
BinaryHeaderCommentEnd = False
|
||||
BinaryHeaderStarLineNo = -1
|
||||
|
||||
|
||||
#
|
||||
# While Section ends. parse whole section contents.
|
||||
#
|
||||
NewSectionStartFlag = False
|
||||
FirstSectionStartFlag = False
|
||||
|
||||
|
||||
#
|
||||
# Parse file content
|
||||
#
|
||||
CommentBlock = []
|
||||
|
||||
|
||||
#
|
||||
# Variables for Event/Hob/BootMode
|
||||
#
|
||||
@@ -151,44 +151,44 @@ class InfParser(InfSectionParser):
|
||||
self.HobList = []
|
||||
self.BootModeList = []
|
||||
SectionType = ''
|
||||
|
||||
|
||||
FileLinesList = OpenInfFile (Filename)
|
||||
|
||||
|
||||
#
|
||||
# One INF file can only has one [Defines] section.
|
||||
#
|
||||
DefineSectionParsedFlag = False
|
||||
|
||||
|
||||
#
|
||||
# Convert special characters in lines to space character.
|
||||
#
|
||||
FileLinesList = ConvertSpecialChar(FileLinesList)
|
||||
|
||||
|
||||
#
|
||||
# Process Line Extender
|
||||
#
|
||||
FileLinesList = ProcessLineExtender(FileLinesList)
|
||||
|
||||
|
||||
#
|
||||
# Process EdkI INF style comment if found
|
||||
#
|
||||
OrigLines = [Line for Line in FileLinesList]
|
||||
FileLinesList, EdkCommentStartPos = ProcessEdkComment(FileLinesList)
|
||||
|
||||
|
||||
#
|
||||
# Judge whether the INF file is Binary INF or not
|
||||
#
|
||||
if IsBinaryInf(FileLinesList):
|
||||
GlobalData.gIS_BINARY_INF = True
|
||||
|
||||
|
||||
InfSectionCommonDefObj = None
|
||||
|
||||
|
||||
for Line in FileLinesList:
|
||||
LineNo = LineNo + 1
|
||||
Line = Line.strip()
|
||||
if (LineNo < len(FileLinesList) - 1):
|
||||
NextLine = FileLinesList[LineNo].strip()
|
||||
|
||||
|
||||
#
|
||||
# blank line
|
||||
#
|
||||
@@ -209,7 +209,7 @@ class InfParser(InfSectionParser):
|
||||
HeaderStarLineNo = LineNo
|
||||
SectionLines.append((Line, LineNo))
|
||||
HeaderCommentStart = True
|
||||
continue
|
||||
continue
|
||||
|
||||
#
|
||||
# Collect Header content.
|
||||
@@ -225,11 +225,11 @@ class InfParser(InfSectionParser):
|
||||
if (Line.startswith(DT.TAB_SPECIAL_COMMENT) or not Line.strip().startswith("#")) and HeaderCommentStart \
|
||||
and not HeaderCommentEnd:
|
||||
HeaderCommentEnd = True
|
||||
BinaryHeaderCommentStart = False
|
||||
BinaryHeaderCommentStart = False
|
||||
BinaryHeaderCommentEnd = False
|
||||
HeaderCommentStart = False
|
||||
HeaderCommentStart = False
|
||||
if Line.find(DT.TAB_BINARY_HEADER_COMMENT) > -1:
|
||||
self.InfHeaderParser(SectionLines, self.InfHeader, self.FileName)
|
||||
self.InfHeaderParser(SectionLines, self.InfHeader, self.FileName)
|
||||
SectionLines = []
|
||||
else:
|
||||
SectionLines.append((Line, LineNo))
|
||||
@@ -255,8 +255,8 @@ class InfParser(InfSectionParser):
|
||||
SectionLines.append((Line, LineNo))
|
||||
BinaryHeaderCommentStart = True
|
||||
HeaderCommentEnd = True
|
||||
continue
|
||||
|
||||
continue
|
||||
|
||||
#
|
||||
# check whether there are more than one binary header exist
|
||||
#
|
||||
@@ -266,7 +266,7 @@ class InfParser(InfSectionParser):
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_MULTIPLE_BINARYHEADER_EXIST,
|
||||
File=Filename)
|
||||
|
||||
|
||||
#
|
||||
# Collect Binary Header content.
|
||||
#
|
||||
@@ -287,17 +287,17 @@ class InfParser(InfSectionParser):
|
||||
#
|
||||
self.InfHeaderParser(SectionLines, self.InfBinaryHeader, self.FileName, True)
|
||||
SectionLines = []
|
||||
BinaryHeaderCommentEnd = True
|
||||
continue
|
||||
BinaryHeaderCommentEnd = True
|
||||
continue
|
||||
#
|
||||
# Find a new section tab
|
||||
# Or at the last line of INF file,
|
||||
# Or at the last line of INF file,
|
||||
# need to process the last section.
|
||||
#
|
||||
LastSectionFalg = False
|
||||
if LineNo == len(FileLinesList):
|
||||
LastSectionFalg = True
|
||||
|
||||
|
||||
if Line.startswith(DT.TAB_COMMENT_SPLIT) and not Line.startswith(DT.TAB_SPECIAL_COMMENT):
|
||||
SectionLines.append((Line, LineNo))
|
||||
if not LastSectionFalg:
|
||||
@@ -307,23 +307,23 @@ class InfParser(InfSectionParser):
|
||||
# Encountered a section. start with '[' and end with ']'
|
||||
#
|
||||
if (Line.startswith(DT.TAB_SECTION_START) and \
|
||||
Line.find(DT.TAB_SECTION_END) > -1) or LastSectionFalg:
|
||||
|
||||
HeaderCommentEnd = True
|
||||
BinaryHeaderCommentEnd = True
|
||||
|
||||
Line.find(DT.TAB_SECTION_END) > -1) or LastSectionFalg:
|
||||
|
||||
HeaderCommentEnd = True
|
||||
BinaryHeaderCommentEnd = True
|
||||
|
||||
if not LastSectionFalg:
|
||||
#
|
||||
# check to prevent '#' inside section header
|
||||
#
|
||||
HeaderContent = Line[1:Line.find(DT.TAB_SECTION_END)]
|
||||
if HeaderContent.find(DT.TAB_COMMENT_SPLIT) != -1:
|
||||
Logger.Error("InfParser",
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,
|
||||
File=self.FullPath,
|
||||
Line=LineNo,
|
||||
ExtraData=Line)
|
||||
Line=LineNo,
|
||||
ExtraData=Line)
|
||||
|
||||
#
|
||||
# Keep last time section header content for section parser
|
||||
@@ -339,7 +339,7 @@ class InfParser(InfSectionParser):
|
||||
if CommentIndex > -1:
|
||||
TailComments = Line[CommentIndex:]
|
||||
Line = Line[:CommentIndex]
|
||||
|
||||
|
||||
InfSectionCommonDefObj = InfSectionCommonDef()
|
||||
if TailComments != '':
|
||||
InfSectionCommonDefObj.SetTailComments(TailComments)
|
||||
@@ -350,8 +350,8 @@ class InfParser(InfSectionParser):
|
||||
# Call section parser before section header parer to avoid encounter EDKI INF file
|
||||
#
|
||||
if CurrentSection == DT.MODEL_META_DATA_DEFINE:
|
||||
DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,
|
||||
DefineSectionParsedFlag, SectionLines,
|
||||
DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,
|
||||
DefineSectionParsedFlag, SectionLines,
|
||||
InfSectionCommonDefObj, LineNo)
|
||||
#
|
||||
# Compare the new section name with current
|
||||
@@ -377,52 +377,52 @@ class InfParser(InfSectionParser):
|
||||
#
|
||||
# End of section content collect.
|
||||
# Parser the section content collected previously.
|
||||
#
|
||||
#
|
||||
if NewSectionStartFlag or LastSectionFalg:
|
||||
if CurrentSection != DT.MODEL_META_DATA_DEFINE or \
|
||||
(LastSectionFalg and CurrentSection == DT.MODEL_META_DATA_DEFINE):
|
||||
DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,
|
||||
DefineSectionParsedFlag, SectionLines,
|
||||
(LastSectionFalg and CurrentSection == DT.MODEL_META_DATA_DEFINE):
|
||||
DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,
|
||||
DefineSectionParsedFlag, SectionLines,
|
||||
InfSectionCommonDefObj, LineNo)
|
||||
|
||||
|
||||
CurrentSection = SectionType
|
||||
#
|
||||
# Clear section lines
|
||||
#
|
||||
SectionLines = []
|
||||
|
||||
SectionLines = []
|
||||
|
||||
if HeaderStarLineNo == -1:
|
||||
Logger.Error("InfParser",
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_NO_SOURCE_HEADER,
|
||||
File=self.FullPath)
|
||||
File=self.FullPath)
|
||||
if BinaryHeaderStarLineNo > -1 and HeaderStarLineNo > -1 and HeaderStarLineNo > BinaryHeaderStarLineNo:
|
||||
Logger.Error("InfParser",
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_BINARY_HEADER_ORDER,
|
||||
File=self.FullPath)
|
||||
File=self.FullPath)
|
||||
#
|
||||
# EDKII INF should not have EDKI style comment
|
||||
#
|
||||
if EdkCommentStartPos != -1:
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII,
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII,
|
||||
File=self.FullPath,
|
||||
Line=EdkCommentStartPos + 1,
|
||||
ExtraData=OrigLines[EdkCommentStartPos])
|
||||
|
||||
|
||||
#
|
||||
# extract [Event] [Hob] [BootMode] sections
|
||||
#
|
||||
# extract [Event] [Hob] [BootMode] sections
|
||||
#
|
||||
self._ExtractEventHobBootMod(FileLinesList)
|
||||
|
||||
|
||||
## _CheckSectionHeaders
|
||||
#
|
||||
#
|
||||
def _CheckSectionHeaders(self, Line, LineNo):
|
||||
if len(self.SectionHeaderContent) == 0:
|
||||
Logger.Error("InfParser",
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,
|
||||
File=self.FullPath,
|
||||
@@ -431,7 +431,7 @@ class InfParser(InfSectionParser):
|
||||
for SectionItem in self.SectionHeaderContent:
|
||||
ArchList = []
|
||||
#
|
||||
# Not cover Depex/UserExtension section header
|
||||
# Not cover Depex/UserExtension section header
|
||||
# check.
|
||||
#
|
||||
if SectionItem[0].strip().upper() == DT.TAB_INF_FIXED_PCD.upper() or \
|
||||
@@ -442,15 +442,15 @@ class InfParser(InfSectionParser):
|
||||
ArchList = GetSplitValueList(SectionItem[1].strip(), ' ')
|
||||
else:
|
||||
ArchList = [SectionItem[1].strip()]
|
||||
|
||||
|
||||
for Arch in ArchList:
|
||||
if (not IsValidArch(Arch)) and \
|
||||
(SectionItem[0].strip().upper() != DT.TAB_DEPEX.upper()) and \
|
||||
(SectionItem[0].strip().upper() != DT.TAB_USER_EXTENSIONS.upper()) and \
|
||||
(SectionItem[0].strip().upper() != DT.TAB_COMMON_DEFINES.upper()):
|
||||
Logger.Error("InfParser",
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[1]),
|
||||
ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[1]),
|
||||
File=self.FullPath,
|
||||
Line=LineNo, ExtraData=Line)
|
||||
#
|
||||
@@ -467,11 +467,11 @@ class InfParser(InfSectionParser):
|
||||
ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[2]),
|
||||
File=self.FullPath, Line=LineNo,
|
||||
ExtraData=Line)
|
||||
|
||||
|
||||
## _CallSectionParsers
|
||||
#
|
||||
#
|
||||
def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag,
|
||||
def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag,
|
||||
SectionLines, InfSectionCommonDefObj, LineNo):
|
||||
if CurrentSection == DT.MODEL_META_DATA_DEFINE:
|
||||
if not DefineSectionParsedFlag:
|
||||
@@ -481,22 +481,22 @@ class InfParser(InfSectionParser):
|
||||
InfSectionCommonDefObj)
|
||||
DefineSectionParsedFlag = True
|
||||
else:
|
||||
Logger.Error("Parser",
|
||||
PARSER_ERROR,
|
||||
ST.ERR_INF_PARSER_MULTI_DEFINE_SECTION,
|
||||
File=self.FullPath,
|
||||
Logger.Error("Parser",
|
||||
PARSER_ERROR,
|
||||
ST.ERR_INF_PARSER_MULTI_DEFINE_SECTION,
|
||||
File=self.FullPath,
|
||||
RaiseError = Logger.IS_RAISE_ERROR)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_META_DATA_BUILD_OPTION:
|
||||
self.InfBuildOptionParser(SectionLines,
|
||||
self.InfBuildOptionSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_EFI_LIBRARY_CLASS:
|
||||
self.InfLibraryParser(SectionLines,
|
||||
self.InfLibraryClassSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_META_DATA_PACKAGE:
|
||||
self.InfPackageParser(SectionLines,
|
||||
self.InfPackageSection,
|
||||
@@ -512,37 +512,37 @@ class InfParser(InfSectionParser):
|
||||
self.InfPcdParser(SectionLines,
|
||||
self.InfPcdSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_EFI_SOURCE_FILE:
|
||||
self.InfSourceParser(SectionLines,
|
||||
self.InfSourcesSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_META_DATA_USER_EXTENSION:
|
||||
self.InfUserExtensionParser(SectionLines,
|
||||
self.InfUserExtensionSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_EFI_PROTOCOL:
|
||||
self.InfProtocolParser(SectionLines,
|
||||
self.InfProtocolSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_EFI_PPI:
|
||||
self.InfPpiParser(SectionLines,
|
||||
self.InfPpiSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_EFI_GUID:
|
||||
self.InfGuidParser(SectionLines,
|
||||
self.InfGuidSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_EFI_DEPEX:
|
||||
self.InfDepexParser(SectionLines,
|
||||
self.InfDepexSection,
|
||||
self.FullPath)
|
||||
|
||||
|
||||
elif CurrentSection == DT.MODEL_EFI_BINARY_FILE:
|
||||
self.InfBinaryParser(SectionLines,
|
||||
self.InfBinariesSection,
|
||||
@@ -552,20 +552,20 @@ class InfParser(InfSectionParser):
|
||||
#
|
||||
else:
|
||||
if len(self.SectionHeaderContent) >= 1:
|
||||
Logger.Error("Parser",
|
||||
PARSER_ERROR,
|
||||
ST.ERR_INF_PARSER_UNKNOWN_SECTION,
|
||||
File=self.FullPath, Line=LineNo,
|
||||
Logger.Error("Parser",
|
||||
PARSER_ERROR,
|
||||
ST.ERR_INF_PARSER_UNKNOWN_SECTION,
|
||||
File=self.FullPath, Line=LineNo,
|
||||
RaiseError = Logger.IS_RAISE_ERROR)
|
||||
else:
|
||||
Logger.Error("Parser",
|
||||
PARSER_ERROR,
|
||||
ST.ERR_INF_PARSER_NO_SECTION_ERROR,
|
||||
File=self.FullPath, Line=LineNo,
|
||||
Logger.Error("Parser",
|
||||
PARSER_ERROR,
|
||||
ST.ERR_INF_PARSER_NO_SECTION_ERROR,
|
||||
File=self.FullPath, Line=LineNo,
|
||||
RaiseError = Logger.IS_RAISE_ERROR)
|
||||
|
||||
return DefineSectionParsedFlag
|
||||
|
||||
|
||||
return DefineSectionParsedFlag
|
||||
|
||||
def _ExtractEventHobBootMod(self, FileLinesList):
|
||||
SpecialSectionStart = False
|
||||
CheckLocation = False
|
||||
@@ -607,43 +607,43 @@ class InfParser(InfSectionParser):
|
||||
elif not Line:
|
||||
SpecialSectionStart = False
|
||||
CheckLocation = True
|
||||
Element = []
|
||||
Element = []
|
||||
else:
|
||||
if not Line.startswith(DT.TAB_COMMENT_SPLIT):
|
||||
Logger.Warn("Parser",
|
||||
ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,
|
||||
Logger.Warn("Parser",
|
||||
ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,
|
||||
File=self.FullPath, Line=LineNum)
|
||||
SpecialSectionStart = False
|
||||
CheckLocation = False
|
||||
Element = []
|
||||
else:
|
||||
Element.append([Line, LineNum])
|
||||
Element.append([Line, LineNum])
|
||||
else:
|
||||
if CheckLocation:
|
||||
if MatchObject:
|
||||
CheckLocation = False
|
||||
elif Line:
|
||||
Logger.Warn("Parser",
|
||||
ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,
|
||||
File=self.FullPath, Line=LineNum)
|
||||
Logger.Warn("Parser",
|
||||
ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,
|
||||
File=self.FullPath, Line=LineNum)
|
||||
CheckLocation = False
|
||||
|
||||
|
||||
if len(self.BootModeList) >= 1:
|
||||
self.InfSpecialCommentParser(self.BootModeList,
|
||||
self.InfSpecialCommentSection,
|
||||
self.FileName,
|
||||
DT.TYPE_BOOTMODE_SECTION)
|
||||
|
||||
if len(self.EventList) >= 1:
|
||||
self.InfSpecialCommentParser(self.EventList,
|
||||
self.InfSpecialCommentParser(self.BootModeList,
|
||||
self.InfSpecialCommentSection,
|
||||
self.FileName,
|
||||
self.FileName,
|
||||
DT.TYPE_BOOTMODE_SECTION)
|
||||
|
||||
if len(self.EventList) >= 1:
|
||||
self.InfSpecialCommentParser(self.EventList,
|
||||
self.InfSpecialCommentSection,
|
||||
self.FileName,
|
||||
DT.TYPE_EVENT_SECTION)
|
||||
|
||||
|
||||
if len(self.HobList) >= 1:
|
||||
self.InfSpecialCommentParser(self.HobList,
|
||||
self.InfSpecialCommentSection,
|
||||
self.FileName,
|
||||
self.InfSpecialCommentParser(self.HobList,
|
||||
self.InfSpecialCommentSection,
|
||||
self.FileName,
|
||||
DT.TYPE_HOB_SECTION)
|
||||
## _ProcessLastSection
|
||||
#
|
||||
@@ -652,35 +652,35 @@ class InfParser(InfSectionParser):
|
||||
#
|
||||
# The last line is a section header. will discard it.
|
||||
#
|
||||
if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1):
|
||||
if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1):
|
||||
SectionLines.append((Line, LineNo))
|
||||
|
||||
|
||||
if len(self.SectionHeaderContent) >= 1:
|
||||
TemSectionName = self.SectionHeaderContent[0][0].upper()
|
||||
if TemSectionName.upper() not in gINF_SECTION_DEF.keys():
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_UNKNOWN_SECTION,
|
||||
File=self.FullPath,
|
||||
Line=LineNo,
|
||||
Logger.Error("InfParser",
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_UNKNOWN_SECTION,
|
||||
File=self.FullPath,
|
||||
Line=LineNo,
|
||||
ExtraData=Line,
|
||||
RaiseError = Logger.IS_RAISE_ERROR
|
||||
)
|
||||
)
|
||||
else:
|
||||
CurrentSection = gINF_SECTION_DEF[TemSectionName]
|
||||
self.LastSectionHeaderContent = self.SectionHeaderContent
|
||||
|
||||
|
||||
return SectionLines, CurrentSection
|
||||
|
||||
## _ConvertSecNameToType
|
||||
#
|
||||
#
|
||||
def _ConvertSecNameToType(SectionName):
|
||||
def _ConvertSecNameToType(SectionName):
|
||||
SectionType = ''
|
||||
if SectionName.upper() not in gINF_SECTION_DEF.keys():
|
||||
SectionType = DT.MODEL_UNKNOWN
|
||||
SectionType = DT.MODEL_UNKNOWN
|
||||
else:
|
||||
SectionType = gINF_SECTION_DEF[SectionName.upper()]
|
||||
|
||||
return SectionType
|
||||
|
||||
SectionType = gINF_SECTION_DEF[SectionName.upper()]
|
||||
|
||||
return SectionType
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the miscellaneous functions for INF parser
|
||||
# This file contained the miscellaneous functions for INF parser
|
||||
#
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -59,39 +59,39 @@ gINF_SECTION_DEF = {
|
||||
#
|
||||
# EDK1 section
|
||||
# TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE
|
||||
#
|
||||
#
|
||||
}
|
||||
|
||||
## InfExpandMacro
|
||||
#
|
||||
# Expand MACRO definition with MACROs defined in [Defines] section and specific section.
|
||||
# Expand MACRO definition with MACROs defined in [Defines] section and specific section.
|
||||
# The MACROs defined in specific section has high priority and will be expanded firstly.
|
||||
#
|
||||
# @param LineInfo Contain information of FileName, LineContent, LineNo
|
||||
# @param GlobalMacros MACROs defined in INF [Defines] section
|
||||
# @param SectionMacros MACROs defined in INF specific section
|
||||
# @param Flag If the flag set to True, need to skip macros in a quoted string
|
||||
# @param Flag If the flag set to True, need to skip macros in a quoted string
|
||||
#
|
||||
def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Flag=False):
|
||||
if GlobalMacros is None:
|
||||
GlobalMacros = {}
|
||||
if SectionMacros is None:
|
||||
SectionMacros = {}
|
||||
|
||||
|
||||
FileName = LineInfo[0]
|
||||
LineContent = LineInfo[1]
|
||||
LineNo = LineInfo[2]
|
||||
|
||||
|
||||
# Don't expand macros in comments
|
||||
if LineContent.strip().startswith("#"):
|
||||
return Content
|
||||
|
||||
NewLineInfo = (FileName, LineNo, LineContent)
|
||||
|
||||
|
||||
#
|
||||
# First, replace MARCOs with value defined in specific section
|
||||
#
|
||||
Content = ReplaceMacro (Content,
|
||||
Content = ReplaceMacro (Content,
|
||||
SectionMacros,
|
||||
False,
|
||||
(LineContent, LineNo),
|
||||
@@ -100,13 +100,13 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Fla
|
||||
#
|
||||
# Then replace MARCOs with value defined in [Defines] section
|
||||
#
|
||||
Content = ReplaceMacro (Content,
|
||||
Content = ReplaceMacro (Content,
|
||||
GlobalMacros,
|
||||
False,
|
||||
(LineContent, LineNo),
|
||||
FileName,
|
||||
Flag)
|
||||
|
||||
|
||||
MacroUsed = gMACRO_PATTERN.findall(Content)
|
||||
#
|
||||
# no macro found in String, stop replacing
|
||||
@@ -122,9 +122,9 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Fla
|
||||
#
|
||||
ErrorInInf (ERR_MARCO_DEFINITION_MISS_ERROR,
|
||||
LineInfo=NewLineInfo)
|
||||
|
||||
|
||||
return Content
|
||||
|
||||
|
||||
|
||||
## IsBinaryInf
|
||||
#
|
||||
@@ -135,25 +135,25 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Fla
|
||||
def IsBinaryInf(FileLineList):
|
||||
if not FileLineList:
|
||||
return False
|
||||
|
||||
|
||||
ReIsSourcesSection = re.compile("^\s*\[Sources.*\]\s.*$", re.IGNORECASE)
|
||||
ReIsBinarySection = re.compile("^\s*\[Binaries.*\]\s.*$", re.IGNORECASE)
|
||||
BinarySectionFoundFlag = False
|
||||
|
||||
|
||||
for Line in FileLineList:
|
||||
if ReIsSourcesSection.match(Line):
|
||||
return False
|
||||
if ReIsBinarySection.match(Line):
|
||||
BinarySectionFoundFlag = True
|
||||
|
||||
|
||||
if BinarySectionFoundFlag:
|
||||
return True
|
||||
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
## IsLibInstanceInfo
|
||||
#
|
||||
#
|
||||
# Judge whether the string contain the information of ## @LIB_INSTANCES.
|
||||
#
|
||||
# @param String
|
||||
@@ -166,10 +166,10 @@ def IsLibInstanceInfo(String):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
## IsAsBuildOptionInfo
|
||||
#
|
||||
#
|
||||
# Judge whether the string contain the information of ## @ASBUILD.
|
||||
#
|
||||
# @param String
|
||||
@@ -181,8 +181,8 @@ def IsAsBuildOptionInfo(String):
|
||||
if ReIsAsBuildInstance.match(String):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class InfParserSectionRoot(object):
|
||||
def __init__(self):
|
||||
@@ -190,19 +190,19 @@ class InfParserSectionRoot(object):
|
||||
# Macros defined in [Define] section are file scope global
|
||||
#
|
||||
self.FileLocalMacros = {}
|
||||
|
||||
|
||||
#
|
||||
# Current Section Header content.
|
||||
# Current Section Header content.
|
||||
#
|
||||
self.SectionHeaderContent = []
|
||||
|
||||
#
|
||||
# Last time Section Header content.
|
||||
# Last time Section Header content.
|
||||
#
|
||||
self.LastSectionHeaderContent = []
|
||||
|
||||
self.LastSectionHeaderContent = []
|
||||
|
||||
self.FullPath = ''
|
||||
|
||||
|
||||
self.InfDefSection = None
|
||||
self.InfBuildOptionSection = None
|
||||
self.InfLibraryClassSection = None
|
||||
@@ -219,4 +219,4 @@ class InfParserSectionRoot(object):
|
||||
self.InfSmmDepexSection = None
|
||||
self.InfBinariesSection = None
|
||||
self.InfHeader = None
|
||||
self.InfSpecialCommentSection = None
|
||||
self.InfSpecialCommentSection = None
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for [Pcds] sections in INF file
|
||||
# This file contained the parser for [Pcds] sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -31,49 +31,49 @@ from Parser.InfParserMisc import InfParserSectionRoot
|
||||
|
||||
class InfPcdSectionParser(InfParserSectionRoot):
|
||||
## Section PCD related parser
|
||||
#
|
||||
#
|
||||
# For 5 types of PCD list below, all use this function.
|
||||
# 'FixedPcd', 'FeaturePcd', 'PatchPcd', 'Pcd', 'PcdEx'
|
||||
#
|
||||
# This is a INF independent parser, the validation in this parser only
|
||||
# This is a INF independent parser, the validation in this parser only
|
||||
# cover
|
||||
# INF spec scope, will not cross DEC/DSC to check pcd value
|
||||
#
|
||||
def InfPcdParser(self, SectionString, InfSectionObject, FileName):
|
||||
KeysList = []
|
||||
PcdList = []
|
||||
CommentsList = []
|
||||
ValueList = []
|
||||
CommentsList = []
|
||||
ValueList = []
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
#
|
||||
LineIndex = -1
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
if (Item[0], Item[1], Item[3]) not in KeysList:
|
||||
KeysList.append((Item[0], Item[1], Item[3]))
|
||||
LineIndex = Item[3]
|
||||
|
||||
|
||||
if (Item[0].upper() == DT.TAB_INF_FIXED_PCD.upper() or \
|
||||
Item[0].upper() == DT.TAB_INF_FEATURE_PCD.upper() or \
|
||||
Item[0].upper() == DT.TAB_INF_PCD.upper()) and GlobalData.gIS_BINARY_INF:
|
||||
Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_ASBUILD_PCD_SECTION_TYPE%("\"" + Item[0] + "\""),
|
||||
File=FileName, Line=LineIndex)
|
||||
|
||||
File=FileName, Line=LineIndex)
|
||||
|
||||
#
|
||||
# For Common INF file
|
||||
#
|
||||
if not GlobalData.gIS_BINARY_INF:
|
||||
if not GlobalData.gIS_BINARY_INF:
|
||||
#
|
||||
# Macro defined in this section
|
||||
# Macro defined in this section
|
||||
#
|
||||
SectionMacros = {}
|
||||
SectionMacros = {}
|
||||
for Line in SectionString:
|
||||
PcdLineContent = Line[0]
|
||||
PcdLineNo = Line[1]
|
||||
if PcdLineContent.strip() == '':
|
||||
CommentsList = []
|
||||
continue
|
||||
|
||||
continue
|
||||
|
||||
if PcdLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
|
||||
CommentsList.append(Line)
|
||||
continue
|
||||
@@ -83,10 +83,10 @@ class InfPcdSectionParser(InfParserSectionRoot):
|
||||
#
|
||||
if PcdLineContent.find(DT.TAB_COMMENT_SPLIT) > -1:
|
||||
CommentsList.append((
|
||||
PcdLineContent[PcdLineContent.find(DT.TAB_COMMENT_SPLIT):],
|
||||
PcdLineContent[PcdLineContent.find(DT.TAB_COMMENT_SPLIT):],
|
||||
PcdLineNo))
|
||||
PcdLineContent = PcdLineContent[:PcdLineContent.find(DT.TAB_COMMENT_SPLIT)]
|
||||
|
||||
PcdLineContent = PcdLineContent[:PcdLineContent.find(DT.TAB_COMMENT_SPLIT)]
|
||||
|
||||
if PcdLineContent != '':
|
||||
#
|
||||
# Find Macro
|
||||
@@ -100,23 +100,23 @@ class InfPcdSectionParser(InfParserSectionRoot):
|
||||
ValueList = []
|
||||
CommentsList = []
|
||||
continue
|
||||
|
||||
|
||||
PcdEntryReturn = SplitPcdEntry(PcdLineContent)
|
||||
|
||||
|
||||
if not PcdEntryReturn[1]:
|
||||
TokenList = ['']
|
||||
TokenList = ['']
|
||||
else:
|
||||
TokenList = PcdEntryReturn[0]
|
||||
|
||||
|
||||
ValueList[0:len(TokenList)] = TokenList
|
||||
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
ValueList = [InfExpandMacro(Value, (FileName, PcdLineContent, PcdLineNo),
|
||||
#
|
||||
ValueList = [InfExpandMacro(Value, (FileName, PcdLineContent, PcdLineNo),
|
||||
self.FileLocalMacros, SectionMacros, True)
|
||||
for Value in ValueList]
|
||||
|
||||
|
||||
if len(ValueList) >= 1:
|
||||
PcdList.append((ValueList, CommentsList, (PcdLineContent, PcdLineNo, FileName)))
|
||||
ValueList = []
|
||||
@@ -129,11 +129,11 @@ class InfPcdSectionParser(InfParserSectionRoot):
|
||||
for Line in SectionString:
|
||||
LineContent = Line[0].strip()
|
||||
LineNo = Line[1]
|
||||
|
||||
|
||||
if LineContent == '':
|
||||
CommentsList = []
|
||||
continue
|
||||
|
||||
|
||||
if LineContent.startswith(DT.TAB_COMMENT_SPLIT):
|
||||
CommentsList.append(LineContent)
|
||||
continue
|
||||
@@ -144,7 +144,7 @@ class InfPcdSectionParser(InfParserSectionRoot):
|
||||
if CommentIndex > -1:
|
||||
CommentsList.append(LineContent[CommentIndex+1:])
|
||||
LineContent = LineContent[:CommentIndex]
|
||||
|
||||
|
||||
TokenList = GetSplitValueList(LineContent, DT.TAB_VALUE_SPLIT)
|
||||
#
|
||||
# PatchablePcd
|
||||
@@ -152,33 +152,33 @@ class InfPcdSectionParser(InfParserSectionRoot):
|
||||
#
|
||||
if KeysList[0][0].upper() == DT.TAB_INF_PATCH_PCD.upper():
|
||||
if len(TokenList) != 3:
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_ASBUILD_PATCHPCD_FORMAT_INVALID,
|
||||
File=FileName,
|
||||
Line=LineNo,
|
||||
ExtraData=LineContent)
|
||||
#
|
||||
#
|
||||
elif KeysList[0][0].upper() == DT.TAB_INF_PCD_EX.upper():
|
||||
if len(TokenList) != 1:
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_ASBUILD_PCDEX_FORMAT_INVALID,
|
||||
File=FileName,
|
||||
Line=LineNo,
|
||||
ExtraData=LineContent)
|
||||
ValueList[0:len(TokenList)] = TokenList
|
||||
if len(ValueList) >= 1:
|
||||
PcdList.append((ValueList, CommentsList, (LineContent, LineNo, FileName)))
|
||||
if len(ValueList) >= 1:
|
||||
PcdList.append((ValueList, CommentsList, (LineContent, LineNo, FileName)))
|
||||
ValueList = []
|
||||
CommentsList = []
|
||||
continue
|
||||
|
||||
if not InfSectionObject.SetPcds(PcdList, KeysList = KeysList,
|
||||
continue
|
||||
|
||||
if not InfSectionObject.SetPcds(PcdList, KeysList = KeysList,
|
||||
PackageInfo = self.InfPackageSection.GetPackages()):
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[PCD]"),
|
||||
File=FileName,
|
||||
Line=LineIndex)
|
||||
|
||||
Line=LineIndex)
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for sections in INF file
|
||||
# This file contained the parser for sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -95,7 +95,7 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionString):
|
||||
if ItemList[3] != '':
|
||||
Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_SOURCE_SECTION_SECTIONNAME_INVALID \
|
||||
% (SectionString), File=FileName, Line=LineNo, ExtraData=SectionString)
|
||||
|
||||
|
||||
if not ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper():
|
||||
Str2 = ItemList[2] + ' | ' + ItemList[3]
|
||||
else:
|
||||
@@ -108,7 +108,7 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionString):
|
||||
return Str2
|
||||
|
||||
## ProcessUseExtHeader
|
||||
#
|
||||
#
|
||||
#
|
||||
def ProcessUseExtHeader(ItemList):
|
||||
NewItemList = []
|
||||
@@ -138,12 +138,12 @@ def ProcessUseExtHeader(ItemList):
|
||||
NewItemList.append(Item)
|
||||
else:
|
||||
AppendContent = AppendContent + "." + Item
|
||||
|
||||
|
||||
if len(NewItemList) > 4:
|
||||
return False, []
|
||||
|
||||
|
||||
return True, NewItemList
|
||||
|
||||
|
||||
## GetArch
|
||||
#
|
||||
# GetArch
|
||||
@@ -244,7 +244,7 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
|
||||
#
|
||||
# A List for store define section content.
|
||||
#
|
||||
#
|
||||
self._PcdNameList = []
|
||||
self._SectionName = ''
|
||||
self._SectionType = 0
|
||||
@@ -253,7 +253,7 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
|
||||
#
|
||||
# File Header content parser
|
||||
#
|
||||
#
|
||||
def InfHeaderParser(self, Content, InfHeaderObject2, FileName, IsBinaryHeader = False):
|
||||
if IsBinaryHeader:
|
||||
(Abstract, Description, Copyright, License) = ParseHeaderCommentSection(Content, FileName, True)
|
||||
@@ -272,7 +272,7 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
|
||||
#
|
||||
# Insert Abstract, Description, CopyRight, License into header object
|
||||
#
|
||||
#
|
||||
InfHeaderObject2.SetAbstract(Abstract)
|
||||
InfHeaderObject2.SetDescription(Description)
|
||||
InfHeaderObject2.SetCopyright(Copyright)
|
||||
@@ -287,7 +287,7 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
#
|
||||
# [section_name.arch<.platform|module_type>]
|
||||
#
|
||||
# @param String A string contained the content need to be parsed.
|
||||
# @param String A string contained the content need to be parsed.
|
||||
#
|
||||
def SectionHeaderParser(self, SectionString, FileName, LineNo):
|
||||
_Scope = []
|
||||
@@ -313,7 +313,7 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
#
|
||||
# different section should not mix in one section
|
||||
# Allow different PCD type sections mixed together
|
||||
#
|
||||
#
|
||||
if _SectionName.upper() not in _PcdNameList:
|
||||
if _SectionName != '' and _SectionName.upper() != ItemList[0].upper():
|
||||
Logger.Error('Parser',
|
||||
@@ -350,7 +350,7 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
|
||||
#
|
||||
# For [Defines] section, do special check.
|
||||
#
|
||||
#
|
||||
if ItemList[0].upper() == DT.TAB_COMMON_DEFINES.upper():
|
||||
if len(ItemList) != 1:
|
||||
Logger.Error('Parser',
|
||||
@@ -360,26 +360,26 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
|
||||
#
|
||||
# For [UserExtension] section, do special check.
|
||||
#
|
||||
#
|
||||
if ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper():
|
||||
|
||||
|
||||
RetValue = ProcessUseExtHeader(ItemList)
|
||||
|
||||
|
||||
if not RetValue[0]:
|
||||
Logger.Error('Parser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (SectionString),
|
||||
File=FileName, Line=LineNo, ExtraData=SectionString)
|
||||
else:
|
||||
ItemList = RetValue[1]
|
||||
|
||||
ItemList = RetValue[1]
|
||||
|
||||
if len(ItemList) == 3:
|
||||
ItemList.append('COMMON')
|
||||
|
||||
|
||||
Str1 = ItemList[1]
|
||||
|
||||
#
|
||||
# For Library classes, need to check module type.
|
||||
# For Library classes, need to check module type.
|
||||
#
|
||||
if ItemList[0].upper() == DT.TAB_LIBRARY_CLASSES.upper() and len(ItemList) == 3:
|
||||
if ItemList[2] != '':
|
||||
@@ -424,10 +424,10 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
|
||||
## GenSpecialSectionList
|
||||
#
|
||||
# @param SpecialSectionList: a list of list, of which item's format
|
||||
# @param SpecialSectionList: a list of list, of which item's format
|
||||
# (Comment, LineNum)
|
||||
# @param ContainerFile: Input value for filename of Inf file
|
||||
#
|
||||
#
|
||||
def InfSpecialCommentParser (self, SpecialSectionList, InfSectionObject, ContainerFile, SectionType):
|
||||
ReFindSpecialCommentRe = re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)
|
||||
ReFindHobArchRe = re.compile(r"""[Hh][Oo][Bb]\.([^,]*)""", re.DOTALL)
|
||||
|
@@ -1,11 +1,11 @@
|
||||
## @file
|
||||
# This file contained the parser for [Sources] sections in INF file
|
||||
# This file contained the parser for [Sources] sections in INF file
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -31,7 +31,7 @@ from Parser.InfParserMisc import InfParserSectionRoot
|
||||
class InfSourceSectionParser(InfParserSectionRoot):
|
||||
## InfSourceParser
|
||||
#
|
||||
#
|
||||
#
|
||||
def InfSourceParser(self, SectionString, InfSectionObject, FileName):
|
||||
SectionMacros = {}
|
||||
ValueList = []
|
||||
@@ -43,12 +43,12 @@ class InfSourceSectionParser(InfParserSectionRoot):
|
||||
for Line in SectionString:
|
||||
SrcLineContent = Line[0]
|
||||
SrcLineNo = Line[1]
|
||||
|
||||
|
||||
if SrcLineContent.strip() == '':
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# Found Header Comments
|
||||
# Found Header Comments
|
||||
#
|
||||
if SrcLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
|
||||
#
|
||||
@@ -59,7 +59,7 @@ class InfSourceSectionParser(InfParserSectionRoot):
|
||||
SectionContent += SrcLineContent + DT.END_OF_LINE
|
||||
continue
|
||||
#
|
||||
# First time encounter comment
|
||||
# First time encounter comment
|
||||
#
|
||||
else:
|
||||
#
|
||||
@@ -68,18 +68,18 @@ class InfSourceSectionParser(InfParserSectionRoot):
|
||||
HeaderComments = []
|
||||
HeaderComments.append(Line)
|
||||
StillCommentFalg = True
|
||||
SectionContent += SrcLineContent + DT.END_OF_LINE
|
||||
SectionContent += SrcLineContent + DT.END_OF_LINE
|
||||
continue
|
||||
else:
|
||||
StillCommentFalg = False
|
||||
|
||||
|
||||
if len(HeaderComments) >= 1:
|
||||
LineComment = InfLineCommentObject()
|
||||
LineCommentContent = ''
|
||||
for Item in HeaderComments:
|
||||
LineCommentContent += Item[0] + DT.END_OF_LINE
|
||||
LineComment.SetHeaderComments(LineCommentContent)
|
||||
|
||||
|
||||
#
|
||||
# Find Tail comment.
|
||||
#
|
||||
@@ -89,11 +89,11 @@ class InfSourceSectionParser(InfParserSectionRoot):
|
||||
if LineComment is None:
|
||||
LineComment = InfLineCommentObject()
|
||||
LineComment.SetTailComments(TailComments)
|
||||
|
||||
|
||||
#
|
||||
# Find Macro
|
||||
#
|
||||
Name, Value = MacroParser((SrcLineContent, SrcLineNo),
|
||||
Name, Value = MacroParser((SrcLineContent, SrcLineNo),
|
||||
FileName,
|
||||
DT.MODEL_EFI_SOURCE_FILE,
|
||||
self.FileLocalMacros)
|
||||
@@ -102,44 +102,44 @@ class InfSourceSectionParser(InfParserSectionRoot):
|
||||
LineComment = None
|
||||
HeaderComments = []
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# Replace with Local section Macro and [Defines] section Macro.
|
||||
#
|
||||
SrcLineContent = InfExpandMacro(SrcLineContent,
|
||||
(FileName, SrcLineContent, SrcLineNo),
|
||||
self.FileLocalMacros,
|
||||
#
|
||||
SrcLineContent = InfExpandMacro(SrcLineContent,
|
||||
(FileName, SrcLineContent, SrcLineNo),
|
||||
self.FileLocalMacros,
|
||||
SectionMacros)
|
||||
|
||||
TokenList = GetSplitValueList(SrcLineContent, DT.TAB_VALUE_SPLIT, 4)
|
||||
ValueList[0:len(TokenList)] = TokenList
|
||||
|
||||
|
||||
#
|
||||
# Store section content string after MACRO replaced.
|
||||
#
|
||||
SectionContent += SrcLineContent + DT.END_OF_LINE
|
||||
|
||||
SourceList.append((ValueList, LineComment,
|
||||
SectionContent += SrcLineContent + DT.END_OF_LINE
|
||||
|
||||
SourceList.append((ValueList, LineComment,
|
||||
(SrcLineContent, SrcLineNo, FileName)))
|
||||
ValueList = []
|
||||
LineComment = None
|
||||
TailComments = ''
|
||||
HeaderComments = []
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# Current section archs
|
||||
#
|
||||
ArchList = []
|
||||
for Item in self.LastSectionHeaderContent:
|
||||
if Item[1] not in ArchList:
|
||||
ArchList.append(Item[1])
|
||||
ArchList.append(Item[1])
|
||||
InfSectionObject.SetSupArchList(Item[1])
|
||||
|
||||
InfSectionObject.SetAllContent(SectionContent)
|
||||
|
||||
InfSectionObject.SetAllContent(SectionContent)
|
||||
if not InfSectionObject.SetSources(SourceList, Arch = ArchList):
|
||||
Logger.Error('InfParser',
|
||||
Logger.Error('InfParser',
|
||||
FORMAT_INVALID,
|
||||
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[Sources]"),
|
||||
File=FileName,
|
||||
Line=Item[3])
|
||||
File=FileName,
|
||||
Line=Item[3])
|
||||
|
@@ -4,11 +4,11 @@
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -17,4 +17,4 @@
|
||||
|
||||
'''
|
||||
Parser
|
||||
'''
|
||||
'''
|
||||
|
Reference in New Issue
Block a user