コード例 #1
0
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 = Guid.GetSupArchList()
        ArchList.sort()
        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
コード例 #2
0
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 = Object.GetSupArchList()
        ArchList.sort()
        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
コード例 #3
0
def GenAsBuiltPacthPcdSections(ModuleObject):
    PatchPcdDict = {}
    for BinaryFile in ModuleObject.GetBinaryFileList():
        if not BinaryFile.AsBuiltList:
            continue
        for PatchPcd in BinaryFile.AsBuiltList[0].PatchPcdList:
            TokenSpaceName = ''
            PcdCName = PatchPcd.CName
            PcdValue = PatchPcd.DefaultValue
            PcdOffset = PatchPcd.Offset
            TokenSpaceGuidValue = PatchPcd.TokenSpaceGuidValue
            Token = PatchPcd.Token
            HelpTextList = PatchPcd.HelpTextList
            HelpString = ''
            for HelpStringItem in HelpTextList:
                for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
                    HelpString += '## ' + HelpLine + '\n'
            TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(
                ModuleObject.PackageDependencyList, TokenSpaceGuidValue, Token)
            if TokenSpaceName == '' or PcdCName == '':
                Logger.Error("Upt",
                             ToolError.RESOURCE_NOT_AVAILABLE,
                             ST.ERR_INSTALL_FILE_DEC_FILE_ERROR %
                             (TokenSpaceGuidValue, Token),
                             File=ModuleObject.GetFullPath())
            Statement = HelpString + TokenSpaceName + '.' + PcdCName + ' | ' + PcdValue + ' | ' + \
                         PcdOffset + DT.TAB_SPACE_SPLIT
            #
            # Use binary file's Arch to be Pcd's Arch
            #
            ArchList = []
            FileNameObjList = BinaryFile.GetFileNameList()
            if FileNameObjList:
                ArchList = FileNameObjList[0].GetSupArchList()
            if len(ArchList) == 0:
                if PatchPcdDict.has_key(DT.TAB_ARCH_COMMON):
                    if Statement not in PatchPcdDict[DT.TAB_ARCH_COMMON]:
                        PatchPcdDict[DT.TAB_ARCH_COMMON].append(Statement)
                else:
                    PatchPcdDict[DT.TAB_ARCH_COMMON] = [Statement]
            else:
                for Arch in ArchList:
                    if PatchPcdDict.has_key(Arch):
                        if Statement not in PatchPcdDict[Arch]:
                            PatchPcdDict[Arch].append(Statement)
                    else:
                        PatchPcdDict[Arch] = [Statement]
    return GenSection(DT.TAB_INF_PATCH_PCD, PatchPcdDict)
コード例 #4
0
def GenAsBuiltPcdExSections(ModuleObject):
    PcdExDict = {}
    for BinaryFile in ModuleObject.GetBinaryFileList():
        if not BinaryFile.AsBuiltList:
            continue
        for PcdExItem in BinaryFile.AsBuiltList[0].PcdExValueList:
            TokenSpaceName = ''
            PcdCName = PcdExItem.CName
            TokenSpaceGuidValue = PcdExItem.TokenSpaceGuidValue
            Token = PcdExItem.Token
            HelpTextList = PcdExItem.HelpTextList
            HelpString = ''
            for HelpStringItem in HelpTextList:
                for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
                    HelpString += '## ' + HelpLine + '\n'
            TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(
                ModuleObject.PackageDependencyList, TokenSpaceGuidValue, Token)
            if TokenSpaceName == '' or PcdCName == '':
                Logger.Error("Upt",
                             ToolError.RESOURCE_NOT_AVAILABLE,
                             ST.ERR_INSTALL_FILE_DEC_FILE_ERROR %
                             (TokenSpaceGuidValue, Token),
                             File=ModuleObject.GetFullPath())

            Statement = HelpString + TokenSpaceName + DT.TAB_SPLIT + PcdCName + DT.TAB_SPACE_SPLIT

            #
            # Use binary file's Arch to be Pcd's Arch
            #
            ArchList = []
            FileNameObjList = BinaryFile.GetFileNameList()
            if FileNameObjList:
                ArchList = FileNameObjList[0].GetSupArchList()

            if len(ArchList) == 0:
                if 'COMMON' in PcdExDict:
                    PcdExDict['COMMON'].append(Statement)
                else:
                    PcdExDict['COMMON'] = [Statement]
            else:
                for Arch in ArchList:
                    if Arch in PcdExDict:
                        if Statement not in PcdExDict[Arch]:
                            PcdExDict[Arch].append(Statement)
                    else:
                        PcdExDict[Arch] = [Statement]
    return GenSection('PcdEx', PcdExDict)
コード例 #5
0
ファイル: GenInfFile.py プロジェクト: mcb30/edk2
def GenAsBuiltPcdExSections(ModuleObject):
    PcdExDict = {}
    for BinaryFile in ModuleObject.GetBinaryFileList():
        if not BinaryFile.AsBuiltList:
            continue
        for PcdExItem in BinaryFile.AsBuiltList[0].PcdExValueList:
            TokenSpaceName = ''
            PcdCName = PcdExItem.CName
            PcdValue = PcdExItem.DefaultValue
            TokenSpaceGuidValue = PcdExItem.TokenSpaceGuidValue
            Token = PcdExItem.Token
            HelpTextList = PcdExItem.HelpTextList
            HelpString = ''
            for HelpStringItem in HelpTextList:
                for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
                    HelpString += '# ' + HelpLine + '\n'
            TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(
                ModuleObject.PackageDependencyList, TokenSpaceGuidValue, Token)

            if TokenSpaceName == '' or PcdCName == '':
                Logger.Error("Upt",
                             ToolError.RESOURCE_NOT_AVAILABLE,
                             ST.ERR_INSTALL_FILE_DEC_FILE_ERROR %
                             (TokenSpaceGuidValue, Token),
                             File=ModuleObject.GetFullPath())

            Statement = HelpString[:
                                   -3] + TokenSpaceName + '.' + PcdCName + ' | ' + PcdValue

            if len(BinaryFile.SupArchList) == 0:
                if PcdExDict.has_key('COMMON'):
                    PcdExDict['COMMON'].append(Statement)
                else:
                    PcdExDict['COMMON'] = [Statement]
            else:
                for Arch in BinaryFile.SupArchList:
                    if PcdExDict.has_key(Arch):
                        PcdExDict[Arch].append(Statement)
                    else:
                        PcdExDict[Arch] = [Statement]
    return GenSection('PcdEx', PcdExDict)
コード例 #6
0
ファイル: GenInfFile.py プロジェクト: mcb30/edk2
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 or (ItemType
                                              == DT.TAB_INF_FEATURE_PCD):
                # 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 = Pcd.GetSupArchList()
            ArchList.sort()
            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)

            if NewSectionDict:
                Content += GenSection(ItemType, NewSectionDict)
    #
    # For AsBuild INF files
    #
    else:
        Content += GenAsBuiltPacthPcdSections(ModuleObject)
        Content += GenAsBuiltPcdExSections(ModuleObject)

    return Content
