コード例 #1
0
    def __init__(self, Datab, ToBeInstalledPkgList=None):
        self.IpiDb = Datab
        self.WsPkgList = GetWorkspacePackage()
        self.WsModuleList = GetWorkspaceModule()

        self.PkgsToBeDepend = [(PkgInfo[1], PkgInfo[2]) for PkgInfo in self.WsPkgList]

        # Add package info from the DIST to be installed.
        self.PkgsToBeDepend.extend(self.GenToBeInstalledPkgList(ToBeInstalledPkgList))
コード例 #2
0
ファイル: GenInfFile.py プロジェクト: mcb30/edk2
def ModuleToInf(ModuleObject):
    if not GlobalData.gWSPKG_LIST:
        GlobalData.gWSPKG_LIST = GetWorkspacePackage()

    #
    # Init global information for the file
    #
    ContainerFile = ModuleObject.GetFullPath()
    Content = ''
    #
    # generate header comment section
    #
    Content += GenHeaderCommentSection(ModuleObject.GetAbstract(),
                                       ModuleObject.GetDescription(),
                                       ModuleObject.GetCopyright(),
                                       ModuleObject.GetLicense())

    #
    # Judge whether the INF file is an AsBuild INF.
    #
    if ModuleObject.BinaryModule:
        GlobalData.gIS_BINARY_INF = True
    else:
        GlobalData.gIS_BINARY_INF = False

    #
    # for each section, maintain a dict, sorted arch will be its key,
    # statement list will be its data
    # { 'Arch1 Arch2 Arch3': [statement1, statement2],
    #   'Arch1' : [statement1, statement3]
    #  }
    #

    #
    # Gen section contents
    #
    Content += GenDefines(ModuleObject)
    Content += GenBuildOptions(ModuleObject)
    Content += GenLibraryClasses(ModuleObject)
    Content += GenPackages(ModuleObject)
    Content += GenPcdSections(ModuleObject)
    Content += GenSources(ModuleObject)
    Content += GenProtocolPPiSections(ModuleObject.GetProtocolList(), True)
    Content += GenProtocolPPiSections(ModuleObject.GetPpiList(), False)
    Content += GenGuidSections(ModuleObject.GetGuidList())
    Content += GenBinaries(ModuleObject)
    Content += GenDepex(ModuleObject)
    Content += GenUserExtensions(ModuleObject)

    if ModuleObject.GetEventList() or ModuleObject.GetBootModeList(
    ) or ModuleObject.GetHobList():
        Content += '\n\n'
    #
    # generate [Event], [BootMode], [Hob] section
    #
    Content += GenSpecialSections(ModuleObject.GetEventList(), 'Event')
    Content += GenSpecialSections(ModuleObject.GetBootModeList(), 'BootMode')
    Content += GenSpecialSections(ModuleObject.GetHobList(), 'Hob')

    SaveFileOnChange(ContainerFile, Content, False)
    return ContainerFile
コード例 #3
0
 def __init__(self, Datab):
     self.IpiDb = Datab
     self.WsPkgList = GetWorkspacePackage()
     self.WsModuleList = GetWorkspaceModule()
     self.PkgsToBeDepend = []
