X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFdfParser.py;h=662c232c86e427f97a7be79284644547ab8c1e31;hb=cdc9b0c2966a8681a2b4e14c2cf75bf1e37815a1;hp=4183f318b75b9369e0c7743e58b44940ec5ab2e1;hpb=cfbe3c3500a64e218e7d357dacb18d8b95eddfec;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 4183f318b7..662c232c86 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -61,7 +61,6 @@ from Common.LongFilePathSupport import OpenLongFilePath as open from Capsule import EFI_CERT_TYPE_PKCS7_GUID from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID from Common.RangeExpression import RangeExpression -from Common.FdfParserLite import FileExtensionPattern,TokenFindPattern ##define T_CHAR_SPACE ' ' ##define T_CHAR_NULL '\0' @@ -85,6 +84,9 @@ RegionSizePattern = re.compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P\w+\.\w+)\s*\|\s*(?P\w+\.\w+)\s*") RegionOffsetPcdPattern = re.compile("\s*(?P\w+\.\w+)\s*$") ShortcutPcdPattern = re.compile("\s*\w+\s*=\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P\w+\.\w+)\s*") +BaseAddrValuePattern = re.compile('^0[xX][0-9a-fA-F]+') +FileExtensionPattern = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)') +TokenFindPattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)') AllIncludeFileList = [] @@ -275,21 +277,6 @@ class FdfParser: if GenFdsGlobalVariable.WorkSpaceDir == '': GenFdsGlobalVariable.WorkSpaceDir = os.getenv("WORKSPACE") - ## __IsWhiteSpace() method - # - # Whether char at current FileBufferPos is whitespace - # - # @param self The object pointer - # @param Char The char to test - # @retval True The char is a kind of white space - # @retval False The char is NOT a kind of white space - # - def __IsWhiteSpace(self, Char): - if Char in (T_CHAR_NULL, T_CHAR_CR, T_CHAR_SPACE, T_CHAR_TAB, T_CHAR_LF): - return True - else: - return False - ## __SkipWhiteSpace() method # # Skip white spaces from current char, return number of chars skipped @@ -719,7 +706,8 @@ class FdfParser: # Preprocess done. self.Rewind() - def __GetIfListCurrentItemStat(self, IfList): + @staticmethod + def __GetIfListCurrentItemStat(IfList): if len(IfList) == 0: return True @@ -2170,7 +2158,7 @@ class FdfParser: self.__GetAprioriSection(FvObj, FvObj.DefineVarDict.copy()) while True: - isInf = self.__GetInfStatement(FvObj, MacroDict = FvObj.DefineVarDict.copy()) + isInf = self.__GetInfStatement(FvObj) isFile = self.__GetFileStatement(FvObj, MacroDict = FvObj.DefineVarDict.copy()) if not isInf and not isFile: break @@ -2225,9 +2213,7 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected FV base address value", self.FileName, self.CurrentLineNumber) - IsValidBaseAddrValue = re.compile('^0[x|X][0-9a-fA-F]+') - - if not IsValidBaseAddrValue.match(self.__Token.upper()): + if not BaseAddrValuePattern.match(self.__Token.upper()): raise Warning("Unknown FV base address value '%s'" % self.__Token, self.FileName, self.CurrentLineNumber) Obj.FvBaseAddress = self.__Token return True @@ -2437,7 +2423,7 @@ class FdfParser: MacroDict.update(AprSectionObj.DefineVarDict) while True: - IsInf = self.__GetInfStatement( AprSectionObj, MacroDict = MacroDict) + IsInf = self.__GetInfStatement(AprSectionObj) IsFile = self.__GetFileStatement( AprSectionObj) if not IsInf and not IsFile: break @@ -2500,11 +2486,10 @@ class FdfParser: # # @param self The object pointer # @param Obj for whom inf statement is got - # @param MacroDict dictionary used to replace macro # @retval True Successfully find inf statement # @retval False Not able to find inf statement # - def __GetInfStatement(self, Obj, ForCapsule=False, MacroDict={}): + def __GetInfStatement(self, Obj, ForCapsule=False): ffsInf = self.__ParseInfStatement() if not ffsInf: return False @@ -2640,13 +2625,12 @@ class FdfParser: # # Check whether reloc strip flag can be set for a file type. # - # @param self The object pointer # @param FileType The file type to check with # @retval True This type could have relocation strip flag # @retval False No way to have it # - - def __FileCouldHaveRelocFlag (self, FileType): + @staticmethod + def __FileCouldHaveRelocFlag (FileType): if FileType in ('SEC', 'PEI_CORE', 'PEIM', 'PEI_DXE_COMBO'): return True else: @@ -2656,13 +2640,12 @@ class FdfParser: # # Check whether reloc strip flag can be set for a section type. # - # @param self The object pointer # @param SectionType The section type to check with # @retval True This type could have relocation strip flag # @retval False No way to have it # - - def __SectionCouldHaveRelocFlag (self, SectionType): + @staticmethod + def __SectionCouldHaveRelocFlag (SectionType): if SectionType in ('TE', 'PE32'): return True else: @@ -2942,7 +2925,7 @@ class FdfParser: self.__GetAprioriSection(FvObj, MacroDict.copy()) while True: - IsInf = self.__GetInfStatement(FvObj, MacroDict.copy()) + IsInf = self.__GetInfStatement(FvObj) IsFile = self.__GetFileStatement(FvObj, MacroDict.copy()) if not IsInf and not IsFile: break @@ -4001,12 +3984,12 @@ class FdfParser: # # Get whether a section could be optional # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could be optional # @retval False section never optional # - def __RuleSectionCouldBeOptional(self, SectionType): + @staticmethod + def __RuleSectionCouldBeOptional(SectionType): if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW", "SMM_DEPEX"): return True else: @@ -4016,12 +3999,12 @@ class FdfParser: # # Get whether a section could have build number information # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could have build number information # @retval False section never have build number information # - def __RuleSectionCouldHaveBuildNum(self, SectionType): + @staticmethod + def __RuleSectionCouldHaveBuildNum(SectionType): if SectionType in ("VERSION"): return True else: @@ -4031,12 +4014,12 @@ class FdfParser: # # Get whether a section could have string # - # @param self The object pointer # @param SectionType The section type to check # @retval True section could have string # @retval False section never have string # - def __RuleSectionCouldHaveString(self, SectionType): + @staticmethod + def __RuleSectionCouldHaveString(SectionType): if SectionType in ("UI", "VERSION"): return True else: