def GenGuidSections(GuidObjList): # # generate [Guids] section # Content = '' GuidDict = Sdict() for Guid in GuidObjList: HelpTextList = Guid.GetHelpTextList() HelpStr = _GetHelpStr(HelpTextList) CName = Guid.GetCName() FFE = Guid.GetFeatureFlag() Statement = CName if FFE: Statement += '|' + FFE Usage = Guid.GetUsage() GuidType = Guid.GetGuidTypeList()[0] VariableName = Guid.GetVariableName() # # Differentiate the generic comment and usage comment as multiple generic comment need to be put at first # if Usage == DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED: # generate list of generic comment Comment = GenGenericCommentF(HelpStr) else: # generate list of other comment Comment = HelpStr.replace('\n', ' ') Comment = Comment.strip() if Comment: Comment = ' # ' + Comment else: Comment = '' if Usage != DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED: Comment = '## ' + Usage + Comment elif GuidType == 'Variable': Comment = '## ' + Usage + ' ## ' + GuidType + ':' + VariableName + Comment else: Comment = '## ' + Usage + ' ## ' + GuidType + Comment if Comment: Comment += '\n' # # merge duplicate items # ArchList = sorted(Guid.GetSupArchList()) SortedArch = ' '.join(ArchList) if (Statement, SortedArch) in GuidDict: PreviousComment = GuidDict[Statement, SortedArch] Comment = PreviousComment + Comment GuidDict[Statement, SortedArch] = Comment NewSectionDict = GenMetaFileMisc.TransferDict(GuidDict, 'INF_GUID') # # generate the section contents # if NewSectionDict: Content = GenSection('Guids', NewSectionDict) return Content
def GenProtocolPPiSections(ObjList, IsProtocol): Content = '' Dict = Sdict() for Object in ObjList: HelpTextList = Object.GetHelpTextList() HelpStr = _GetHelpStr(HelpTextList) CName = Object.GetCName() FFE = Object.GetFeatureFlag() Statement = CName if FFE: Statement += '|' + FFE Usage = Object.GetUsage() Notify = Object.GetNotify() # # Differentiate the generic comment and usage comment as consecutive generic comment need to be put together # if Usage == DT.ITEM_UNDEFINED and Notify == '': # generate list of generic comment Comment = GenGenericCommentF(HelpStr) else: # generate list of other comment Comment = HelpStr.replace('\n', ' ') Comment = Comment.strip() if Comment: Comment = ' # ' + Comment else: Comment = '' if Usage == DT.ITEM_UNDEFINED and not Comment and Notify == '': Comment = '' else: if Notify: Comment = '## ' + Usage + ' ## ' + 'NOTIFY' + Comment else: Comment = '## ' + Usage + Comment if Comment: Comment += '\n' # # merge duplicate items # ArchList = sorted(Object.GetSupArchList()) SortedArch = ' '.join(ArchList) if (Statement, SortedArch) in Dict: PreviousComment = Dict[Statement, SortedArch] Comment = PreviousComment + Comment Dict[Statement, SortedArch] = Comment NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PPI_PROTOCOL') # # generate the section contents # if NewSectionDict: if IsProtocol: Content = GenSection('Protocols', NewSectionDict) else: Content = GenSection('Ppis', NewSectionDict) return Content
def GenPcdSections(ModuleObject): Content = '' if not GlobalData.gIS_BINARY_INF: # # for each Pcd Itemtype, maintain a dict so the same type will be grouped # together # ItemTypeDict = {} for Pcd in ModuleObject.GetPcdList(): HelpTextList = Pcd.GetHelpTextList() HelpStr = _GetHelpStr(HelpTextList) Statement = '' CName = Pcd.GetCName() TokenSpaceGuidCName = Pcd.GetTokenSpaceGuidCName() DefaultValue = Pcd.GetDefaultValue() ItemType = Pcd.GetItemType() if ItemType in ItemTypeDict: Dict = ItemTypeDict[ItemType] else: Dict = Sdict() ItemTypeDict[ItemType] = Dict FFE = Pcd.GetFeatureFlag() Statement += TokenSpaceGuidCName + '.' + CName if DefaultValue: Statement += '|' + DefaultValue if FFE: Statement += '|' + FFE elif FFE: Statement += '||' + FFE # # Generate comment # Usage = Pcd.GetValidUsage() # if FeatureFlag Pcd, then assume all Usage is CONSUMES if ItemType == DT.TAB_INF_FEATURE_PCD: Usage = DT.USAGE_ITEM_CONSUMES if Usage == DT.ITEM_UNDEFINED: # generate list of generic comment Comment = GenGenericCommentF(HelpStr) else: # generate list of other comment Comment = HelpStr.replace('\n', ' ') Comment = Comment.strip() if Comment: Comment = ' # ' + Comment else: Comment = '' Comment = '## ' + Usage + Comment if Comment: Comment += '\n' # # Merge duplicate entries # ArchList = sorted(Pcd.GetSupArchList()) SortedArch = ' '.join(ArchList) if (Statement, SortedArch) in Dict: PreviousComment = Dict[Statement, SortedArch] Comment = PreviousComment + Comment Dict[Statement, SortedArch] = Comment for ItemType in ItemTypeDict: # First we need to transfer the Dict to use SortedArch as key Dict = ItemTypeDict[ItemType] NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PCD') if NewSectionDict: Content += GenSection(ItemType, NewSectionDict) # # For AsBuild INF files # else: Content += GenAsBuiltPacthPcdSections(ModuleObject) Content += GenAsBuiltPcdExSections(ModuleObject) return Content