Пример #1
0
 def __init__(self):
     self.Header = DistributionPackageHeaderObject()
     #
     # {(Guid, Version, Path) : PackageObj}
     #
     self.PackageSurfaceArea = Sdict()
     #
     # {(Guid, Version, Name, Path) : ModuleObj}
     #
     self.ModuleSurfaceArea = Sdict()
     self.Tools = MiscFileObject()
     self.MiscellaneousFiles = MiscFileObject()
     self.UserExtensions = []
     self.FileList = []
Пример #2
0
def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleList, PackageList):
    NewDict = Sdict()
    for Guid, Version, Path in DistPkg.PackageSurfaceArea:
        PackagePath = Path
        Package = DistPkg.PackageSurfaceArea[Guid, Version, Path]
        Logger.Info(ST.MSG_INSTALL_PACKAGE % Package.GetName())
#         if Dep.CheckPackageExists(Guid, Version):
#             Logger.Info(ST.WRN_PACKAGE_EXISTED %(Guid, Version))
        if Options.UseGuidedPkgPath:
            GuidedPkgPath = "%s_%s_%s" % (Package.GetName(), Guid, Version)
            NewPackagePath = InstallNewPackage(WorkspaceDir, GuidedPkgPath, Options.CustomPath)
        else:
            NewPackagePath = InstallNewPackage(WorkspaceDir, PackagePath, Options.CustomPath)
        InstallPackageContent(PackagePath, NewPackagePath, Package, ContentZipFile, Dep, WorkspaceDir, ModuleList, 
                              DistPkg.Header.ReadOnly)
        PackageList.append(Package)
        
        NewDict[Guid, Version, Package.GetPackagePath()] = Package
    
    #
    # Now generate meta-data files, first generate all dec for package
    # dec should be generated before inf, and inf should be generated after
    # all packages installed, else hard to resolve modules' package
    # dependency (Hard to get the location of the newly installed package)
    #
    for Package in PackageList:
        FilePath = PackageToDec(Package, DistPkg.Header)
        Md5Sigature = md5.new(__FileHookOpen__(str(FilePath), 'rb').read())
        Md5Sum = Md5Sigature.hexdigest()
        if (FilePath, Md5Sum) not in Package.FileList:
            Package.FileList.append((FilePath, Md5Sum))
    
    return NewDict
Пример #3
0
def GenDepex(ModuleObject):
    #
    # generate [Depex] section
    #
    NewSectionDict = Sdict()
    Content = ''
    for Depex in ModuleObject.GetPeiDepex() + ModuleObject.GetDxeDepex(
    ) + ModuleObject.GetSmmDepex():
        HelpTextList = Depex.GetHelpTextList()
        HelpStr = _GetHelpStr(HelpTextList)
        CommentStr = GenGenericCommentF(HelpStr)
        SupArchList = Depex.GetSupArchList()
        SupModList = Depex.GetModuleType()
        Expression = Depex.GetDepex()
        Statement = CommentStr + Expression
        SupArchList.sort()
        KeyList = []
        if not SupArchList:
            SupArchList.append(DT.TAB_ARCH_COMMON.lower())
        if not SupModList:
            KeyList = SupArchList
        else:
            for ModuleType in SupModList:
                for Arch in SupArchList:
                    KeyList.append(
                        ConvertArchForInstall(Arch) + '.' + ModuleType)
        for Key in KeyList:
            if Key in NewSectionDict:
                NewSectionDict[Key] = NewSectionDict[Key] + [Statement]
            else:
                NewSectionDict[Key] = [Statement]
    Content += GenSection('Depex', NewSectionDict, False)

    return Content
Пример #4
0
 def __init__(self):
     self.Binaries = Sdict()
     #
     # Macro defined in this section should be only used in this section.
     #
     self.Macros = {}
     InfSectionCommonDef.__init__(self)
