From d40b2ee60ef161044bcaf05a8b36aa60eac633cc Mon Sep 17 00:00:00 2001 From: lgao4 Date: Wed, 9 Nov 2011 04:32:08 +0000 Subject: =?UTF-8?q?Sync=20BaseTool=20trunk=20(version=20r2397)=20into=20ED?= =?UTF-8?q?KII=20BaseTools.=20=20The=20change=20mainly=20includes=201.=20F?= =?UTF-8?q?ix=20the=20issue=20that=20root=20directory=20of=20disk=20can?= =?UTF-8?q?=E2=80=99t=20be=20used=20as=20WORKSPACE.=202.=20Update=20AutoGe?= =?UTF-8?q?n=20code=20style=20to=20pass=20C++=20compiler.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lgao4 Reviewed-by: jsu1 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12676 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Source/Python/Common/DecClassObjectLight.py | 106 ++++++++++----------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'BaseTools/Source/Python/Common/DecClassObjectLight.py') diff --git a/BaseTools/Source/Python/Common/DecClassObjectLight.py b/BaseTools/Source/Python/Common/DecClassObjectLight.py index cba88b64f2..7fb41a2359 100644 --- a/BaseTools/Source/Python/Common/DecClassObjectLight.py +++ b/BaseTools/Source/Python/Common/DecClassObjectLight.py @@ -75,7 +75,7 @@ class DecObject(object): # @var KeyList: To store value for KeyList, a list for all Keys used in Dec # class Dec(DecObject): - def __init__(self, Filename = None, IsToPackage = False, WorkspaceDir = None, AllGuidVersionDict = None, SupArchList = DataType.ARCH_LIST): + def __init__(self, Filename=None, IsToPackage=False, WorkspaceDir=None, AllGuidVersionDict=None, SupArchList=DataType.ARCH_LIST): self.Identification = IdentificationClass() self.Package = PackageClass() self.UserExtensions = '' @@ -92,23 +92,23 @@ class Dec(DecObject): ] # Upper all KEYs to ignore case sensitive when parsing self.KeyList = map(lambda c: c.upper(), self.KeyList) - + # Init RecordSet - self.RecordSet = {} + self.RecordSet = {} for Key in self.KeyList: self.RecordSet[Section[Key]] = [] - + # Init Comment self.SectionHeaderCommentDict = {} - + # Load Dec file if filename is not None if Filename != None: self.LoadDecFile(Filename) - + # Transfer to Package Object if IsToPackage is True if IsToPackage: self.DecToPackage() - + ## Load Dec file # # Load the file if it exists @@ -121,13 +121,13 @@ class Dec(DecObject): self.Identification.FullPath = Filename (self.Identification.RelaPath, self.Identification.FileName) = os.path.split(Filename) if self.Identification.FullPath.find(self.WorkspaceDir) > -1: - self.Identification.PackagePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:]) - + self.Identification.PackagePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:]) + # Init common datas IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \ [], [], TAB_UNKNOWN, [], [], [] LineNo = 0 - + # Parse file content IsFindBlockComment = False ReservedLine = '' @@ -136,7 +136,7 @@ class Dec(DecObject): LineNo = LineNo + 1 # Remove comment block if Line.find(TAB_COMMENT_EDK_START) > -1: - ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0] + ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0] if ReservedLine.strip().startswith(TAB_COMMENT_SPLIT): Comment = Comment + Line.strip() + '\n' ReservedLine = '' @@ -147,7 +147,7 @@ class Dec(DecObject): continue 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] + Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1] ReservedLine = '' IsFindBlockComment = False if IsFindBlockComment: @@ -160,7 +160,7 @@ class Dec(DecObject): Line = CleanString(Line) if Line == '': continue - + ## Find a new section tab # First insert previous section items # And then parse the content of the new section @@ -173,7 +173,7 @@ class Dec(DecObject): SectionItemList = [] ArchList = [] ThirdList = [] - + CurrentSection = '' LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT) for Item in LineList: @@ -182,7 +182,7 @@ class Dec(DecObject): CurrentSection = ItemList[0] else: if CurrentSection != ItemList[0]: - EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError) + EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) if CurrentSection.upper() not in self.KeyList: RaiseParserError(Line, CurrentSection, Filename, '', LineNo) ItemList.append('') @@ -191,28 +191,28 @@ class Dec(DecObject): RaiseParserError(Line, CurrentSection, Filename, '', LineNo) else: if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL: - EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError) + EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) ArchList.append(ItemList[1].upper()) ThirdList.append(ItemList[2]) - + if Comment: if Comment.endswith('\n'): Comment = Comment[:len(Comment) - len('\n')] self.SectionHeaderCommentDict[Section[CurrentSection.upper()]] = Comment Comment = '' continue - + # Not in any defined section if CurrentSection == TAB_UNKNOWN: ErrorMsg = "%s is not in any defined section" % Line - EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError) + EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) # Add a section item SectionItemList.append([Line, LineNo, Comment]) Comment = '' # End of parse #End of For - + # # Insert items data of last section # @@ -229,7 +229,7 @@ class Dec(DecObject): SectionHeaderCommentDict = {} if Package == None: return Dec - + PackageHeader = Package.PackageHeader TmpList = [] if PackageHeader.Name: @@ -243,30 +243,30 @@ class Dec(DecObject): if Package.UserExtensions != None: for Item in Package.UserExtensions.Defines: TmpList.append(Item) - DecList['Defines'] =TmpList + DecList['Defines'] = TmpList if PackageHeader.Description != '': SectionHeaderCommentDict['Defines'] = PackageHeader.Description - + for Item in Package.Includes: Key = 'Includes.' + Item.SupArchList Value = Item.FilePath GenMetaDatSectionItem(Key, Value, DecList) - + for Item in Package.GuidDeclarations: Key = 'Guids.' + Item.SupArchList Value = Item.CName + '=' + Item.Guid GenMetaDatSectionItem(Key, Value, DecList) - + for Item in Package.ProtocolDeclarations: Key = 'Protocols.' + Item.SupArchList Value = Item.CName + '=' + Item.Guid GenMetaDatSectionItem(Key, Value, DecList) - + for Item in Package.PpiDeclarations: Key = 'Ppis.' + Item.SupArchList Value = Item.CName + '=' + Item.Guid GenMetaDatSectionItem(Key, Value, DecList) - + for Item in Package.LibraryClassDeclarations: Key = 'LibraryClasses.' + Item.SupArchList Value = Item.LibraryClass + '|' + Item.RecommendedInstance @@ -297,7 +297,7 @@ class Dec(DecObject): else: Dec = Dec + ' ' + Value + '\n' Dec = Dec + '\n' - + return Dec ## Transfer to Package Object @@ -307,10 +307,10 @@ class Dec(DecObject): def DecToPackage(self): # Init global information for the file ContainerFile = self.Identification.FullPath - + # Generate Package Header self.GenPackageHeader(ContainerFile) - + # Generate Includes # Only for Edk self.GenIncludes(ContainerFile) @@ -323,16 +323,16 @@ class Dec(DecObject): # Generate Ppis self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile) - + # Generate LibraryClasses self.GenLibraryClasses(ContainerFile) - + # Generate Pcds self.GenPcds(ContainerFile) - + # Init MiscFiles self.GenMiscFiles(ContainerFile) - + ## GenMiscFiles # def GenMiscFiles(self, ContainerFile): @@ -343,7 +343,7 @@ class Dec(DecObject): File.Filename = Item MiscFiles.Files.append(File) self.Package.MiscFiles = MiscFiles - + ## Get Package Header # # Gen Package Header of Dec as = @@ -375,23 +375,23 @@ class Dec(DecObject): PackageHeader.DecSpecification = Value else: OtherDefines.append(Record[0]) - + PackageHeader.FileName = self.Identification.FileName PackageHeader.FullPath = self.Identification.FullPath PackageHeader.RelaPath = self.Identification.RelaPath PackageHeader.PackagePath = self.Identification.PackagePath PackageHeader.ModulePath = self.Identification.ModulePath PackageHeader.CombinePath = os.path.normpath(os.path.join(PackageHeader.PackagePath, PackageHeader.ModulePath, PackageHeader.FileName)) - + if MODEL_META_DATA_HEADER in self.SectionHeaderCommentDict: PackageHeader.Description = self.SectionHeaderCommentDict[MODEL_META_DATA_HEADER] - + self.Package.PackageHeader = PackageHeader UE = UserExtensionsClass() UE.Defines = OtherDefines self.Package.UserExtensions = UE - - + + ## GenIncludes # # Gen Includes of Dec @@ -403,7 +403,7 @@ class Dec(DecObject): Includes = {} # Get all Includes RecordSet = self.RecordSet[MODEL_EFI_INCLUDE] - + # Go through each arch for Record in RecordSet: Arch = Record[1] @@ -412,7 +412,7 @@ class Dec(DecObject): Include.FilePath = NormPath(Key) Include.SupArchList = Arch self.Package.Includes.append(Include) - + ## GenPpis # # Gen Ppis of Dec @@ -425,12 +425,12 @@ class Dec(DecObject): Lists = {} # Get all Items RecordSet = self.RecordSet[Section[Type.upper()]] - + # Go through each arch for Record in RecordSet: Arch = Record[1] (Name, Value) = GetGuidsProtocolsPpisOfDec(Record[0], Type, ContainerFile, Record[2]) - + ListMember = None if Type == TAB_GUIDS: ListMember = self.Package.GuidDeclarations @@ -438,13 +438,13 @@ class Dec(DecObject): ListMember = self.Package.ProtocolDeclarations elif Type == TAB_PPIS: ListMember = self.Package.PpiDeclarations - + ListClass = GuidProtocolPpiCommonClass() ListClass.CName = Name ListClass.Guid = Value ListClass.SupArchList = Arch ListMember.append(ListClass) - + ## GenLibraryClasses # # Gen LibraryClasses of Dec @@ -457,7 +457,7 @@ class Dec(DecObject): LibraryClasses = {} # Get all Guids RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS] - + # Go through each arch for Record in RecordSet: Arch = Record[1] @@ -469,7 +469,7 @@ class Dec(DecObject): LibraryClass.RecommendedInstance = NormPath(List[1]) LibraryClass.SupArchList = Arch self.Package.LibraryClassDeclarations.append(LibraryClass) - + def AddPcd(self, CName, Token, TokenSpaceGuidCName, DatumType, DefaultValue, ItemType, Arch): Pcd = CommonClass.PcdClass() Pcd.CName = CName @@ -480,7 +480,7 @@ class Dec(DecObject): Pcd.ItemType = ItemType Pcd.SupArchList = Arch self.Package.PcdDeclarations.append(Pcd) - + ## GenPcds # # Gen Pcds of Dec @@ -498,7 +498,7 @@ class Dec(DecObject): RecordSet3 = self.RecordSet[MODEL_PCD_FEATURE_FLAG] RecordSet4 = self.RecordSet[MODEL_PCD_DYNAMIC_EX] RecordSet5 = self.RecordSet[MODEL_PCD_DYNAMIC] - + # Go through each pcd for Record in RecordSet1: Arch = Record[1] @@ -520,7 +520,7 @@ class Dec(DecObject): Arch = Record[1] (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC, ContainerFile, Record[2]) self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch) - + ## Show detailed information of Package # # Print all members and their values of Package class @@ -533,7 +533,7 @@ class Dec(DecObject): print 'PackagePath =', M.PackageHeader.PackagePath print 'ModulePath =', M.PackageHeader.ModulePath print 'CombinePath =', M.PackageHeader.CombinePath - + print 'BaseName =', M.PackageHeader.Name print 'Guid =', M.PackageHeader.Guid print 'Version =', M.PackageHeader.Version @@ -571,7 +571,7 @@ class Dec(DecObject): if __name__ == '__main__': EdkLogger.Initialize() EdkLogger.SetLevel(EdkLogger.QUIET) - + W = os.getenv('WORKSPACE') F = os.path.join(W, 'MdeModulePkg/MdeModulePkg.dec') -- cgit v1.2.3