Пример #1
0
    def FromXml(self, Item, Key):
        if self.FileNames:
            pass
        BinaryFile = BinaryFileObject()
        FilenameList = []
        SupArchList = ['COMMON']
        for SubItem in XmlList(Item, '%s/Filename' % Key):
            Axml = FilenameXml()
            Bxml = Axml.FromXml(SubItem, 'Filename')
            FilenameList.append(Bxml)
        BinaryFile.SetFileNameList(FilenameList)
        for FileName in FilenameList:
            if FileName.GetSupArchList():
                SupArchList = FileName.GetSupArchList()
        BinaryFile.SetSupArchList(SupArchList)
        if GlobalData.gIS_BINARY_INF:
            AsBuiltList = []
            for AsBuiltItem in XmlList(Item, '%s/AsBuilt' % Key):
                AsBuilt = AsBuiltObject()

                PatchPcdValueList = []
                for SubItem in XmlList(AsBuiltItem, 'AsBuilt/PatchPcdValue'):
                    Axml = PcdEntryXml()
                    Bxml = Axml.FromXml(SubItem, 'PatchPcdValue')
                    PatchPcdValueList.append(Bxml)
                AsBuilt.SetPatchPcdList(PatchPcdValueList)
                PcdExValueList = []
                for SubItem in XmlList(AsBuiltItem, 'AsBuilt/PcdExValue'):
                    Axml = PcdEntryXml()
                    Bxml = Axml.FromXml(SubItem, 'PcdExValue')
                    PcdExValueList.append(Bxml)
                AsBuilt.SetPcdExList(PcdExValueList)
                LibraryList = []
                for SubItem in XmlList(
                        Item, '%s/AsBuilt/LibraryInstances/GUID' % Key):
                    GuidVerObj = GuidVersionObject()
                    GUID = XmlElement(SubItem, 'GUID')
                    Version = XmlAttribute(XmlNode(SubItem, 'GUID'), 'Version')
                    GuidVerObj.SetGuid(GUID)
                    GuidVerObj.SetVersion(Version)
                    LibraryList.append(GuidVerObj)
                if XmlList(Item, '%s/AsBuilt/LibraryInstances' %
                           Key) and not LibraryList:
                    LibraryList = [None]
                AsBuilt.SetLibraryInstancesList(LibraryList)
                BuildFlagList = []
                for SubItem in XmlList(Item, '%s/AsBuilt/BuildFlags' % Key):
                    BuildFlag = BuildFlagXml()
                    BuildFlagList.append(
                        BuildFlag.FromXml2(SubItem, 'BuildFlags'))
                AsBuilt.SetBuildFlagsList(BuildFlagList)
                AsBuiltList.append(AsBuilt)
            BinaryFile.SetAsBuiltList(AsBuiltList)
        return BinaryFile
Пример #2
0
    def _GenBinaries(self):
        Logger.Debug(2, "Generate %s ..." % DT.TAB_BINARIES)
        BinariesDict = {}

        #
        # Get all Binary data
        #
        BinaryObj = self.Parser.InfBinariesSection.GetBinary()

        BinaryData = BinaryObj.keys()

        #
        # If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section,
        # then the ModuleSurfaceArea.BinaryModule attribute must be set to true. Otherwise, do not use the attribute
        #
        if BinaryObj and not self.Parser.InfSourcesSection.GetSources():
            self.BinaryModule = True
        else:
            self.BinaryModule = False

        BinaryFileObjectList = []
        AsBuildLibraryClassList = []
        AsBuildBuildOptionList = []
        AsBuildIns = AsBuiltObject()
        #
        # Library AsBuild Info
        #
        for LibItem in self.Parser.InfLibraryClassSection.GetLibraryClasses():
            AsBuildLibIns = AsBuildLibraryClassObject()
            AsBuildLibIns.SetLibGuid(LibItem.GetFileGuid())
            AsBuildLibIns.SetLibVersion(LibItem.GetVersion())
            AsBuildLibraryClassList.append(AsBuildLibIns)
        AsBuildIns.SetLibraryInstancesList(AsBuildLibraryClassList)

        #
        # BuildOption AsBuild Info
        #
        for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions(
        ):
            AsBuildBuildOptionList += BuildOptionItem.GetAsBuildList()
        AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList)

        #
        # PatchPcd and PcdEx
        #
        AsBuildIns = self._GenAsBuiltPcds(self.Parser.InfPcdSection.GetPcds(),
                                          AsBuildIns)

        BinariesDict, AsBuildIns, BinaryFileObjectList = GenBinaryData(
            BinaryData, BinaryObj, BinariesDict, AsBuildIns,
            BinaryFileObjectList, self.GetSupArchList(), self.BinaryModule)

        BinariesDict2 = {}
        for Key in BinariesDict:
            ValueList = BinariesDict[Key]
            if len(ValueList) > 1:
                BinariesDict2[Key] = ValueList
            else:
                #
                # if there is no TagName, ToolCode, HelpStr,
                # then do not need to put them into userextension
                #
                (Target, Family, TagName, HelpStr) = ValueList[0]
                if not (Target or Family or TagName or HelpStr):
                    continue
                else:
                    BinariesDict2[Key] = ValueList

        self.SetBinaryFileList(self.GetBinaryFileList() + BinaryFileObjectList)

        if BinariesDict2:
            UserExtension = CommonObject.UserExtensionObject()
            UserExtension.SetBinariesDict(BinariesDict2)
            UserExtension.SetIdentifier('BinaryFileModifiers')
            UserExtension.SetUserID('EDK2')
            self.SetUserExtensionList(self.GetUserExtensionList() +
                                      [UserExtension])
Пример #3
0
    def _GenBinaries(self):
        Logger.Debug(2, "Generate %s ..." % DT.TAB_BINARIES)
        BinariesDict = {}

        #
        # Get all Binary data
        #
        BinaryObj = self.Parser.InfBinariesSection.GetBinary()

        BinaryData = BinaryObj.keys()

        #
        # If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section,
        # then the ModuleSurfaceArea.BinaryModule attribute must be set to true. Otherwise, do not use the attribute
        #
        if BinaryObj and not self.Parser.InfSourcesSection.GetSources():
            self.BinaryModule = True
        else:
            self.BinaryModule = False

        BinaryFileObjectList = []
        AsBuildLibraryClassList = []
        AsBuildBuildOptionList = []
        AsBuildIns = AsBuiltObject()
        #
        # Library AsBuild Info
        #
        for LibItem in self.Parser.InfLibraryClassSection.GetLibraryClasses():
            AsBuildLibIns = AsBuildLibraryClassObject()
            AsBuildLibIns.SetLibGuid(LibItem.GetFileGuid())
            AsBuildLibIns.SetLibVersion(LibItem.GetVersion())
            AsBuildLibIns.SetSupArchList(LibItem.GetSupArchList())
            AsBuildLibraryClassList.append(AsBuildLibIns)
        AsBuildIns.SetLibraryInstancesList(AsBuildLibraryClassList)

        #
        # BuildOption AsBuild Info
        #
        for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions(
        ):
            AsBuildBuildOptionList.append(BuildOptionItem)
        AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList)

        #
        # PatchPcd and PcdEx
        #
        AsBuildIns = self._GenAsBuiltPcds(self.Parser.InfPcdSection.GetPcds(),
                                          AsBuildIns)

        #
        # Parse the DEC file that contains the GUID value of the GUID CName which is used by
        # SUBTYPE_GUID type binary file in the Binaries section in the INF file
        #
        DecObjList = []
        if not self.PackagePath:
            WorkSpace = os.path.normpath(self.WorkSpace)
            TempPath = ModulePath = os.path.normpath(self.ModulePath)
            while ModulePath:
                TempPath = ModulePath
                ModulePath = os.path.dirname(ModulePath)
            PackageName = TempPath
            DecFilePath = os.path.normpath(os.path.join(
                WorkSpace, PackageName))
            if DecFilePath:
                for File in os.listdir(DecFilePath):
                    if File.upper().endswith('.DEC'):
                        DecFileFullPath = os.path.normpath(
                            os.path.join(DecFilePath, File))
                        DecObjList.append(
                            DecPomAlignment(DecFileFullPath, self.WorkSpace))

        BinariesDict, AsBuildIns, BinaryFileObjectList = GenBinaryData(
            BinaryData, BinaryObj,
            BinariesDict, AsBuildIns, BinaryFileObjectList,
            self.GetSupArchList(), self.BinaryModule, DecObjList)

        BinariesDict2 = {}
        for Key in BinariesDict:
            ValueList = BinariesDict[Key]
            if len(ValueList) > 1:
                BinariesDict2[Key] = ValueList
            else:
                #
                # if there is no TagName, ToolCode, HelpStr,
                # then do not need to put them into userextension
                #
                (Target, Family, TagName, HelpStr) = ValueList[0]
                if not (Target or Family or TagName or HelpStr):
                    continue
                else:
                    BinariesDict2[Key] = ValueList

        self.SetBinaryFileList(self.GetBinaryFileList() + BinaryFileObjectList)

        if BinariesDict2:
            UserExtension = CommonObject.UserExtensionObject()
            UserExtension.SetBinariesDict(BinariesDict2)
            UserExtension.SetIdentifier('BinaryFileModifiers')
            UserExtension.SetUserID('EDK2')
            self.SetUserExtensionList(self.GetUserExtensionList() +
                                      [UserExtension])