From b36d134faf4305247830522b8e2bb255e98c5699 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Sun, 18 Sep 2011 12:17:25 +0000 Subject: Sync BaseTools Branch (version r2321) to EDKII main trunk. Signed-off-by: lgao4 Reviewed-by: gikidy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12372 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/Common/BuildVersion.py | 3 ++ BaseTools/Source/Python/Common/DataType.py | 11 +++--- BaseTools/Source/Python/Common/DecClassObject.py | 8 ++-- .../Source/Python/Common/DecClassObjectLight.py | 12 +++--- BaseTools/Source/Python/Common/DscClassObject.py | 8 ++-- .../Source/Python/Common/EdkIIWorkspaceBuild.py | 6 +-- BaseTools/Source/Python/Common/FdfParserLite.py | 9 ++++- BaseTools/Source/Python/Common/GlobalData.py | 1 - BaseTools/Source/Python/Common/InfClassObject.py | 20 +++++----- .../Source/Python/Common/InfClassObjectLight.py | 12 +++--- BaseTools/Source/Python/Common/Misc.py | 8 ++-- BaseTools/Source/Python/Common/String.py | 43 ++++++++++++++++------ 12 files changed, 85 insertions(+), 56 deletions(-) create mode 100644 BaseTools/Source/Python/Common/BuildVersion.py (limited to 'BaseTools/Source/Python/Common') diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py new file mode 100644 index 0000000000..7425810fe3 --- /dev/null +++ b/BaseTools/Source/Python/Common/BuildVersion.py @@ -0,0 +1,3 @@ +#This file is for build version number auto generation +# +gBUILD_VERSION = "Build 2318" diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 151f7bb1f3..9a2556749a 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -14,9 +14,9 @@ # Common Definitions # TAB_SPLIT = '.' -TAB_COMMENT_R8_START = '/*' -TAB_COMMENT_R8_END = '*/' -TAB_COMMENT_R8_SPLIT = '//' +TAB_COMMENT_EDK_START = '/*' +TAB_COMMENT_EDK_END = '*/' +TAB_COMMENT_EDK_SPLIT = '//' TAB_COMMENT_SPLIT = '#' TAB_EQUAL_SPLIT = '=' TAB_VALUE_SPLIT = '|' @@ -302,16 +302,17 @@ TAB_INF_DEFINES_BINARY_MODULE = 'BINARY_MODULE' TAB_INF_DEFINES_LIBRARY_CLASS = 'LIBRARY_CLASS' TAB_INF_DEFINES_COMPONENT_TYPE = 'COMPONENT_TYPE' TAB_INF_DEFINES_MAKEFILE_NAME = 'MAKEFILE_NAME' +TAB_INF_DEFINES_DPX_SOURCE = 'DPX_SOURCE' TAB_INF_DEFINES_BUILD_NUMBER = 'BUILD_NUMBER' TAB_INF_DEFINES_BUILD_TYPE = 'BUILD_TYPE' TAB_INF_DEFINES_FFS_EXT = 'FFS_EXT' TAB_INF_DEFINES_FV_EXT = 'FV_EXT' TAB_INF_DEFINES_SOURCE_FV = 'SOURCE_FV' TAB_INF_DEFINES_VERSION_NUMBER = 'VERSION_NUMBER' -TAB_INF_DEFINES_VERSION = 'VERSION' # for R8 inf, the same as VERSION_NUMBER +TAB_INF_DEFINES_VERSION = 'VERSION' # for Edk inf, the same as VERSION_NUMBER TAB_INF_DEFINES_VERSION_STRING = 'VERSION_STRING' TAB_INF_DEFINES_PCD_IS_DRIVER = 'PCD_IS_DRIVER' -TAB_INF_DEFINES_TIANO_R8_FLASHMAP_H = 'TIANO_R8_FLASHMAP_H' +TAB_INF_DEFINES_TIANO_EDK_FLASHMAP_H = 'TIANO_EDK_FLASHMAP_H' TAB_INF_DEFINES_ENTRY_POINT = 'ENTRY_POINT' TAB_INF_DEFINES_UNLOAD_IMAGE = 'UNLOAD_IMAGE' TAB_INF_DEFINES_CONSTRUCTOR = 'CONSTRUCTOR' diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/Source/Python/Common/DecClassObject.py index ffa485979d..18816806f2 100644 --- a/BaseTools/Source/Python/Common/DecClassObject.py +++ b/BaseTools/Source/Python/Common/DecClassObject.py @@ -162,11 +162,11 @@ class Dec(DecObject): # # Remove comment block # - if Line.find(TAB_COMMENT_R8_START) > -1: - ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0] + if Line.find(TAB_COMMENT_EDK_START) > -1: + ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0] IsFindBlockComment = True - if Line.find(TAB_COMMENT_R8_END) > -1: - Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1] + if Line.find(TAB_COMMENT_EDK_END) > -1: + Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1] ReservedLine = '' IsFindBlockComment = False if IsFindBlockComment: diff --git a/BaseTools/Source/Python/Common/DecClassObjectLight.py b/BaseTools/Source/Python/Common/DecClassObjectLight.py index 1982dd05a0..cba88b64f2 100644 --- a/BaseTools/Source/Python/Common/DecClassObjectLight.py +++ b/BaseTools/Source/Python/Common/DecClassObjectLight.py @@ -135,8 +135,8 @@ class Dec(DecObject): for Line in open(Filename, 'r'): LineNo = LineNo + 1 # Remove comment block - if Line.find(TAB_COMMENT_R8_START) > -1: - ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0] + if Line.find(TAB_COMMENT_EDK_START) > -1: + ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0] if ReservedLine.strip().startswith(TAB_COMMENT_SPLIT): Comment = Comment + Line.strip() + '\n' ReservedLine = '' @@ -145,9 +145,9 @@ class Dec(DecObject): IsFindBlockComment = True if not ReservedLine: continue - if Line.find(TAB_COMMENT_R8_END) > -1: - Comment = Comment + Line[:Line.find(TAB_COMMENT_R8_END) + len(TAB_COMMENT_R8_END)] + '\n' - Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1] + if Line.find(TAB_COMMENT_EDK_END) > -1: + Comment = Comment + Line[:Line.find(TAB_COMMENT_EDK_END) + len(TAB_COMMENT_EDK_END)] + '\n' + Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1] ReservedLine = '' IsFindBlockComment = False if IsFindBlockComment: @@ -312,7 +312,7 @@ class Dec(DecObject): self.GenPackageHeader(ContainerFile) # Generate Includes - # Only for R8 + # Only for Edk self.GenIncludes(ContainerFile) # Generate Guids diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py index 943bc6948e..428f1686b6 100644 --- a/BaseTools/Source/Python/Common/DscClassObject.py +++ b/BaseTools/Source/Python/Common/DscClassObject.py @@ -1045,11 +1045,11 @@ class Dsc(DscObject): # # Remove comment block # - if Line.find(TAB_COMMENT_R8_START) > -1: - ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0] + if Line.find(TAB_COMMENT_EDK_START) > -1: + ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0] IsFindBlockComment = True - if Line.find(TAB_COMMENT_R8_END) > -1: - Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1] + if Line.find(TAB_COMMENT_EDK_END) > -1: + Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1] ReservedLine = '' IsFindBlockComment = False if IsFindBlockComment: diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py index 69a67eda39..26a9b324e6 100644 --- a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py +++ b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py @@ -929,13 +929,13 @@ class WorkspaceBuild(object): ModuleDatabase = self.Build[Arch].ModuleDatabase ModuleType = Module.ModuleType - # check R8 module + # check Edk module if Module.AutoGenVersion < 0x00010005: EdkLogger.verbose("") EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), Arch)) LibraryConsumerList = [Module] - # "CompilerStub" is a must for R8 modules + # "CompilerStub" is a must for Edk modules Module.Libraries.append("CompilerStub") while len(LibraryConsumerList) > 0: M = LibraryConsumerList.pop() @@ -952,7 +952,7 @@ class WorkspaceBuild(object): EdkLogger.verbose("\t" + LibraryName + " : " + LibraryFile) return - # R9 module + # EdkII module LibraryConsumerList = [Module] Constructor = [] ConsumedByList = sdict() diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py index 5d0fd7f67b..87595df1e7 100644 --- a/BaseTools/Source/Python/Common/FdfParserLite.py +++ b/BaseTools/Source/Python/Common/FdfParserLite.py @@ -3647,7 +3647,14 @@ class FdfParser(object): return CycleRefExists if __name__ == "__main__": - parser = FdfParser("..\LakeportX64Pkg.fdf") + import sys + try: + test_file = sys.argv[1] + except IndexError, v: + print "Usage: %s filename" % sys.argv[0] + sys.exit(1) + + parser = FdfParser(test_file) try: parser.ParseFile() parser.CycleReferenceCheck() diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py index 6c7f085810..ec6456faac 100644 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -34,4 +34,3 @@ gBuildingModule = '' ## Regular expression for matching macro used in DSC/DEC/INF file inclusion gMacroPattern = re.compile("\$\(([_A-Z][_A-Z0-9]*)\)", re.UNICODE) - diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/Source/Python/Common/InfClassObject.py index e774d80d69..0f2b5ca47d 100644 --- a/BaseTools/Source/Python/Common/InfClassObject.py +++ b/BaseTools/Source/Python/Common/InfClassObject.py @@ -104,7 +104,7 @@ class InfHeader(ModuleHeaderClass): TAB_INF_DEFINES_VERSION_STRING : "VersionString", TAB_INF_DEFINES_VERSION : "Version", TAB_INF_DEFINES_PCD_IS_DRIVER : "PcdIsDriver", - TAB_INF_DEFINES_TIANO_R8_FLASHMAP_H : "TianoR8FlashMap_h", + TAB_INF_DEFINES_TIANO_EDK_FLASHMAP_H : "TianoEdkFlashMap_h", TAB_INF_DEFINES_SHADOW : "Shadow", # TAB_INF_DEFINES_LIBRARY_CLASS : "LibraryClass", # TAB_INF_DEFINES_ENTRY_POINT : "ExternImages", @@ -352,11 +352,11 @@ class Inf(InfObject): # # Remove comment block # - if Line.find(TAB_COMMENT_R8_START) > -1: - ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0] + if Line.find(TAB_COMMENT_EDK_START) > -1: + ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0] IsFindBlockComment = True - if Line.find(TAB_COMMENT_R8_END) > -1: - Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1] + if Line.find(TAB_COMMENT_EDK_END) > -1: + Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1] ReservedLine = '' IsFindBlockComment = False if IsFindBlockComment: @@ -465,7 +465,7 @@ class Inf(InfObject): print 'FvExt =', M.Header[Arch].FvExt print 'SourceFv =', M.Header[Arch].SourceFv print 'PcdIsDriver =', M.Header[Arch].PcdIsDriver - print 'TianoR8FlashMap_h =', M.Header[Arch].TianoR8FlashMap_h + print 'TianoEdkFlashMap_h =', M.Header[Arch].TianoEdkFlashMap_h print 'Shadow =', M.Header[Arch].Shadow print 'LibraryClass =', M.Header[Arch].LibraryClass for Item in M.Header[Arch].LibraryClass: @@ -613,7 +613,7 @@ class Inf(InfObject): # Get version of INF # if ModuleHeader.InfVersion != "": - # R9 inf + # EdkII inf VersionNumber = ModuleHeader.VersionNumber VersionString = ModuleHeader.VersionString if len(VersionNumber) > 0 and len(VersionString) == 0: @@ -624,12 +624,12 @@ class Inf(InfObject): EdkLogger.warn(2001, 'INF file %s defines both VERSION_NUMBER and VERSION_STRING, using VERSION_STRING' % self.Identification.FileFullPath) ModuleHeader.Version = VersionString else: - # R8 inf + # Edk inf ModuleHeader.InfVersion = "0x00010000" if ModuleHeader.ComponentType in gComponentType2ModuleType: ModuleHeader.ModuleType = gComponentType2ModuleType[ModuleHeader.ComponentType] elif ModuleHeader.ComponentType != '': - EdkLogger.error("Parser", PARSER_ERROR, "Unsupported R8 component type [%s]" % ModuleHeader.ComponentType, ExtraData=File, RaiseError = EdkLogger.IsRaiseError) + EdkLogger.error("Parser", PARSER_ERROR, "Unsupported Edk component type [%s]" % ModuleHeader.ComponentType, ExtraData=File, RaiseError = EdkLogger.IsRaiseError) self.Module.Header[Arch] = ModuleHeader @@ -841,7 +841,7 @@ class Inf(InfObject): Nmake.SupArchList = Nmakes[Key] self.Module.Nmake.append(Nmake) - # convert R8 format to R9 format + # convert Edk format to EdkII format if Nmake.Name == "IMAGE_ENTRY_POINT": Image = ModuleExternImageClass() Image.ModuleEntryPoint = Nmake.Value diff --git a/BaseTools/Source/Python/Common/InfClassObjectLight.py b/BaseTools/Source/Python/Common/InfClassObjectLight.py index 020addfdb7..067bf71008 100644 --- a/BaseTools/Source/Python/Common/InfClassObjectLight.py +++ b/BaseTools/Source/Python/Common/InfClassObjectLight.py @@ -89,7 +89,7 @@ class InfHeader(ModuleHeaderClass): TAB_INF_DEFINES_VERSION_STRING : "VersionString", TAB_INF_DEFINES_VERSION : "Version", TAB_INF_DEFINES_PCD_IS_DRIVER : "PcdIsDriver", - TAB_INF_DEFINES_TIANO_R8_FLASHMAP_H : "TianoR8FlashMap_h", + TAB_INF_DEFINES_TIANO_EDK_FLASHMAP_H : "TianoEdkFlashMap_h", TAB_INF_DEFINES_SHADOW : "Shadow", } @@ -411,8 +411,8 @@ class Inf(InfObject): for Line in open(Filename, 'r'): LineNo = LineNo + 1 # Remove comment block - if Line.find(TAB_COMMENT_R8_START) > -1: - ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0] + if Line.find(TAB_COMMENT_EDK_START) > -1: + ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0] if ReservedLine.strip().startswith(TAB_COMMENT_SPLIT): Comment = Comment + Line.strip() + '\n' ReservedLine = '' @@ -421,9 +421,9 @@ class Inf(InfObject): IsFindBlockComment = True if not ReservedLine: continue - if Line.find(TAB_COMMENT_R8_END) > -1: - Comment = Comment + Line[:Line.find(TAB_COMMENT_R8_END) + len(TAB_COMMENT_R8_END)] + '\n' - Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1] + if Line.find(TAB_COMMENT_EDK_END) > -1: + Comment = Comment + Line[:Line.find(TAB_COMMENT_EDK_END) + len(TAB_COMMENT_EDK_END)] + '\n' + Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1] ReservedLine = '' IsFindBlockComment = False if IsFindBlockComment: diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 0540636988..d6a796bd2b 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -468,7 +468,7 @@ def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource=' if FileExt.lower() != Ext.lower(): return False, File - # Replace the R8 macros + # Replace the Edk macros if OverrideDir != '' and OverrideDir != None: if OverrideDir.find('$(EFI_SOURCE)') > -1: OverrideDir = OverrideDir.replace('$(EFI_SOURCE)', EfiSource) @@ -480,7 +480,7 @@ def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource=' Dir = os.getcwd() Dir = Dir[len(Workspace)+1:] - # First check if File has R8 definition itself + # First check if File has Edk definition itself if File.find('$(EFI_SOURCE)') > -1 or File.find('$(EDK_SOURCE)') > -1: NewFile = File.replace('$(EFI_SOURCE)', EfiSource) NewFile = NewFile.replace('$(EDK_SOURCE)', EdkSource) @@ -506,7 +506,7 @@ def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource=' # # def ValidFile3(AllFiles, File, Workspace='', EfiSource='', EdkSource='', Dir='.', OverrideDir=''): - # Replace the R8 macros + # Replace the Edk macros if OverrideDir != '' and OverrideDir != None: if OverrideDir.find('$(EFI_SOURCE)') > -1: OverrideDir = OverrideDir.replace('$(EFI_SOURCE)', EfiSource) @@ -524,7 +524,7 @@ def ValidFile3(AllFiles, File, Workspace='', EfiSource='', EdkSource='', Dir='.' NewRelaPath = RelaPath while(True): - # First check if File has R8 definition itself + # First check if File has Edk definition itself if File.find('$(EFI_SOURCE)') > -1 or File.find('$(EDK_SOURCE)') > -1: File = File.replace('$(EFI_SOURCE)', EfiSource) File = File.replace('$(EDK_SOURCE)', EdkSource) diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py index 195fa5c6ca..4880768866 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -20,7 +20,7 @@ import os.path import string import EdkLogger as EdkLogger -from GlobalData import * +import GlobalData from BuildToolError import * gHexVerPatt = re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$',re.IGNORECASE) @@ -213,7 +213,7 @@ def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement = False): def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement = False): LastString = String while MacroDefinitions: - MacroUsed = gMacroPattern.findall(String) + MacroUsed = GlobalData.gMacroPattern.findall(String) # no macro found in String, stop replacing if len(MacroUsed) == 0: break @@ -277,21 +277,40 @@ def CleanString(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT, AllowCppSty # Line = Line.strip(); # - # Replace R8's comment character + # Replace Edk's comment character # if AllowCppStyleComment: - Line = Line.replace(DataType.TAB_COMMENT_R8_SPLIT, CommentCharacter) + Line = Line.replace(DataType.TAB_COMMENT_EDK_SPLIT, CommentCharacter) # # remove comments, but we should escape comment character in string # InString = False + CommentInString = False for Index in range(0, len(Line)): if Line[Index] == '"': InString = not InString - elif Line[Index] == CommentCharacter and not InString: + elif Line[Index] == CommentCharacter and InString : + CommentInString = True + elif Line[Index] == CommentCharacter and not InString : Line = Line[0: Index] break - + + if CommentInString: + Line = Line.replace('"', '') + ChIndex = Line.find('#') + while ChIndex >= 0: + if GlobalData.gIsWindows: + if ChIndex == 0 or Line[ChIndex-1] != '^': + Line = Line[0:ChIndex] + '^' + Line[ChIndex:] + ChIndex = Line.find('#', ChIndex + 2) + else: + ChIndex = Line.find('#', ChIndex + 1) + else: + if ChIndex == 0 or Line[ChIndex-1] != '\\': + Line = Line[0:ChIndex] + '\\' + Line[ChIndex:] + ChIndex = Line.find('#', ChIndex + 2) + else: + ChIndex = Line.find('#', ChIndex + 1) # # remove whitespace again # @@ -315,10 +334,10 @@ def CleanString2(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT, AllowCppSt # Line = Line.strip(); # - # Replace R8's comment character + # Replace Edk's comment character # if AllowCppStyleComment: - Line = Line.replace(DataType.TAB_COMMENT_R8_SPLIT, CommentCharacter) + Line = Line.replace(DataType.TAB_COMMENT_EDK_SPLIT, CommentCharacter) # # separate comments and statements # @@ -689,11 +708,11 @@ def RemoveBlockComment(Lines): # # Remove comment block # - if Line.find(DataType.TAB_COMMENT_R8_START) > -1: - ReservedLine = GetSplitValueList(Line, DataType.TAB_COMMENT_R8_START, 1)[0] + if Line.find(DataType.TAB_COMMENT_EDK_START) > -1: + ReservedLine = GetSplitValueList(Line, DataType.TAB_COMMENT_EDK_START, 1)[0] IsFindBlockComment = True - if Line.find(DataType.TAB_COMMENT_R8_END) > -1: - Line = ReservedLine + GetSplitValueList(Line, DataType.TAB_COMMENT_R8_END, 1)[1] + if Line.find(DataType.TAB_COMMENT_EDK_END) > -1: + Line = ReservedLine + GetSplitValueList(Line, DataType.TAB_COMMENT_EDK_END, 1)[1] ReservedLine = '' IsFindBlockComment = False if IsFindBlockComment: -- cgit v1.2.3