コード例 #4
0
def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None):
    if not GlobalData.gWSPKG_LIST:
        GlobalData.gWSPKG_LIST = GetWorkspacePackage()
    #
    # Init global information for the file
    #
    ContainerFile = ModuleObject.GetFullPath()

    Content = ''
    #
    # Generate file header, If any Abstract, Description, Copyright or License XML elements are missing,
    # should 1) use the Abstract, Description, Copyright or License from the PackageSurfaceArea.Header elements
    # that the module belongs to, or 2) if this is a stand-alone module that is not included in a PackageSurfaceArea,
    # use the abstract, description, copyright or license from the DistributionPackage.Header elements.
    #
    ModuleAbstract = GetLocalValue(ModuleObject.GetAbstract())
    if not ModuleAbstract and PackageObject:
        ModuleAbstract = GetLocalValue(PackageObject.GetAbstract())
    if not ModuleAbstract and DistHeader:
        ModuleAbstract = GetLocalValue(DistHeader.GetAbstract())
    ModuleDescription = GetLocalValue(ModuleObject.GetDescription())
    if not ModuleDescription and PackageObject:
        ModuleDescription = GetLocalValue(PackageObject.GetDescription())
    if not ModuleDescription and DistHeader:
        ModuleDescription = GetLocalValue(DistHeader.GetDescription())
    ModuleCopyright = ''
    for (Lang, Copyright) in ModuleObject.GetCopyright():
        if Lang:
            pass
        ModuleCopyright = Copyright
    if not ModuleCopyright and PackageObject:
        for (Lang, Copyright) in PackageObject.GetCopyright():
            if Lang:
                pass
            ModuleCopyright = Copyright
    if not ModuleCopyright and DistHeader:
        for (Lang, Copyright) in DistHeader.GetCopyright():
            if Lang:
                pass
            ModuleCopyright = Copyright
    ModuleLicense = ''
    for (Lang, License) in ModuleObject.GetLicense():
        if Lang:
            pass
        ModuleLicense = License
    if not ModuleLicense and PackageObject:
        for (Lang, License) in PackageObject.GetLicense():
            if Lang:
                pass
            ModuleLicense = License
    if not ModuleLicense and DistHeader:
        for (Lang, License) in DistHeader.GetLicense():
            if Lang:
                pass
            ModuleLicense = License

    #
    # Generate header comment section of INF file
    #
    Content += GenHeaderCommentSection(ModuleAbstract, ModuleDescription,
                                       ModuleCopyright,
                                       ModuleLicense).replace('\r\n', '\n')

    #
    # Generate Binary Header
    #
    for UserExtension in ModuleObject.GetUserExtensionList():
        if UserExtension.GetUserID() == DT.TAB_BINARY_HEADER_USERID \
        and UserExtension.GetIdentifier() == DT.TAB_BINARY_HEADER_IDENTIFIER:
            ModuleBinaryAbstract = GetLocalValue(
                UserExtension.GetBinaryAbstract())
            ModuleBinaryDescription = GetLocalValue(
                UserExtension.GetBinaryDescription())
            ModuleBinaryCopyright = ''
            ModuleBinaryLicense = ''
            for (Lang, Copyright) in UserExtension.GetBinaryCopyright():
                ModuleBinaryCopyright = Copyright
            for (Lang, License) in UserExtension.GetBinaryLicense():
                ModuleBinaryLicense = License
            if ModuleBinaryAbstract and ModuleBinaryDescription and \
            ModuleBinaryCopyright and ModuleBinaryLicense:
                Content += GenHeaderCommentSection(ModuleBinaryAbstract,
                                                   ModuleBinaryDescription,
                                                   ModuleBinaryCopyright,
                                                   ModuleBinaryLicense, True)

    #
    # Generate MODULE_UNI_FILE for module
    #
    FileHeader = GenHeaderCommentSection(ModuleAbstract, ModuleDescription, ModuleCopyright, ModuleLicense, False, \
                                         DT.TAB_COMMENT_EDK1_SPLIT)
    GenModuleUNIEncodeFile(ModuleObject, FileHeader)

    #
    # Judge whether the INF file is an AsBuild INF.
    #
    if ModuleObject.BinaryModule:
        GlobalData.gIS_BINARY_INF = True
    else:
        GlobalData.gIS_BINARY_INF = False
    #
    # for each section, maintain a dict, sorted arch will be its key,
    # statement list will be its data
    # { 'Arch1 Arch2 Arch3': [statement1, statement2],
    #   'Arch1' : [statement1, statement3]
    #  }
    #
    # Gen section contents
    #
    Content += GenDefines(ModuleObject)
    Content += GenBuildOptions(ModuleObject)
    Content += GenLibraryClasses(ModuleObject)
    Content += GenPackages(ModuleObject)
    Content += GenPcdSections(ModuleObject)
    Content += GenSources(ModuleObject)
    Content += GenProtocolPPiSections(ModuleObject.GetProtocolList(), True)
    Content += GenProtocolPPiSections(ModuleObject.GetPpiList(), False)
    Content += GenGuidSections(ModuleObject.GetGuidList())
    Content += GenBinaries(ModuleObject)
    Content += GenDepex(ModuleObject)
    Content += GenUserExtensions(ModuleObject)
    if ModuleObject.GetEventList() or ModuleObject.GetBootModeList(
    ) or ModuleObject.GetHobList():
        Content += '\n'
    #
    # generate [Event], [BootMode], [Hob] section
    #
    Content += GenSpecialSections(ModuleObject.GetEventList(), 'Event')
    Content += GenSpecialSections(ModuleObject.GetBootModeList(), 'BootMode')
    Content += GenSpecialSections(ModuleObject.GetHobList(), 'Hob')
    SaveFileOnChange(ContainerFile, Content, False)
    if DistHeader.ReadOnly:
        os.chmod(ContainerFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
    else:
        os.chmod(
            ContainerFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
            | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)
    return ContainerFile