Пример #5
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
Пример #6
0
 def __init__(self):
     IdentificationObject.__init__(self)
     CommonHeaderObject.__init__(self)
     #
     # LibraryClassObject
     #
     self.LibraryClassList = [] 
     #
     # FileObject
     #
     self.IncludePathList = [] 
     #
     # StandardIncludeFileObject
     #
     self.StandardIncludeFileList = [] 
     #
     # PackageIncludeFileObject
     #
     self.PackageIncludeFileList = [] 
     #
     # Include and Arch List, item is (IncludePath, SupArchList-List of Arch), used during install package
     #
     self.IncludeArchList = []
     #
     # ProtocolObject
     #
     self.ProtocolList = [] 
     #
     # PpiObject
     #
     self.PpiList = [] 
     #
     # GuidObject
     #
     self.GuidList = [] 
     #
     # (PcdObject, PcdErrorObject)
     #
     self.PcdList = [] 
     #
     # UserExtensionObject
     #
     self.UserExtensionList = [] 
     #
     # MiscFileObject
     #
     self.MiscFileList = [] 
     self.ModuleDict = Sdict()
     #
     # ClonedRecordObject
     #
     self.ClonedFromList = [] 
     #
     # string object
     #
     self.ModuleFileList = [] 
     
     self.PcdChecks = []
Пример #7
0
def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
    #
    # ModulePathList will keep track of the standalone module path that
    # we just installed. If a new module's path in that list 
    # (only multiple INF in one directory will be so), we will 
    # install them directly. If not, we will try to create a new directory 
    # for it.
    #
    ModulePathList = []   
    
    #
    # Check module exist and install
    #
    Module = None
    NewDict = Sdict()        
    for Guid, Version, Name, Path in DistPkg.ModuleSurfaceArea:
        ModulePath = Path
        Module = DistPkg.ModuleSurfaceArea[Guid, Version, Name, Path]
        Logger.Info(ST.MSG_INSTALL_MODULE % Module.GetName())
        if Dep.CheckModuleExists(Guid, Version, Name, Path):
            Logger.Quiet(ST.WRN_MODULE_EXISTED %Path)
        #
        # here check for the multiple inf share the same module path cases:
        # they should be installed into the same directory
        #
        ModuleFullPath = \
        os.path.normpath(os.path.join(WorkspaceDir, ModulePath))
        if ModuleFullPath not in ModulePathList:
            NewModulePath = InstallNewModule(WorkspaceDir, ModulePath, ModulePathList)
            NewModuleFullPath = os.path.normpath(os.path.join(WorkspaceDir, NewModulePath))
            ModulePathList.append(NewModuleFullPath)
        else:
            NewModulePath = ModulePath
        
        InstallModuleContent(ModulePath, NewModulePath, '', Module, ContentZipFile, WorkspaceDir, ModuleList, None, 
                             DistPkg.Header.ReadOnly)
        #
        # Update module
        #
        Module.SetModulePath(Module.GetModulePath().replace(Path, NewModulePath, 1))
        
        NewDict[Guid, Version, Name, Module.GetModulePath()] = Module

    #
    # generate all inf for modules
    #
    for (Module, Package) in ModuleList:
        FilePath = ModuleToInf(Module)
        Md5Sigature = md5.new(open(str(FilePath), 'rb').read())
        Md5Sum = Md5Sigature.hexdigest()
        if Package:
            if (FilePath, Md5Sum) not in Package.FileList:
                Package.FileList.append((FilePath, Md5Sum))
        else:
            if (FilePath, Md5Sum) not in Module.FileList:
                Module.FileList.append((FilePath, Md5Sum))
    
    return NewDict
Пример #8
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
Пример #9
0
 def __init__(self, PkgFullName):
     _DecComments.__init__(self)
     #
     # Key is combined with (Arch, SectionType)
     # Default is common
     #
     self.ValueDict = Sdict()
     self._PkgFullName = PkgFullName
     self._PackagePath, self._FileName = os.path.split(PkgFullName)
     self._SecName = ''
Пример #10
0
def GenPackages(ModuleObject):
    Content = ''
    #
    # generate [Packages] section
    #
    NewSectionDict = Sdict()
    WorkspaceDir = getenv('WORKSPACE')
    for PackageDependency in ModuleObject.GetPackageDependencyList():
        #
        # Generate generic comment
        #
        CommentStr = ''
        HelpText = PackageDependency.GetHelpText()
        if HelpText:
            HelpStr = HelpText.GetString()
            CommentStr = GenGenericCommentF(HelpStr)
        Statement = CommentStr
        Guid = PackageDependency.GetGuid()
        Version = PackageDependency.GetVersion()
        FFE = PackageDependency.GetFeatureFlag()
        #
        # find package path/name
        #
        for PkgInfo in GlobalData.gWSPKG_LIST:
            if Guid == PkgInfo[1]:
                if (not Version) or (Version == PkgInfo[2]):
                    Path = PkgInfo[3]
                    break
        #
        # get relative path
        #
        RelaPath = Path[Path.upper().find(WorkspaceDir.upper()) +
                        len(WorkspaceDir) + 1:]
        Statement += RelaPath.replace('\\', '/')
        if FFE:
            Statement += '|' + FFE
        ArchList = PackageDependency.GetSupArchList()
        ArchList.sort()
        SortedArch = ' '.join(ArchList)
        if SortedArch in NewSectionDict:
            NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [
                Statement
            ]
        else:
            NewSectionDict[SortedArch] = [Statement]

    Content += GenSection('Packages', NewSectionDict)

    return Content
Пример #11
0
    def GenIncludes(self, ContainerFile):
        if ContainerFile:
            pass
        Logger.Debug(2, "Generate %s ..." % TAB_INCLUDES)
        IncludesDict = Sdict()

        IncObj = self.DecParser.GetIncludeSectionObject()
        for Item in IncObj.GetAllIncludes():
            IncludePath = os.path.normpath(Item.File)
            if platform.system() != 'Windows' and platform.system() != 'Microsoft':
                IncludePath = IncludePath.replace('\\', '/')
            if IncludePath in IncludesDict:
                if Item.GetArchList() == [TAB_ARCH_COMMON] or IncludesDict[IncludePath] == [TAB_ARCH_COMMON]:
                    IncludesDict[IncludePath] = [TAB_ARCH_COMMON]
                else:
                    IncludesDict[IncludePath] = IncludesDict[IncludePath] + Item.GetArchList()
            else:
                IncludesDict[IncludePath] = Item.GetArchList()

        #
        # get the  standardIncludeFileList(industry), packageIncludeFileList
        # (others) for PackageObject
        #
        PackagePath = os.path.split(self.GetFullPath())[0]
        IncludePathList = \
            sorted([os.path.normpath(Path) + sep for Path in IncludesDict.keys()])

        #
        # get a non-overlap set of include path, IncludePathList should be
        # sorted, and path should be end with path separator '\'
        #
        NonOverLapList = []
        for Path1 in IncludePathList:
            for Path2 in NonOverLapList:
                if Path1.startswith(Path2):
                    break
            else:
                NonOverLapList.append(Path1)
        #
        # revert the list so the longest path shown first in list, also need
        # to remove the extra path separator '\'
        # as this list is used to search the supported Arch info
        #
        for IndexN in range (0, len(IncludePathList)):
            IncludePathList[IndexN] = os.path.normpath(IncludePathList[IndexN])
        IncludePathList.sort()
        IncludePathList.reverse()
        #
        # save the include path list for later usage
        #
        self.SetIncludePathList(IncludePathList)
        StandardIncludeFileList = []
        PackageIncludeFileList = []

        IncludeFileList = []
        for Path in NonOverLapList:
            FileList = GetFiles(os.path.join(PackagePath, Path), ['CVS', '.svn'], False)
            IncludeFileList += [os.path.normpath(os.path.join(Path, File)) for File in FileList]
        for Includefile in IncludeFileList:
            ExtName = os.path.splitext(Includefile)[1]
            if ExtName.upper() == '.DEC' and self.CheckMulDec:
                Logger.Error('MkPkg',
                             UPT_MUL_DEC_ERROR,
                             ST.ERR_MUL_DEC_ERROR%(os.path.dirname(ContainerFile),
                                                   os.path.basename(ContainerFile),
                                                   Includefile))

            FileCombinePath = os.path.dirname(Includefile)
            Include = IncludeObject()
            for Path in IncludePathList:
                if FileCombinePath.startswith(Path):
                    SupArchList = IncludesDict[Path]
                    break
            Include.SetFilePath(Includefile)
            Include.SetSupArchList(SupArchList)
            if Includefile.find('IndustryStandard') != -1:
                StandardIncludeFileList.append(Include)
            else:
                PackageIncludeFileList.append(Include)

        self.SetStandardIncludeFileList(StandardIncludeFileList)

        #
        # put include path into the PackageIncludeFileList
        #
        PackagePathList = []
        IncObj = self.DecParser.GetIncludeSectionObject()
        for Item in IncObj.GetAllIncludes():
            IncludePath = Item.File
            Include = IncludeObject()
            Include.SetFilePath(IncludePath)
            Include.SetSupArchList(Item.GetArchList())
            PackagePathList.append(Include)
        self.SetPackageIncludeFileList(PackagePathList + PackageIncludeFileList)
Пример #12
0
 def __init__(self):
     self.LibraryClasses = Sdict()
     #
     # Macro defined in this section should be only used in this section.
     #
     self.Macros = {}
Пример #13
0
 def __init__(self):
     self.SpecialComments = Sdict()
     InfSectionCommonDef.__init__(self)
Пример #14
0
 def __init__(self):
     self.Defines = Sdict()
     InfSectionCommonDef.__init__(self)
Пример #15
0
 def __init__(self):
     self.Guids = Sdict()
     #
     # Macro defined in this section should be only used in this section.
     #
     self.Macros = {}
Пример #16
0
 def __init__(self, FileName):
     self.Pcds = Sdict()
     self.FileName = FileName
Пример #17
0
def ValidatePS1(Package):
    #
    # Check DistributionPackage -> PackageSurfaceArea -> Header
    #
    XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'Header']
    CheckDict = Sdict()
    CheckDict['Name'] = Package.GetName()
    CheckDict['BaseName'] = Package.GetBaseName()
    CheckDict['GUID'] = Package.GetGuid()
    CheckDict['Version'] = Package.GetVersion()
    CheckDict['PackagePath'] = Package.GetPackagePath()

    IsRequiredItemListNull(CheckDict, XmlTreeLevel)
    if not IsValidInstallPath(Package.GetPackagePath()):
        Logger.Error("UPT", FORMAT_INVALID,
                     ERR_FILE_NAME_INVALIDE % Package.GetPackagePath())

    #
    # Check DistributionPackage -> PackageSurfaceArea -> ClonedFrom
    #
    XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'ClonedFrom']
    for Item in Package.GetClonedFromList():
        if Item is None:
            CheckDict = Sdict()
            CheckDict['GUID'] = ''
            IsRequiredItemListNull(CheckDict, XmlTreeLevel)
        CheckDict = Sdict()
        CheckDict['GUID'] = Item.GetPackageGuid()
        CheckDict['Version'] = Item.GetPackageVersion()

        IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    #
    # Check DistributionPackage -> PackageSurfaceArea -> LibraryClassDeclarations -> LibraryClass
    #
    XmlTreeLevel = [
        'DistributionPackage', 'PackageSurfaceArea', 'LibraryClassDeclarations'
    ]
    for Item in Package.GetLibraryClassList():
        if Item is None:
            CheckDict = {'LibraryClass': ''}
            IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    XmlTreeLevel = [
        'DistributionPackage', 'PackageSurfaceArea',
        'LibraryClassDeclarations', 'LibraryClass'
    ]
    for Item in Package.GetLibraryClassList():
        CheckDict = {
            'Keyword': Item.GetLibraryClass(),
            'HeaderFile': Item.GetIncludeHeader()
        }
        IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    #
    # Check DistributionPackage -> PackageSurfaceArea -> IndustryStandardIncludes -> IndustryStandardHeader
    #
    XmlTreeLevel = [
        'DistributionPackage', 'PackageSurfaceArea', 'IndustryStandardIncludes'
    ]
    for Item in Package.GetStandardIncludeFileList():
        if Item is None:
            CheckDict = {'IndustryStandardHeader': ''}
            IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    XmlTreeLevel = [
        'DistributionPackage', 'PackageSurfaceArea',
        'IndustryStandardIncludes', 'IndustryStandardHeader'
    ]
    for Item in Package.GetStandardIncludeFileList():
        CheckDict = {'HeaderFile': Item.GetFilePath()}
        IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    #
    # Check DistributionPackage -> PackageSurfaceArea -> PackageIncludes -> PackageHeader
    #
    XmlTreeLevel = [
        'DistributionPackage', 'PackageSurfaceArea', 'PackageIncludes'
    ]
    for Item in Package.GetPackageIncludeFileList():
        if Item is None:
            CheckDict = {'PackageHeader': ''}
            IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    XmlTreeLevel = [
        'DistributionPackage', 'PackageSurfaceArea', 'PackageIncludes',
        'PackageHeader'
    ]
    for Item in Package.GetPackageIncludeFileList():
        CheckDict = {'HeaderFile': Item.GetFilePath()}
        IsRequiredItemListNull(CheckDict, XmlTreeLevel)
Пример #18
0
    def ValidateDistributionPackage(self):
        XmlTreeLevel = ['DistributionPackage']
        if self.DistP:
            #
            # Check DistributionPackage -> DistributionHeader
            #
            XmlTreeLevel = ['DistributionPackage', '']
            CheckDict = {'DistributionHeader': self.DistP.Header}
            IsRequiredItemListNull(CheckDict, XmlTreeLevel)

            if self.DistP.Header:
                DpHeader = self.DistP.Header
                XmlTreeLevel = ['DistributionPackage', 'DistributionHeader']
                CheckDict = Sdict()
                if DpHeader.GetAbstract():
                    DPAbstract = DpHeader.GetAbstract()[0][1]
                else:
                    DPAbstract = ''
                if DpHeader.GetCopyright():
                    DPCopyright = DpHeader.GetCopyright()[0][1]
                else:
                    DPCopyright = ''
                if DpHeader.GetLicense():
                    DPLicense = DpHeader.GetLicense()[0][1]
                else:
                    DPLicense = ''

                CheckDict['Name'] = DpHeader.GetName()
                CheckDict['GUID'] = DpHeader.GetGuid()
                CheckDict['Version'] = DpHeader.GetVersion()
                CheckDict['Copyright'] = DPCopyright
                CheckDict['License'] = DPLicense
                CheckDict['Abstract'] = DPAbstract
                CheckDict['Vendor'] = DpHeader.GetVendor()
                CheckDict['Date'] = DpHeader.GetDate()
                CheckDict['XmlSpecification'] = DpHeader.GetXmlSpecification()

                IsRequiredItemListNull(CheckDict, XmlTreeLevel)
            else:
                XmlTreeLevel = ['DistributionPackage', 'DistributionHeader']
                CheckDict = CheckDict = {
                    'DistributionHeader': '',
                }
                IsRequiredItemListNull(CheckDict, XmlTreeLevel)

            #
            # Check Each Package
            #
            for Key in self.DistP.PackageSurfaceArea:
                ValidatePackageSurfaceArea(self.DistP.PackageSurfaceArea[Key])

            #
            # Check Each Module
            #
            for Key in self.DistP.ModuleSurfaceArea:
                ValidateMS(self.DistP.ModuleSurfaceArea[Key],
                           ['DistributionPackage', 'ModuleSurfaceArea'])

            #
            # Check Each Tool
            #
            if self.DistP.Tools:
                XmlTreeLevel = ['DistributionPackage', 'Tools', 'Header']
                CheckDict = {
                    'Name': self.DistP.Tools.GetName(),
                }
                IsRequiredItemListNull(CheckDict, XmlTreeLevel)

                if not self.DistP.Tools.GetFileList():
                    XmlTreeLevel = ['DistributionPackage', 'Tools']
                    CheckDict = {
                        'FileName': None,
                    }
                    IsRequiredItemListNull(CheckDict, XmlTreeLevel)
                for Item in self.DistP.Tools.GetFileList():
                    XmlTreeLevel = ['DistributionPackage', 'Tools']
                    CheckDict = {
                        'FileName': Item.GetURI(),
                    }
                    IsRequiredItemListNull(CheckDict, XmlTreeLevel)

            #
            # Check Each Misc File
            #
            if self.DistP.MiscellaneousFiles:
                XmlTreeLevel = [
                    'DistributionPackage', 'MiscellaneousFiles', 'Header'
                ]
                CheckDict = {
                    'Name': self.DistP.MiscellaneousFiles.GetName(),
                }
                IsRequiredItemListNull(CheckDict, XmlTreeLevel)

                if not self.DistP.MiscellaneousFiles.GetFileList():
                    XmlTreeLevel = [
                        'DistributionPackage', 'MiscellaneousFiles'
                    ]
                    CheckDict = {
                        'FileName': None,
                    }
                    IsRequiredItemListNull(CheckDict, XmlTreeLevel)
                for Item in self.DistP.MiscellaneousFiles.GetFileList():
                    XmlTreeLevel = [
                        'DistributionPackage', 'MiscellaneousFiles'
                    ]
                    CheckDict = {
                        'FileName': Item.GetURI(),
                    }
                    IsRequiredItemListNull(CheckDict, XmlTreeLevel)

            #
            # Check Each Distribution Level User Extension
            #
            for Item in self.DistP.UserExtensions:
                XmlTreeLevel = ['DistributionPackage', 'UserExtensions']
                CheckDict = {
                    'UserId': Item.GetUserID(),
                }
                IsRequiredItemListNull(CheckDict, XmlTreeLevel)
Пример #19
0
def ValidateMS2(Module, TopXmlTreeLevel):
    #
    # Check Header
    #
    XmlTreeLevel = TopXmlTreeLevel + ['Header']
    CheckDict = Sdict()
    CheckDict['Name'] = Module.GetName()
    CheckDict['BaseName'] = Module.GetBaseName()
    CheckDict['GUID'] = Module.GetGuid()
    CheckDict['Version'] = Module.GetVersion()
    IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    #
    # Check ModuleProperties
    #
    XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties']
    CheckDict = {
        'ModuleType': Module.GetModuleType(),
        'Path': Module.GetModulePath()
    }
    IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    if not IsValidInstallPath(Module.GetModulePath()):
        Logger.Error("UPT", FORMAT_INVALID,
                     ERR_FILE_NAME_INVALIDE % Module.GetModulePath())

    #
    # Check ModuleProperties->BootMode
    #
    XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['BootMode']
    for Item in Module.GetBootModeList():
        CheckDict = {
            'Usage': Item.GetUsage(),
            'SupportedBootModes': Item.GetSupportedBootModes()
        }
        IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    #
    # Check ModuleProperties->Event
    #
    XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['Event']
    for Item in Module.GetEventList():
        CheckDict = {
            'Usage': Item.GetUsage(),
            'EventType': Item.GetEventType()
        }
        IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    #
    # Check ModuleProperties->Hob
    #
    XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['HOB']
    for Item in Module.GetHobList():
        CheckDict = {'Usage': Item.GetUsage(), 'HobType': Item.GetHobType()}
        IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    #
    # The UDP Specification supports the module type of UEFI_RUNTIME_DRIVER, which is not present in the EDK II INF
    # File Specification v. 1.23, so UPT must perform the following translation that include the generation of a
    # [Depex] section.
    #
    if Module.ModuleType == "UEFI_RUNTIME_DRIVER":
        Module.ModuleType = "DXE_RUNTIME_DRIVER"
        DxeObj = DepexObject()
        DxeObj.SetDepex("gEfiBdsArchProtocolGuid AND \ngEfiCpuArchProtocolGuid AND\n" + \
                        "gEfiMetronomeArchProtocolGuid AND \ngEfiMonotonicCounterArchProtocolGuid AND\n" + \
                        "gEfiRealTimeClockArchProtocolGuid AND \ngEfiResetArchProtocolGuid AND\n" + \
                        "gEfiRuntimeArchProtocolGuid AND \ngEfiSecurityArchProtocolGuid AND\n" + \
                        "gEfiTimerArchProtocolGuid AND \ngEfiVariableWriteArchProtocolGuid AND\n" + \
                        "gEfiVariableArchProtocolGuid AND \ngEfiWatchdogTimerArchProtocolGuid")
        DxeObj.SetModuleType(['DXE_RUNTIME_DRIVER'])
        Module.PeiDepex = []
        Module.DxeDepex = []
        Module.SmmDepex = []
        Module.DxeDepex.append(DxeObj)

    #
    # Check LibraryClassDefinitions -> LibraryClass
    #
    XmlTreeLevel = TopXmlTreeLevel + ['LibraryClassDefinitions']
    for Item in Module.GetLibraryClassList():
        if Item is None:
            CheckDict = {'LibraryClass': ''}
            IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    XmlTreeLevel = TopXmlTreeLevel + [
        'LibraryClassDefinitions', 'LibraryClass'
    ]

    IsLibraryModule = False
    LibrarySupModList = []
    for Item in Module.GetLibraryClassList():
        CheckDict = {
            'Keyword': Item.GetLibraryClass(),
            'Usage': Item.GetUsage()
        }
        IsRequiredItemListNull(CheckDict, XmlTreeLevel)
        #
        # If the LibraryClass:SupModList is not "UNDEFINED" the LIBRARY_CLASS entry must have the list
        # appended using the format:
        # LIBRARY_CLASS = <ClassName> ["|" <Edk2ModuleTypeList>]
        #
        # Edk2ModuleTypeList ::= <ModuleType> [" " <ModuleType>]{0,}
        # <ModuleTypes>      ::= {"BASE"} {"SEC"} {"PEI_CORE"} {"PEIM"}
        #                       {"DXE_CORE"} {"DXE_DRIVER"} {"SMM_CORE"}
        #                       {"DXE_SMM_DRIVER"} {"DXE_RUNTIME_DRIVER"}
        #                       {"DXE_SAL_DRIVER"} {"UEFI_DRIVER"}
        #                       {"UEFI_APPLICATION"} {"USER_DEFINED"}
        #
        if len(Item.SupModuleList) > 0:
            for SupModule in Item.SupModuleList:
                if not IsValidInfMoudleType(SupModule):
                    Logger.Error('\nUPT',
                                 PARSER_ERROR,
                                 ERR_XML_INVALID_LIB_SUPMODLIST %
                                 (Item.LibraryClass, str(SupModule)),
                                 RaiseError=True)

        if Item.Usage == 'PRODUCES' or Item.Usage == 'SOMETIMES_PRODUCES':
            IsLibraryModule = True
            LibrarySupModList = Item.SupModuleList

    #
    # For Library modules (indicated by a LIBRARY_CLASS statement in the [Defines] section)
    # If the SupModList attribute of the CONSTRUCTOR or DESTRUCTOR element does not match the Supported Module
    # Types listed after "LIBRARY_CLASS = <Keyword> |", the tool should gracefully exit with an error message
    # stating that there is a conflict in the module types the CONSTRUCTOR/DESTRUCTOR is to be used with and
    # the Module types this Library supports.
    #
    if IsLibraryModule:
        for Item in Module.GetExternList():
            if Item.Constructor or Item.Destructor:
                if hasattr(Item, 'SupModList') and len(Item.SupModList) > 0 and \
                   not IsEqualList(Item.SupModList, LibrarySupModList):
                    Logger.Error(
                        '\nUPT',
                        PARSER_ERROR,
                        ERR_XML_INVALID_EXTERN_SUPMODLIST %
                        (str(Item.SupModList), str(LibrarySupModList)),
                        RaiseError=True)

    #
    # If the module is not a library module, the MODULE_TYPE listed in the ModuleSurfaceArea.Header must match the
    # SupModList attribute.  If these conditions cannot be met, the tool must exit gracefully, informing the user
    # that the EDK II Build system does not currently support the features required by this Module.
    #
    if not IsLibraryModule:
        for Item in Module.GetExternList():
            if hasattr(Item, 'SupModList') and len(Item.SupModList) > 0 and \
               not IsEqualList(Item.SupModList, [Module.ModuleType]):
                Logger.Error('\nUPT',
                             PARSER_ERROR,
                             ERR_XML_INVALID_EXTERN_SUPMODLIST_NOT_LIB %
                             (str(Module.ModuleType), str(Item.SupModList)),
                             RaiseError=True)
    #
    # Check SourceFiles
    #
    XmlTreeLevel = TopXmlTreeLevel + ['SourceFiles']
    for Item in Module.GetSourceFileList():
        if Item is None:
            CheckDict = {'Filename': ''}
            IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    XmlTreeLevel = TopXmlTreeLevel + ['SourceFiles']
    for Item in Module.GetSourceFileList():
        CheckDict = {'Filename': Item.GetSourceFile()}
        IsRequiredItemListNull(CheckDict, XmlTreeLevel)

    for ItemCount in range(len(Module.GetBinaryFileList())):
        Item = Module.GetBinaryFileList()[ItemCount]
        if Item and len(Item.FileNamList
                        ) > 0 and Item.FileNamList[0].FileType == 'FREEFORM':
            Item.FileNamList[0].FileType = 'SUBTYPE_GUID'
            Module.GetBinaryFileList()[ItemCount] = Item
 def __init__(self):
     self.UserExtension = Sdict()
Пример #21
0
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
Пример #22
0
 def __init__(self):
     self.Sources = Sdict()
     InfSectionCommonDef.__init__(self)