diff options
Diffstat (limited to 'BaseTools/Source/Python')
11 files changed, 182 insertions, 84 deletions
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 49816832..7b1ce72e 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -38,6 +38,9 @@ LF = u'\u000A' NULL = u'\u0000'
TAB = u'\t'
BACK_SPLASH = u'\\'
+DOBULE_QUOTED_SPLASH = u'\\"'
+SIGLE_QUOTED_SPLASH = u"\\'"
+TAB_BACK_SLASH = u"\\/"
gIncludePattern = re.compile("^#include +[\"<]+([^\"< >]+)[>\"]+$", re.MULTILINE | re.UNICODE)
@@ -346,7 +349,10 @@ class UniFileClassObject(object): Line = Line.replace(u'''\"''', u'''"''')
Line = Line.replace(u'\t', u' ')
Line = Line.replace(u'\u0006', u'\\')
-
+ Line = Line.replace(DOBULE_QUOTED_SPLASH, u'"')
+ Line = Line.replace(SIGLE_QUOTED_SPLASH, u"'")
+ Line = Line.replace(TAB_BACK_SLASH, u"/")
+
# if Line.find(u'\\x'):
# hex = Line[Line.find(u'\\x') + 2 : Line.find(u'\\x') + 6]
# hex = "u'\\u" + hex + "'"
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index c9c620d8..547271d5 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -2503,16 +2503,16 @@ class FdfParser: self.__GetFileOpts( FfsFileObj)
if not self.__IsToken("{"):
-# if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'):
-# if self.__FileCouldHaveRelocFlag(FfsFileObj.FvFileType):
-# if self.__Token == 'RELOCS_STRIPPED':
-# FfsFileObj.KeepReloc = False
-# else:
-# FfsFileObj.KeepReloc = True
-# else:
-# raise Warning("File type %s could not have reloc strip flag%d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
-#
-# if not self.__IsToken("{"):
+ if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'):
+ if self.__FileCouldHaveRelocFlag(FfsFileObj.FvFileType):
+ if self.__Token == 'RELOCS_STRIPPED':
+ FfsFileObj.KeepReloc = False
+ else:
+ FfsFileObj.KeepReloc = True
+ else:
+ raise Warning("File type %s could not have reloc strip flag%d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
+
+ if not self.__IsToken("{"):
raise Warning("expected '{'", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py index 04527fe0..d0dec380 100755 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -110,6 +110,8 @@ class FileStatement (FileStatementClassObject) : if FvParentAddr != None and isinstance(section, GuidSection):
section.FvParentAddr = FvParentAddr
+ if self.KeepReloc == False:
+ section.KeepReloc = False
sectList, align = section.GenSection(OutputDir, self.NameGuid, SecIndex, self.KeyStringList, None, Dict)
if sectList != []:
for sect in sectList:
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index b4579376..2fa4cb8c 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -345,7 +345,7 @@ class GenFdsGlobalVariable: @staticmethod def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None, - GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None): + GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None): Cmd = ["GenSec"] if Type not in [None, '']: Cmd += ["-s", Type] @@ -364,6 +364,7 @@ class GenFdsGlobalVariable: for SecAlign in InputAlign: Cmd += ["--sectionalign", SecAlign] + CommandFile = Output + '.txt' if Ui not in [None, '']: #Cmd += ["-n", '"' + Ui + '"'] SectionData = array.array('B', [0,0,0,0]) @@ -374,19 +375,20 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) SaveFileOnChange(Output, SectionData.tostring()) elif Ver not in [None, '']: - #Cmd += ["-j", Ver] - SectionData = array.array('B', [0,0,0,0]) - SectionData.fromstring(Ver.encode("utf_16_le")) - SectionData.append(0) - SectionData.append(0) - Len = len(SectionData) - GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x14) - SaveFileOnChange(Output, SectionData.tostring()) + Cmd += ["-n", Ver] + if BuildNumber: + Cmd += ["-j", BuildNumber] + Cmd += ["-o", Output] + + SaveFileOnChange(CommandFile, ' '.join(Cmd), False) + if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]): + return + + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section") else: Cmd += ["-o", Output] Cmd += Input - CommandFile = Output + '.txt' SaveFileOnChange(CommandFile, ' '.join(Cmd), False) if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]): return diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py index 3fca4064..8f6da962 100644 --- a/BaseTools/Source/Python/GenFds/VerSection.py +++ b/BaseTools/Source/Python/GenFds/VerSection.py @@ -76,7 +76,7 @@ class VerSection (VerSectionClassObject): StringData = ''
GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_VERSION',
- Ui=StringData, Ver=self.BuildNum)
+ Ver=StringData, BuildNumber=self.BuildNum)
OutputFileList = []
OutputFileList.append(OutputFile)
return OutputFileList, self.Alignment
diff --git a/BaseTools/Source/Python/UPT/Library/GlobalData.py b/BaseTools/Source/Python/UPT/Library/GlobalData.py index fedd9815..3f72f227 100644 --- a/BaseTools/Source/Python/UPT/Library/GlobalData.py +++ b/BaseTools/Source/Python/UPT/Library/GlobalData.py @@ -92,3 +92,8 @@ gUNPACK_DIR = None # Flag used to mark whether the INF file is Binary INF or not. # gIS_BINARY_INF = False +# +# Used by Library instance parser +# {FilePath: FileObj} +# +gLIBINSTANCEDICT = {}
\ No newline at end of file diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py index d576cffb..27a1c6ad 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py @@ -89,19 +89,19 @@ class InfUserExtensionObject(): InfUserExtensionItemObj.SetContent(UserExtensionCont)
InfUserExtensionItemObj.SetSupArchList(IdContentItem[2])
- for CheckItem in self.UserExtension:
- if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]:
- if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON':
- #
- # For COMMON ARCH type, do special check.
- #
- Logger.Error('InfParser',
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
- (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
- File=GlobalData.gINF_MODULE_NAME,
- Line=LineNo,
- ExtraData=None)
+# for CheckItem in self.UserExtension:
+# if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]:
+# if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON':
+# #
+# # For COMMON ARCH type, do special check.
+# #
+# Logger.Error('InfParser',
+# ToolError.FORMAT_INVALID,
+# ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
+# (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
+# File=GlobalData.gINF_MODULE_NAME,
+# Line=LineNo,
+# ExtraData=None)
if self.UserExtension.has_key(IdContentItem):
#
diff --git a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py index 12c46f19..6bf070be 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py +++ b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py @@ -42,12 +42,12 @@ from Library import DataType as DT # @param WorkSpace. The WorkSpace directory used to combined with INF file path.
#
# @return GUID, Version
-def GetLibInstanceInfo(String, WorkSpace, LineNo):
-
+def GetLibInstanceInfo(String, WorkSpace, LineNo, CurrentInfFileName):
+
FileGuidString = ""
VerString = ""
-
- OrignalString = String
+
+ OrignalString = String
String = String.strip()
if not String:
return None, None
@@ -56,28 +56,48 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo): #
String = GetHelpStringByRemoveHashKey(String)
String = String.strip()
-
+
+ #
+ # To deal with library instance specified by GUID and version
+ #
+ RegFormatGuidPattern = re.compile("\s*([0-9a-fA-F]){8}-"
+ "([0-9a-fA-F]){4}-"
+ "([0-9a-fA-F]){4}-"
+ "([0-9a-fA-F]){4}-"
+ "([0-9a-fA-F]){12}\s*")
+ VersionPattern = re.compile('[\t\s]*\d+(\.\d+)?[\t\s]*')
+ GuidMatchedObj = RegFormatGuidPattern.search(String)
+
+ if String.upper().startswith('GUID') and GuidMatchedObj and 'Version' in String:
+ VersionStr = String[String.upper().find('VERSION') + 8:]
+ VersionMatchedObj = VersionPattern.search(VersionStr)
+ if VersionMatchedObj:
+ Guid = GuidMatchedObj.group().strip()
+ Version = VersionMatchedObj.group().strip()
+ return GetGuidVerFormLibInstance(Guid, Version, WorkSpace, CurrentInfFileName)
+
+ #
+ # To deal with library instance specified by file name
+ #
FileLinesList = GetFileLineContent(String, WorkSpace, LineNo, OrignalString)
-
+
ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")
-
- FileLinesList = ProcessLineExtender(FileLinesList)
for Line in FileLinesList:
if ReFindFileGuidPattern.match(Line):
FileGuidString = Line
if ReFindVerStringPattern.match(Line):
VerString = Line
-
+
if FileGuidString:
FileGuidString = GetSplitValueList(FileGuidString, '=', 1)[1]
if VerString:
VerString = GetSplitValueList(VerString, '=', 1)[1]
-
+
return FileGuidString, VerString
-
+
## GetPackageListInfo
#
# Get the package information from INF file.
@@ -184,36 +204,97 @@ def GetFileLineContent(FileName, WorkSpace, LineNo, OriginalString): #
# Validate file exist/format.
#
- if IsValidPath(FileName, WorkSpace):
- IsValidFileFlag = True
- else:
+ if not IsValidPath(FileName, WorkSpace):
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(FileName),
File=GlobalData.gINF_MODULE_NAME,
Line=LineNo,
ExtraData=OriginalString)
- return False
FileLinesList = []
- if IsValidFileFlag:
+ try:
+ FullFileName = FullFileName.replace('\\', '/')
+ Inputfile = open(FullFileName, "rb", 0)
try:
- FullFileName = FullFileName.replace('\\', '/')
- Inputfile = open(FullFileName, "rb", 0)
- try:
- FileLinesList = Inputfile.readlines()
- except BaseException:
- Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, ST.ERR_FILE_OPEN_FAILURE, File=FullFileName)
- finally:
- Inputfile.close()
+ FileLinesList = Inputfile.readlines()
except BaseException:
- Logger.Error("InfParser",
- ToolError.FILE_READ_FAILURE,
- ST.ERR_FILE_OPEN_FAILURE,
- File=FullFileName)
-
- FileLinesList = ProcessLineExtender(FileLinesList)
+ Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, ST.ERR_FILE_OPEN_FAILURE, File=FullFileName)
+ finally:
+ Inputfile.close()
+ except BaseException:
+ Logger.Error("InfParser",
+ ToolError.FILE_READ_FAILURE,
+ ST.ERR_FILE_OPEN_FAILURE,
+ File=FullFileName)
+
+ FileLinesList = ProcessLineExtender(FileLinesList)
return FileLinesList
-
\ No newline at end of file +
+##
+# Get all INF files from current workspace
+#
+#
+def GetInfsFromWorkSpace(WorkSpace):
+ InfFiles = []
+ for top, dirs, files in os.walk(WorkSpace):
+ dirs = dirs # just for pylint
+ for File in files:
+ if File.upper().endswith(".INF"):
+ InfFiles.append(os.path.join(top, File))
+
+ return InfFiles
+
+##
+# Get GUID and version from library instance file
+#
+#
+def GetGuidVerFormLibInstance(Guid, Version, WorkSpace, CurrentInfFileName):
+ for InfFile in GetInfsFromWorkSpace(WorkSpace):
+ try:
+ if InfFile.strip().upper() == CurrentInfFileName.strip().upper():
+ continue
+ InfFile = InfFile.replace('\\', '/')
+ if InfFile not in GlobalData.gLIBINSTANCEDICT:
+ InfFileObj = open(InfFile, "rb", 0)
+ GlobalData.gLIBINSTANCEDICT[InfFile] = InfFileObj
+ else:
+ InfFileObj = GlobalData.gLIBINSTANCEDICT[InfFile]
+
+ except BaseException:
+ Logger.Error("InfParser",
+ ToolError.FILE_READ_FAILURE,
+ ST.ERR_FILE_OPEN_FAILURE,
+ File=InfFile)
+ try:
+ FileLinesList = InfFileObj.readlines()
+ FileLinesList = ProcessLineExtender(FileLinesList)
+
+ ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
+ ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")
+
+ for Line in FileLinesList:
+ if ReFindFileGuidPattern.match(Line):
+ FileGuidString = Line
+ if ReFindVerStringPattern.match(Line):
+ VerString = Line
+
+ if FileGuidString:
+ FileGuidString = GetSplitValueList(FileGuidString, '=', 1)[1]
+ if VerString:
+ VerString = GetSplitValueList(VerString, '=', 1)[1]
+
+ if FileGuidString.strip().upper() == Guid.upper() and \
+ VerString.strip().upper() == Version.upper():
+ return Guid, Version
+
+ except BaseException:
+ Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, ST.ERR_FILE_OPEN_FAILURE, File=InfFile)
+ finally:
+ InfFileObj.close()
+
+ return '', ''
+
+
diff --git a/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py b/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py index 8f9427cf..4540fe27 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py @@ -170,28 +170,29 @@ class InfLibrarySectionParser(InfParserSectionRoot): File=FileName,
Line=LineNo,
ExtraData=LineContent)
-
+
if IsLibInstanceInfo(LineContent):
LibInsFlag = True
continue
-
+
if LibInsFlag:
- LibGuid, LibVer = GetLibInstanceInfo(LineContent, GlobalData.gWORKSPACE, LineNo)
+ LibGuid, LibVer = GetLibInstanceInfo(LineContent, GlobalData.gWORKSPACE, LineNo, FileName)
#
# If the VERSION_STRING is missing from the INF file, tool should default to "0".
#
if LibVer == '':
LibVer = '0'
if LibGuid != '':
- LibraryList.append((LibGuid, LibVer))
+ if (LibGuid, LibVer) not in LibraryList:
+ LibraryList.append((LibGuid, LibVer))
else:
- Logger.Error('InfParser',
+ Logger.Error('InfParser',
FORMAT_INVALID,
- ST.ERR_LIB_INSTANCE_MISS_GUID,
- File=FileName,
- Line=LineNo,
- ExtraData=LineContent)
-
+ ST.ERR_LIB_INSTANCE_MISS_GUID,
+ File=FileName,
+ Line=LineNo,
+ ExtraData=LineContent)
+
#
# Current section archs
#
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 92cf3614..b2e98633 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -286,15 +286,15 @@ class MetaFileParser(object): self._SectionName = ItemList[0].upper() if self._SectionName in self.DataType: self._SectionType = self.DataType[self._SectionName] - else: - self._SectionType = MODEL_UNKNOWN - EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item, - self.MetaFile, self._LineIndex + 1, self._CurrentLine) - - # Check if the section name is valid - if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH and len(ItemList) > 2: + # Check if the section name is valid + if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH and len(ItemList) > 2: + EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item, + self.MetaFile, self._LineIndex + 1, self._CurrentLine) + elif self._Version >= 0x00010005: EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item, self.MetaFile, self._LineIndex + 1, self._CurrentLine) + else: + self._SectionType = MODEL_UNKNOWN # S1 is always Arch if len(ItemList) > 1: diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index 34393515..f35b7699 100755 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -699,7 +699,8 @@ class PcdReport(object): # Collect PCDs defined in DSC common section # self.DscPcdDefault = {} - for Platform in Wa.BuildDatabase.WorkspaceDb.PlatformList: + for Arch in Wa.ArchList: + Platform = Wa.BuildDatabase[Wa.MetaFile, Arch, Wa.BuildTarget, Wa.ToolChain] for (TokenCName, TokenSpaceGuidCName) in Platform.Pcds: DscDefaultValue = Platform.Pcds[(TokenCName, TokenSpaceGuidCName)].DefaultValue if DscDefaultValue: |