X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FTrim%2FTrim.py;h=4b3091bec3df2372d4b6f3a46e4529f01e964784;hp=b46d507b4e55e503712ecf0a205cb3d940f206b4;hb=f7496d717357b9af78414d19679b073403812340;hpb=39456d00f36e04b7e7efb208f350f4e83b6c3531 diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py index b46d507b4e..4b3091bec3 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -31,7 +31,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open # Version and Copyright __version_number__ = ("0.10" + " " + gBUILD_VERSION) __version__ = "%prog Version " + __version_number__ -__copyright__ = "Copyright (c) 2007-2017, Intel Corporation. All rights reserved." +__copyright__ = "Copyright (c) 2007-2018, Intel Corporation. All rights reserved." ## Regular expression for matching Line Control directive like "#line xxx" gLineControlDirective = re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"') @@ -261,7 +261,7 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong): # def TrimPreprocessedVfr(Source, Target): CreateDirectory(os.path.dirname(Target)) - + try: f = open (Source, 'r') except: @@ -338,7 +338,7 @@ def DoInclude(Source, Indent='', IncludePathList=[], LocalSearchPath=None): SearchPathList = [LocalSearchPath] + IncludePathList else: SearchPathList = IncludePathList - + for IncludePath in SearchPathList: IncludeFile = os.path.join(IncludePath, Source) if os.path.isfile(IncludeFile): @@ -349,7 +349,7 @@ def DoInclude(Source, Indent='', IncludePathList=[], LocalSearchPath=None): except: EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=Source) - + # avoid A "include" B and B "include" A IncludeFile = os.path.abspath(os.path.normpath(IncludeFile)) if IncludeFile in gIncludedAslFile: @@ -357,7 +357,7 @@ def DoInclude(Source, Indent='', IncludePathList=[], LocalSearchPath=None): ExtraData= "%s -> %s" % (" -> ".join(gIncludedAslFile), IncludeFile)) return [] gIncludedAslFile.append(IncludeFile) - + for Line in F: LocalSearchPath = None Result = gAslIncludePattern.findall(Line) @@ -367,7 +367,7 @@ def DoInclude(Source, Indent='', IncludePathList=[], LocalSearchPath=None): NewFileContent.append("%s%s" % (Indent, Line)) continue # - # We should first search the local directory if current file are using pattern #include "XXX" + # We should first search the local directory if current file are using pattern #include "XXX" # if Result[0][2] == '"': LocalSearchPath = os.path.dirname(IncludeFile) @@ -388,20 +388,20 @@ def DoInclude(Source, Indent='', IncludePathList=[], LocalSearchPath=None): # # @param Source File to be trimmed # @param Target File to store the trimmed content -# @param IncludePathFile The file to log the external include path +# @param IncludePathFile The file to log the external include path # def TrimAslFile(Source, Target, IncludePathFile): CreateDirectory(os.path.dirname(Target)) - + SourceDir = os.path.dirname(Source) if SourceDir == '': SourceDir = '.' - + # # Add source directory as the first search directory # IncludePathList = [SourceDir] - + # # If additional include path file is specified, append them all # to the search directory list. @@ -672,7 +672,7 @@ def Main(): EdkLogger.SetLevel(CommandOptions.LogLevel) except FatalError as X: return 1 - + try: if CommandOptions.FileType == "Vfr": if CommandOptions.OutputFile is None: