Esempio n. 1
0
    def GenLibraryClasses(self, ContainerFile):
        EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES)
        LibraryClasses = {}
        #
        # Get all LibraryClasses
        #
        RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS]

        #
        # Go through each arch
        #
        for Arch in self.SupArchList:
            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON:
                    (LibClassName, LibClassIns, Pcd, SupModelList) = GetLibraryClassOfInf([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])
                    MergeArches(LibraryClasses, (LibClassName, LibClassIns, Pcd, SupModelList), Arch)
                    #
                    # Update to Database
                    #
                    if self.IsToDatabase:
                        SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
                                        where ID = %s""" % (self.TblInf.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])
                        self.TblInf.Exec(SqlCommand)

        for Key in LibraryClasses.keys():
            KeyList = Key[0].split(DataType.TAB_VALUE_SPLIT)
            LibraryClass = LibraryClassClass()
            LibraryClass.LibraryClass = Key[0]
            LibraryClass.RecommendedInstance = NormPath(Key[1])
            LibraryClass.FeatureFlag = Key[2]
            LibraryClass.SupArchList = LibraryClasses[Key]
            LibraryClass.SupModuleList = GetSplitValueList(Key[3])
            self.Module.LibraryClasses.append(LibraryClass)
    def GenLibraryClasses(self, ContainerFile):
        EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES)
        LibraryClasses = {}
        #
        # Get all LibraryClasses
        #
        RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS]

        #
        # Go through each arch
        #
        for Arch in self.SupArchList:
            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON:
                    (LibClassName, LibClassIns, Pcd, SupModelList) = GetLibraryClassOfInf([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])
                    MergeArches(LibraryClasses, (LibClassName, LibClassIns, Pcd, SupModelList), Arch)
                    #
                    # Update to Database
                    #
                    if self.IsToDatabase:
                        SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
                                        where ID = %s""" % (self.TblInf.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])
                        self.TblInf.Exec(SqlCommand)

        for Key in LibraryClasses.keys():
            KeyList = Key[0].split(DataType.TAB_VALUE_SPLIT)
            LibraryClass = LibraryClassClass()
            LibraryClass.LibraryClass = Key[0]
            LibraryClass.RecommendedInstance = NormPath(Key[1])
            LibraryClass.FeatureFlag = Key[2]
            LibraryClass.SupArchList = LibraryClasses[Key]
            LibraryClass.SupModuleList = GetSplitValueList(Key[3])
            self.Module.LibraryClasses.append(LibraryClass)
    def GenModuleHeader(self, ContainerFile):
        EdkLogger.debug(2, "Generate ModuleHeader ...")
        File = self.Identification.FileFullPath
        #
        # Update all defines item in database
        #
        RecordSet = self.RecordSet[MODEL_META_DATA_HEADER]
        for Record in RecordSet:
            ValueList = GetSplitValueList(Record[0], TAB_EQUAL_SPLIT)
            if len(ValueList) != 2:
                RaiseParserError(Record[0], 'Defines', ContainerFile, '<Key> = <Value>', Record[2])
            ID, Value1, Value2, Arch, LineNo = Record[3], ValueList[0], ValueList[1], Record[1], Record[2]
            SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
                            where ID = %s""" % (self.TblInf.Table, ConvertToSqlString2(Value1), ConvertToSqlString2(Value2), ID)
            self.TblInf.Exec(SqlCommand)

        for Arch in DataType.ARCH_LIST:
            ModuleHeader = InfHeader()
            ModuleHeader.FileName = self.Identification.FileName
            ModuleHeader.FullPath = self.Identification.FileFullPath
            DefineList = QueryDefinesItem2(self.TblInf, Arch, self.FileID)

            NotProcessedDefineList = []
            for D in DefineList:
                if D[0] in ModuleHeader:
                    ModuleHeader[D[0]] = GetSplitValueList(D[1])[0]
                else:
                    NotProcessedDefineList.append(D)

            if ModuleHeader.ComponentType == "LIBRARY":
                Lib = LibraryClassClass()
                Lib.LibraryClass = ModuleHeader.Name
                Lib.SupModuleList = DataType.SUP_MODULE_LIST
                ModuleHeader.LibraryClass.append(Lib)

            # we need to make some key defines resolved first
            for D in NotProcessedDefineList:
                if D[0] == TAB_INF_DEFINES_LIBRARY_CLASS:
                    List = GetSplitValueList(D[1], DataType.TAB_VALUE_SPLIT, 1)
                    Lib = LibraryClassClass()
                    Lib.LibraryClass = CleanString(List[0])
                    if len(List) == 1:
                        Lib.SupModuleList = DataType.SUP_MODULE_LIST
                    elif len(List) == 2:
                        Lib.SupModuleList = GetSplitValueList(CleanString(List[1]), ' ')
                    ModuleHeader.LibraryClass.append(Lib)
                elif D[0] == TAB_INF_DEFINES_CUSTOM_MAKEFILE:
                    List = D[1].split(DataType.TAB_VALUE_SPLIT)
                    if len(List) == 2:
                        ModuleHeader.CustomMakefile[CleanString(List[0])] = CleanString(List[1])
                    else:
                        RaiseParserError(D[1], 'CUSTOM_MAKEFILE of Defines', File, 'CUSTOM_MAKEFILE=<Family>|<Filename>', D[2])
                elif D[0] == TAB_INF_DEFINES_ENTRY_POINT:
                    Image = ModuleExternImageClass()
                    Image.ModuleEntryPoint = CleanString(D[1])
                    self.Module.ExternImages.append(Image)
                elif D[0] == TAB_INF_DEFINES_UNLOAD_IMAGE:
                    Image = ModuleExternImageClass()
                    Image.ModuleUnloadImage = CleanString(D[1])
                    self.Module.ExternImages.append(Image)
                elif D[0] == TAB_INF_DEFINES_CONSTRUCTOR:
                    LibraryClass = ModuleExternLibraryClass()
                    LibraryClass.Constructor = CleanString(D[1])
                    self.Module.ExternLibraries.append(LibraryClass)
                elif D[0] == TAB_INF_DEFINES_DESTRUCTOR:
                    LibraryClass = ModuleExternLibraryClass()
                    LibraryClass.Destructor = CleanString(D[1])
                    self.Module.ExternLibraries.append(LibraryClass)
                elif D[0] == TAB_INF_DEFINES_DEFINE:
                    List = D[1].split(DataType.TAB_EQUAL_SPLIT)
                    if len(List) != 2:
                        RaiseParserError(Item, 'DEFINE of Defines', File, 'DEFINE <Word> = <Word>', D[2])
                    else:
                        ModuleHeader.Define[CleanString(List[0])] = CleanString(List[1])
                elif D[0] == TAB_INF_DEFINES_SPEC:
                    List = D[1].split(DataType.TAB_EQUAL_SPLIT)
                    if len(List) != 2:
                        RaiseParserError(Item, 'SPEC of Defines', File, 'SPEC <Word> = <Version>', D[2])
                    else:
                        ModuleHeader.Specification[CleanString(List[0])] = CleanString(List[1])

            #
            # Get version of INF
            #
            if ModuleHeader.InfVersion != "":
                # EdkII inf
                VersionNumber = ModuleHeader.VersionNumber
                VersionString = ModuleHeader.VersionString
                if len(VersionNumber) > 0 and len(VersionString) == 0:
                    EdkLogger.warn(2000, 'VERSION_NUMBER depricated; INF file %s should be modified to use VERSION_STRING instead.' % self.Identification.FileFullPath)
                    ModuleHeader.Version = VersionNumber
                if len(VersionString) > 0:
                    if len(VersionNumber) > 0:
                        EdkLogger.warn(2001, 'INF file %s defines both VERSION_NUMBER and VERSION_STRING, using VERSION_STRING' % self.Identification.FileFullPath)
                    ModuleHeader.Version = VersionString
            else:
                # Edk inf
                ModuleHeader.InfVersion = "0x00010000"
                if ModuleHeader.ComponentType in gComponentType2ModuleType:
                    ModuleHeader.ModuleType = gComponentType2ModuleType[ModuleHeader.ComponentType]
                elif ModuleHeader.ComponentType != '':
                    EdkLogger.error("Parser", PARSER_ERROR, "Unsupported Edk component type [%s]" % ModuleHeader.ComponentType, ExtraData=File, RaiseError=EdkLogger.IsRaiseError)

            self.Module.Header[Arch] = ModuleHeader
Esempio n. 4
0
    def GenModuleHeader(self, ContainerFile):
        EdkLogger.debug(2, "Generate ModuleHeader ...")
        File = self.Identification.FileFullPath
        #
        # Update all defines item in database
        #
        RecordSet = self.RecordSet[MODEL_META_DATA_HEADER]
        for Record in RecordSet:
            ValueList = GetSplitValueList(Record[0], TAB_EQUAL_SPLIT)
            if len(ValueList) != 2:
                RaiseParserError(Record[0], 'Defines', ContainerFile,
                                 '<Key> = <Value>', Record[2])
            ID, Value1, Value2, Arch, LineNo = Record[3], ValueList[
                0], ValueList[1], Record[1], Record[2]
            SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
                            where ID = %s""" % (
                self.TblInf.Table, ConvertToSqlString2(Value1),
                ConvertToSqlString2(Value2), ID)
            self.TblInf.Exec(SqlCommand)

        for Arch in DataType.ARCH_LIST:
            ModuleHeader = InfHeader()
            ModuleHeader.FileName = self.Identification.FileName
            ModuleHeader.FullPath = self.Identification.FileFullPath
            DefineList = QueryDefinesItem2(self.TblInf, Arch, self.FileID)

            NotProcessedDefineList = []
            for D in DefineList:
                if D[0] in ModuleHeader:
                    ModuleHeader[D[0]] = GetSplitValueList(D[1])[0]
                else:
                    NotProcessedDefineList.append(D)

            if ModuleHeader.ComponentType == "LIBRARY":
                Lib = LibraryClassClass()
                Lib.LibraryClass = ModuleHeader.Name
                Lib.SupModuleList = DataType.SUP_MODULE_LIST
                ModuleHeader.LibraryClass.append(Lib)

            # we need to make some key defines resolved first
            for D in NotProcessedDefineList:
                if D[0] == TAB_INF_DEFINES_LIBRARY_CLASS:
                    List = GetSplitValueList(D[1], DataType.TAB_VALUE_SPLIT, 1)
                    Lib = LibraryClassClass()
                    Lib.LibraryClass = CleanString(List[0])
                    if len(List) == 1:
                        Lib.SupModuleList = DataType.SUP_MODULE_LIST
                    elif len(List) == 2:
                        Lib.SupModuleList = GetSplitValueList(
                            CleanString(List[1]), ' ')
                    ModuleHeader.LibraryClass.append(Lib)
                elif D[0] == TAB_INF_DEFINES_CUSTOM_MAKEFILE:
                    List = D[1].split(DataType.TAB_VALUE_SPLIT)
                    if len(List) == 2:
                        ModuleHeader.CustomMakefile[CleanString(
                            List[0])] = CleanString(List[1])
                    else:
                        RaiseParserError(
                            D[1], 'CUSTOM_MAKEFILE of Defines', File,
                            'CUSTOM_MAKEFILE=<Family>|<Filename>', D[2])
                elif D[0] == TAB_INF_DEFINES_ENTRY_POINT:
                    Image = ModuleExternImageClass()
                    Image.ModuleEntryPoint = CleanString(D[1])
                    self.Module.ExternImages.append(Image)
                elif D[0] == TAB_INF_DEFINES_UNLOAD_IMAGE:
                    Image = ModuleExternImageClass()
                    Image.ModuleUnloadImage = CleanString(D[1])
                    self.Module.ExternImages.append(Image)
                elif D[0] == TAB_INF_DEFINES_CONSTRUCTOR:
                    LibraryClass = ModuleExternLibraryClass()
                    LibraryClass.Constructor = CleanString(D[1])
                    self.Module.ExternLibraries.append(LibraryClass)
                elif D[0] == TAB_INF_DEFINES_DESTRUCTOR:
                    LibraryClass = ModuleExternLibraryClass()
                    LibraryClass.Destructor = CleanString(D[1])
                    self.Module.ExternLibraries.append(LibraryClass)
                elif D[0] == TAB_INF_DEFINES_DEFINE:
                    List = D[1].split(DataType.TAB_EQUAL_SPLIT)
                    if len(List) != 2:
                        RaiseParserError(Item, 'DEFINE of Defines', File,
                                         'DEFINE <Word> = <Word>', D[2])
                    else:
                        ModuleHeader.Define[CleanString(
                            List[0])] = CleanString(List[1])
                elif D[0] == TAB_INF_DEFINES_SPEC:
                    List = D[1].split(DataType.TAB_EQUAL_SPLIT)
                    if len(List) != 2:
                        RaiseParserError(Item, 'SPEC of Defines', File,
                                         'SPEC <Word> = <Version>', D[2])
                    else:
                        ModuleHeader.Specification[CleanString(
                            List[0])] = CleanString(List[1])

            #
            # Get version of INF
            #
            if ModuleHeader.InfVersion != "":
                # EdkII inf
                VersionNumber = ModuleHeader.VersionNumber
                VersionString = ModuleHeader.VersionString
                if len(VersionNumber) > 0 and len(VersionString) == 0:
                    EdkLogger.warn(
                        2000,
                        'VERSION_NUMBER depricated; INF file %s should be modified to use VERSION_STRING instead.'
                        % self.Identification.FileFullPath)
                    ModuleHeader.Version = VersionNumber
                if len(VersionString) > 0:
                    if len(VersionNumber) > 0:
                        EdkLogger.warn(
                            2001,
                            'INF file %s defines both VERSION_NUMBER and VERSION_STRING, using VERSION_STRING'
                            % self.Identification.FileFullPath)
                    ModuleHeader.Version = VersionString
            else:
                # Edk inf
                ModuleHeader.InfVersion = "0x00010000"
                if ModuleHeader.ComponentType in gComponentType2ModuleType:
                    ModuleHeader.ModuleType = gComponentType2ModuleType[
                        ModuleHeader.ComponentType]
                elif ModuleHeader.ComponentType != '':
                    EdkLogger.error("Parser",
                                    PARSER_ERROR,
                                    "Unsupported Edk component type [%s]" %
                                    ModuleHeader.ComponentType,
                                    ExtraData=File,
                                    RaiseError=EdkLogger.IsRaiseError)

            self.Module.Header[Arch] = ModuleHeader