From 4afd3d042215afe68d00b9ab8c32f063a3a1c03f Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Fri, 23 Aug 2013 02:18:16 +0000 Subject: Sync BaseTool trunk (version r2599) into EDKII BaseTools. Signed-off-by: Liming Gao Reviewed-by: Heshen Chen git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14591 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/UPT/BuildVersion.py | 2 +- BaseTools/Source/Python/UPT/Library/DataType.py | 23 +++- BaseTools/Source/Python/UPT/Library/GlobalData.py | 5 + BaseTools/Source/Python/UPT/Library/String.py | 4 +- .../UPT/Object/Parser/InfUserExtensionObject.py | 26 ++-- .../Source/Python/UPT/Parser/InfAsBuiltProcess.py | 143 ++++++++++++++++----- .../Python/UPT/Parser/InfLibrarySectionParser.py | 21 +-- 7 files changed, 166 insertions(+), 58 deletions(-) (limited to 'BaseTools/Source/Python/UPT') diff --git a/BaseTools/Source/Python/UPT/BuildVersion.py b/BaseTools/Source/Python/UPT/BuildVersion.py index e2dca6130f..edd4696753 100644 --- a/BaseTools/Source/Python/UPT/BuildVersion.py +++ b/BaseTools/Source/Python/UPT/BuildVersion.py @@ -17,4 +17,4 @@ Build version information ''' -gBUILD_VERSION = "Build 2524" +gBUILD_VERSION = "" diff --git a/BaseTools/Source/Python/UPT/Library/DataType.py b/BaseTools/Source/Python/UPT/Library/DataType.py index da6b69d82b..de3c7092ad 100644 --- a/BaseTools/Source/Python/UPT/Library/DataType.py +++ b/BaseTools/Source/Python/UPT/Library/DataType.py @@ -353,9 +353,10 @@ TAB_ARCH_X64 = 'X64' TAB_ARCH_IPF = 'IPF' TAB_ARCH_ARM = 'ARM' TAB_ARCH_EBC = 'EBC' +TAB_ARCH_AARCH64 = 'AARCH64' ARCH_LIST = \ -[TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC] +[TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64] SUP_MODULE_BASE = 'BASE' SUP_MODULE_SEC = 'SEC' @@ -440,6 +441,7 @@ TAB_SOURCES_X64 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_X64 TAB_SOURCES_IPF = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_IPF TAB_SOURCES_ARM = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_ARM TAB_SOURCES_EBC = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_EBC +TAB_SOURCES_AARCH64 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_BINARIES = 'Binaries' TAB_BINARIES_COMMON = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_COMMON @@ -448,6 +450,7 @@ TAB_BINARIES_X64 = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_X64 TAB_BINARIES_IPF = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_IPF TAB_BINARIES_ARM = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_ARM TAB_BINARIES_EBC = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_EBC +TAB_BINARIES_AARCH64 = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_INCLUDES = 'Includes' TAB_INCLUDES_COMMON = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_COMMON @@ -456,6 +459,7 @@ TAB_INCLUDES_X64 = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_X64 TAB_INCLUDES_IPF = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_IPF TAB_INCLUDES_ARM = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_ARM TAB_INCLUDES_EBC = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_EBC +TAB_INCLUDES_AARCH64 = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_GUIDS = 'Guids' TAB_GUIDS_COMMON = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_COMMON @@ -464,6 +468,7 @@ TAB_GUIDS_X64 = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_X64 TAB_GUIDS_IPF = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_IPF TAB_GUIDS_ARM = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_ARM TAB_GUIDS_EBC = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_EBC +TAB_GUIDS_AARCH64 = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PROTOCOLS = 'Protocols' TAB_PROTOCOLS_COMMON = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_COMMON @@ -472,6 +477,7 @@ TAB_PROTOCOLS_X64 = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_X64 TAB_PROTOCOLS_IPF = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_IPF TAB_PROTOCOLS_ARM = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_ARM TAB_PROTOCOLS_EBC = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_EBC +TAB_PROTOCOLS_AARCH64 = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PPIS = 'Ppis' TAB_PPIS_COMMON = TAB_PPIS + TAB_SPLIT + TAB_ARCH_COMMON @@ -480,6 +486,7 @@ TAB_PPIS_X64 = TAB_PPIS + TAB_SPLIT + TAB_ARCH_X64 TAB_PPIS_IPF = TAB_PPIS + TAB_SPLIT + TAB_ARCH_IPF TAB_PPIS_ARM = TAB_PPIS + TAB_SPLIT + TAB_ARCH_ARM TAB_PPIS_EBC = TAB_PPIS + TAB_SPLIT + TAB_ARCH_EBC +TAB_PPIS_AARCH64 = TAB_PPIS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_LIBRARY_CLASSES = 'LibraryClasses' TAB_LIBRARY_CLASSES_COMMON = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_COMMON @@ -488,6 +495,7 @@ TAB_LIBRARY_CLASSES_X64 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_X64 TAB_LIBRARY_CLASSES_IPF = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_IPF TAB_LIBRARY_CLASSES_ARM = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_ARM TAB_LIBRARY_CLASSES_EBC = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_EBC +TAB_LIBRARY_CLASSES_AARCH64 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PACKAGES = 'Packages' TAB_PACKAGES_COMMON = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_COMMON @@ -496,6 +504,7 @@ TAB_PACKAGES_X64 = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_X64 TAB_PACKAGES_IPF = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_IPF TAB_PACKAGES_ARM = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_ARM TAB_PACKAGES_EBC = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_EBC +TAB_PACKAGES_AARCH64 = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS = 'Pcds' TAB_PCDS_FIXED_AT_BUILD = 'FixedAtBuild' @@ -535,6 +544,8 @@ TAB_PCDS_FIXED_AT_BUILD_ARM = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_FIXED_AT_BUILD_EBC = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_FIXED_AT_BUILD_AARCH64 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ +TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS_PATCHABLE_IN_MODULE_NULL = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE TAB_PCDS_PATCHABLE_IN_MODULE_COMMON = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE \ @@ -549,6 +560,8 @@ TAB_PCDS_PATCHABLE_IN_MODULE_ARM = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + \ TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_PATCHABLE_IN_MODULE_EBC = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + \ TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_PATCHABLE_IN_MODULE_AARCH64 = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + \ +TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS_FEATURE_FLAG_NULL = TAB_PCDS + TAB_PCDS_FEATURE_FLAG TAB_PCDS_FEATURE_FLAG_COMMON = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT \ @@ -563,6 +576,8 @@ TAB_PCDS_FEATURE_FLAG_ARM = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + \ TAB_ARCH_ARM TAB_PCDS_FEATURE_FLAG_EBC = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + \ TAB_ARCH_EBC +TAB_PCDS_FEATURE_FLAG_AARCH64 = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + \ +TAB_ARCH_AARCH64 TAB_PCDS_DYNAMIC_EX_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_EX TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_EX_DEFAULT @@ -580,6 +595,8 @@ TAB_PCDS_DYNAMIC_EX_ARM = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ TAB_ARCH_ARM TAB_PCDS_DYNAMIC_EX_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ TAB_ARCH_EBC +TAB_PCDS_DYNAMIC_EX_AARCH64 = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ +TAB_ARCH_AARCH64 TAB_PCDS_DYNAMIC_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC TAB_PCDS_DYNAMIC_DEFAULT_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_DEFAULT @@ -592,6 +609,7 @@ TAB_PCDS_DYNAMIC_X64 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_X64 TAB_PCDS_DYNAMIC_IPF = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_DYNAMIC_ARM = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_DYNAMIC_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_DYNAMIC_AARCH64 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCD_DYNAMIC_TYPE_LIST = [TAB_PCDS_DYNAMIC_DEFAULT_NULL, \ TAB_PCDS_DYNAMIC_VPD_NULL, \ @@ -632,6 +650,7 @@ TAB_DEPEX_X64 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_X64 TAB_DEPEX_IPF = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_IPF TAB_DEPEX_ARM = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_ARM TAB_DEPEX_EBC = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_EBC +TAB_DEPEX_AARCH64 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_SKUIDS = 'SkuIds' @@ -642,6 +661,7 @@ TAB_LIBRARIES_X64 = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_X64 TAB_LIBRARIES_IPF = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_IPF TAB_LIBRARIES_ARM = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_ARM TAB_LIBRARIES_EBC = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_EBC +TAB_LIBRARIES_AARCH64 = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_COMPONENTS = 'Components' TAB_COMPONENTS_COMMON = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_COMMON @@ -650,6 +670,7 @@ TAB_COMPONENTS_X64 = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_X64 TAB_COMPONENTS_IPF = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_IPF TAB_COMPONENTS_ARM = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_ARM TAB_COMPONENTS_EBC = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_EBC +TAB_COMPONENTS_AARCH64 = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_COMPONENTS_SOURCE_OVERRIDE_PATH = 'SOURCE_OVERRIDE_PATH' diff --git a/BaseTools/Source/Python/UPT/Library/GlobalData.py b/BaseTools/Source/Python/UPT/Library/GlobalData.py index fedd981529..3f72f22738 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/Library/String.py b/BaseTools/Source/Python/UPT/Library/String.py index 2c5853ca93..0953e47cb1 100644 --- a/BaseTools/Source/Python/UPT/Library/String.py +++ b/BaseTools/Source/Python/UPT/Library/String.py @@ -2,7 +2,7 @@ # This file is used to define common string related functions used in parsing # process # -# Copyright (c) 2011, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.
# # This program and the accompanying materials are licensed and made available # under the terms and conditions of the BSD License which accompanies this @@ -737,7 +737,7 @@ def IsHexDigit(Str): return False return False -## Check if the string is HexDgit and its interger value within limit of UINT32 +## Check if the string is HexDgit and its integer value within limit of UINT32 # # Return true if all characters in the string are digits and there is at # least one character diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py index d576cffbd0..27a1c6ad25 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 12c46f1954..6bf070be41 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 8f9427cf4f..4540fe2754 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 # -- cgit v1.2.3