コード例 #7
0
ファイル: GenInfFile.py プロジェクト: mcb30/edk2
def GenDefines(ModuleObject):
    #
    # generate [Defines] section
    #
    Content = ''
    NewSectionDict = {}
    for UserExtension in ModuleObject.GetUserExtensionList():
        DefinesDict = UserExtension.GetDefinesDict()
        if not DefinesDict:
            continue

        for Statement in DefinesDict:
            SortedArch = DT.TAB_ARCH_COMMON
            if Statement.strip().startswith(
                    DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE):
                pos = Statement.find(DT.TAB_VALUE_SPLIT)
                if pos == -1:
                    pos = Statement.find(DT.TAB_EQUAL_SPLIT)
                Makefile = ConvertPath(Statement[pos + 1:].strip())
                Statement = Statement[:pos + 1] + ' ' + Makefile
            if SortedArch in NewSectionDict:
                NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [
                    Statement
                ]
            else:
                NewSectionDict[SortedArch] = [Statement]

    SpecialStatementList = []

    #
    # Add INF_VERSION statement firstly
    #
    Statement = 'INF_VERSION = 0x00010017'
    SpecialStatementList.append(Statement)

    BaseName = ModuleObject.GetBaseName()
    if BaseName.startswith('.') or BaseName.startswith('-'):
        BaseName = '_' + BaseName
    Statement = '%s = %s' % (DT.TAB_INF_DEFINES_BASE_NAME, BaseName)
    SpecialStatementList.append(Statement)
    Statement = '%s = %s' % (DT.TAB_INF_DEFINES_FILE_GUID,
                             ModuleObject.GetGuid())
    SpecialStatementList.append(Statement)
    Statement = '%s = %s' % (DT.TAB_INF_DEFINES_VERSION_STRING,
                             ModuleObject.GetVersion())
    SpecialStatementList.append(Statement)

    if ModuleObject.GetModuleType():
        Statement = '%s = %s' % (DT.TAB_INF_DEFINES_MODULE_TYPE,
                                 ModuleObject.GetModuleType())
        SpecialStatementList.append(Statement)
    if ModuleObject.GetPcdIsDriver():
        Statement = '%s = %s' % (DT.TAB_INF_DEFINES_PCD_IS_DRIVER,
                                 ModuleObject.GetPcdIsDriver())
        SpecialStatementList.append(Statement)
    if ModuleObject.GetUefiSpecificationVersion():
        Statement = '%s = %s' % (DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION, \
                                 ModuleObject.GetUefiSpecificationVersion())
        SpecialStatementList.append(Statement)
    if ModuleObject.GetPiSpecificationVersion():
        Statement = '%s = %s' % (DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION,
                                 ModuleObject.GetPiSpecificationVersion())
        SpecialStatementList.append(Statement)
    for LibraryClass in ModuleObject.GetLibraryClassList():
        if LibraryClass.GetUsage() == DT.USAGE_ITEM_PRODUCES or \
           LibraryClass.GetUsage() == DT.USAGE_ITEM_SOMETIMES_PRODUCES:
            Statement = '%s = %s' % (DT.TAB_INF_DEFINES_LIBRARY_CLASS,
                                     LibraryClass.GetLibraryClass())
            if LibraryClass.GetSupModuleList():
                Statement += '|' + DT.TAB_SPACE_SPLIT.join(
                    l for l in LibraryClass.GetSupModuleList())
            SpecialStatementList.append(Statement)
    for SpecItem in ModuleObject.GetSpecList():
        Spec, Version = SpecItem
        Spec = ConvertSpec(Spec)
        Statement = '%s %s = %s' % (DT.TAB_INF_DEFINES_SPEC, Spec, Version)
        SpecialStatementList.append(Statement)

    ExternList = []
    for Extern in ModuleObject.GetExternList():
        ArchList = Extern.GetSupArchList()
        EntryPoint = Extern.GetEntryPoint()
        UnloadImage = Extern.GetUnloadImage()
        Constructor = Extern.GetConstructor()
        Destructor = Extern.GetDestructor()
        HelpStringList = Extern.GetHelpTextList()
        FFE = Extern.GetFeatureFlag()
        ExternList.append([
            ArchList, EntryPoint, UnloadImage, Constructor, Destructor, FFE,
            HelpStringList
        ])

    #
    # Add VALID_ARCHITECTURES information
    #
    ValidArchStatement = None
    if ModuleObject.SupArchList:
        ValidArchStatement = '# ' + '\n'
        ValidArchStatement += '# The following information is for reference only and not required by the build tools.\n'
        ValidArchStatement += '# ' + '\n'
        ValidArchStatement += '# VALID_ARCHITECTURES = %s' % (' '.join(
            ModuleObject.SupArchList)) + '\n'
        ValidArchStatement += '# ' + '\n'

    if DT.TAB_ARCH_COMMON not in NewSectionDict:
        NewSectionDict[DT.TAB_ARCH_COMMON] = []
    NewSectionDict[DT.TAB_ARCH_COMMON] = NewSectionDict[
        DT.TAB_ARCH_COMMON] + SpecialStatementList
    GenMetaFileMisc.AddExternToDefineSec(NewSectionDict, DT.TAB_ARCH_COMMON,
                                         ExternList)
    if ValidArchStatement is not None:
        NewSectionDict[DT.TAB_ARCH_COMMON] = NewSectionDict[
            DT.TAB_ARCH_COMMON] + [ValidArchStatement]

    Content += GenSection('Defines', NewSectionDict)

    return Content