コード例 #1
0
def GetLibInstanceInfo(String, WorkSpace, LineNo):

    FileGuidString = ""
    VerString = ""

    OrignalString = String
    String = String.strip()
    if not String:
        return None, None
    #
    # Remove "#" characters at the beginning
    #
    String = GetHelpStringByRemoveHashKey(String)
    String = String.strip()

    FileLinesList = GetFileLineContent(String, WorkSpace, LineNo,
                                       OrignalString)

    ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
    ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")

    FileLinesList = ProcessLineExtender(FileLinesList)

    for Line in FileLinesList:
        if ReFindFileGuidPattern.match(Line):
            FileGuidString = Line
        if ReFindVerStringPattern.match(Line):
            VerString = Line

    if FileGuidString:
        FileGuidString = GetSplitValueList(FileGuidString, '=', 1)[1]
    if VerString:
        VerString = GetSplitValueList(VerString, '=', 1)[1]

    return FileGuidString, VerString
コード例 #2
0
def GetLibInstanceInfo(String, WorkSpace, LineNo):
    
    FileGuidString = ""
    VerString = ""
    
    OrignalString = String 
    String = String.strip()
    if not String:
        return None, None
    #
    # Remove "#" characters at the beginning
    #
    String = GetHelpStringByRemoveHashKey(String)
    String = String.strip()
    
    FileLinesList = GetFileLineContent(String, WorkSpace, LineNo, OrignalString)

        
    ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
    ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")
    
    FileLinesList = ProcessLineExtender(FileLinesList)

    for Line in FileLinesList:
        if ReFindFileGuidPattern.match(Line):
            FileGuidString = Line
        if ReFindVerStringPattern.match(Line):
            VerString = Line
    
    if FileGuidString:
        FileGuidString = GetSplitValueList(FileGuidString, '=', 1)[1]
    if VerString:
        VerString = GetSplitValueList(VerString, '=', 1)[1]
        
    return FileGuidString, VerString
コード例 #3
0
def InfAsBuiltBuildOptionParser(SectionString, FileName):
    BuildOptionList = []
    #
    # AsBuild Binary INF file.
    #
    AsBuildOptionFlag = False
    BuildOptionItem = []
    Count = 0
    for Line in SectionString:
        Count += 1
        LineContent = Line[0]
        LineNo = Line[1]

        #
        # The last line
        #
        if len(SectionString) == Count:
            if LineContent.strip().startswith("##") and AsBuildOptionFlag:
                BuildOptionList.append(BuildOptionItem)
                BuildOptionList.append(
                    [GetHelpStringByRemoveHashKey(LineContent)])
            elif LineContent.strip().startswith("#") and AsBuildOptionFlag:
                BuildOptionInfo = GetHelpStringByRemoveHashKey(LineContent)
                BuildOptionItem.append(BuildOptionInfo)
                BuildOptionList.append(BuildOptionItem)
            else:
                if len(BuildOptionItem) > 0:
                    BuildOptionList.append(BuildOptionItem)

            break

        if LineContent.strip() == '':
            AsBuildOptionFlag = False
            continue

        if LineContent.strip().startswith("##") and AsBuildOptionFlag:
            if len(BuildOptionItem) > 0:
                BuildOptionList.append(BuildOptionItem)

            BuildOptionItem = []

        if not LineContent.strip().startswith("#"):
            Logger.Error('InfParser',
                         FORMAT_INVALID,
                         ST.ERR_BO_CONTATIN_ASBUILD_AND_COMMON,
                         File=FileName,
                         Line=LineNo,
                         ExtraData=LineContent)

        if IsAsBuildOptionInfo(LineContent):
            AsBuildOptionFlag = True
            continue

        if AsBuildOptionFlag:
            BuildOptionInfo = GetHelpStringByRemoveHashKey(LineContent)
            BuildOptionItem.append(BuildOptionInfo)

    return BuildOptionList
コード例 #4
0
ファイル: InfAsBuiltProcess.py プロジェクト: rajrakeshdr/asdf
def GetLibInstanceInfo(String, WorkSpace, LineNo, CurrentInfFileName):

    FileGuidString = ""
    VerString = ""

    OrignalString = String
    String = String.strip()
    if not String:
        return None, None
    #
    # Remove "#" characters at the beginning
    #
    String = GetHelpStringByRemoveHashKey(String)
    String = String.strip()

    #
    # To deal with library instance specified by GUID and version
    #
    RegFormatGuidPattern = re.compile("\s*([0-9a-fA-F]){8}-"
                                      "([0-9a-fA-F]){4}-"
                                      "([0-9a-fA-F]){4}-"
                                      "([0-9a-fA-F]){4}-"
                                      "([0-9a-fA-F]){12}\s*")
    VersionPattern = re.compile('[\t\s]*\d+(\.\d+)?[\t\s]*')
    GuidMatchedObj = RegFormatGuidPattern.search(String)

    if String.upper().startswith(
            'GUID') and GuidMatchedObj and 'Version' in String:
        VersionStr = String[String.upper().find('VERSION') + 8:]
        VersionMatchedObj = VersionPattern.search(VersionStr)
        if VersionMatchedObj:
            Guid = GuidMatchedObj.group().strip()
            Version = VersionMatchedObj.group().strip()
            return GetGuidVerFormLibInstance(Guid, Version, WorkSpace,
                                             CurrentInfFileName)

    #
    # To deal with library instance specified by file name
    #
    FileLinesList = GetFileLineContent(String, WorkSpace, LineNo,
                                       OrignalString)

    ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
    ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")

    for Line in FileLinesList:
        if ReFindFileGuidPattern.match(Line):
            FileGuidString = Line
        if ReFindVerStringPattern.match(Line):
            VerString = Line

    if FileGuidString:
        FileGuidString = GetSplitValueList(FileGuidString, '=', 1)[1]
    if VerString:
        VerString = GetSplitValueList(VerString, '=', 1)[1]

    return FileGuidString, VerString
コード例 #5
0
ファイル: InfAsBuiltProcess.py プロジェクト: lersek/edk2
def GetLibInstanceInfo(String, WorkSpace, LineNo, CurrentInfFileName):

    FileGuidString = ""
    VerString = ""

    OriginalString = String
    String = String.strip()
    if not String:
        return None, None
    #
    # Remove "#" characters at the beginning
    #
    String = GetHelpStringByRemoveHashKey(String)
    String = String.strip()

    #
    # To deal with library instance specified by GUID and version
    #
    RegFormatGuidPattern = re.compile("\s*([0-9a-fA-F]){8}-"
                                       "([0-9a-fA-F]){4}-"
                                       "([0-9a-fA-F]){4}-"
                                       "([0-9a-fA-F]){4}-"
                                       "([0-9a-fA-F]){12}\s*")
    VersionPattern = re.compile('[\t\s]*\d+(\.\d+)?[\t\s]*')
    GuidMatchedObj = RegFormatGuidPattern.search(String)

    if String.upper().startswith('GUID') and GuidMatchedObj and 'Version' in String:
        VersionStr = String[String.upper().find('VERSION') + 8:]
        VersionMatchedObj = VersionPattern.search(VersionStr)
        if VersionMatchedObj:
            Guid = GuidMatchedObj.group().strip()
            Version = VersionMatchedObj.group().strip()
            return Guid, Version

    #
    # To deal with library instance specified by file name
    #
    FileLinesList = GetFileLineContent(String, WorkSpace, LineNo, OriginalString)


    ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$")
    ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$")

    for Line in FileLinesList:
        if ReFindFileGuidPattern.match(Line):
            FileGuidString = Line
        if ReFindVerStringPattern.match(Line):
            VerString = Line

    if FileGuidString:
        FileGuidString = GetSplitValueList(FileGuidString, '=', 1)[1]
    if VerString:
        VerString = GetSplitValueList(VerString, '=', 1)[1]

    return FileGuidString, VerString
コード例 #6
0
ファイル: InfPomAlignment.py プロジェクト: aspirefhaha/vbox50
    def _GenLibraryClasses(self):
        Logger.Debug(2, "Generate %s ..." % DT.TAB_LIBRARY_CLASSES)
        if not GlobalData.gIS_BINARY_INF:
            #
            # Get all LibraryClasses
            #
            LibClassObj = self.Parser.InfLibraryClassSection.LibraryClasses
            Keys = LibClassObj.keys()

            for Key in Keys:
                LibraryClassData = LibClassObj[Key]
                for Item in LibraryClassData:
                    LibraryClass = CommonObject.LibraryClassObject()
                    LibraryClass.SetUsage(DT.USAGE_ITEM_CONSUMES)
                    LibraryClass.SetLibraryClass(Item.GetLibName())
                    LibraryClass.SetRecommendedInstance(None)
                    LibraryClass.SetFeatureFlag(Item.GetFeatureFlagExp())
                    LibraryClass.SetSupArchList(
                        ConvertArchList(Item.GetSupArchList()))
                    LibraryClass.SetSupModuleList(Item.GetSupModuleList())
                    HelpStringObj = Item.GetHelpString()

                    if HelpStringObj != None:
                        CommentString = GetHelpStringByRemoveHashKey(
                            HelpStringObj.HeaderComments +
                            HelpStringObj.TailComments)
                        HelpTextHeaderObj = CommonObject.TextObject()
                        HelpTextHeaderObj.SetString(CommentString)
                        LibraryClass.SetHelpTextList([HelpTextHeaderObj])

                    self.SetLibraryClassList(self.GetLibraryClassList() +
                                             [LibraryClass])
コード例 #7
0
ファイル: InfPcdObject.py プロジェクト: mcb30/edk2
    def SetAsBuildPcds(self, PcdContent, KeysList=None, PackageInfo=None):
        for PcdItem in PcdContent:
            PcdItemObj = InfPcdItem()
            CommentList = PcdItem[1]
            CurrentLineOfPcdItem = PcdItem[2]
            PcdItem = PcdItem[0]
            CommentString = ''
            for CommmentLine in CommentList:
                CommentString += GetHelpStringByRemoveHashKey(CommmentLine)

            PcdItemObj.SetHelpStringList(CommentString)
            PcdItemObj.SetItemType(KeysList[0][0])
            #
            # Set PcdTokenSpaceCName and CName
            #
            PcdItemObj = SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj)
            #
            # Set Value/DatumType/MaxDatumSize/Token
            #
            PcdItemObj = SetValueDatumTypeMaxSizeToken(PcdItem,
                                                       CurrentLineOfPcdItem,
                                                       PcdItemObj,
                                                       KeysList[0][1],
                                                       PackageInfo)

            PcdTypeItem = KeysList[0][0]
            if self.Pcds.has_key((PcdTypeItem, PcdItemObj)):
                PcdsList = self.Pcds[PcdTypeItem, PcdItemObj]
                PcdsList.append(PcdItemObj)
                self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
            else:
                PcdsList = []
                PcdsList.append(PcdItemObj)
                self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
コード例 #8
0
    def SetAsBuildPcds(self, PcdContent, KeysList=None, PackageInfo=None):
        for PcdItem in PcdContent:
            PcdItemObj = InfPcdItem()
            CommentList = PcdItem[1]
            CurrentLineOfPcdItem = PcdItem[2]
            PcdItem = PcdItem[0]
            CommentString = ''

            for CommentLine in CommentList:
                CommentString = GetHelpStringByRemoveHashKey(CommentLine)
                CommentItemIns = InfPcdItemCommentContent()
                CommentItemIns.SetHelpStringItem(CommentString)
                CommentItemIns.SetUsageItem(CommentString)
                PcdItemObj.SetHelpStringList(PcdItemObj.GetHelpStringList() +
                                             [CommentItemIns])
                if PcdItemObj.GetValidUsage():
                    PcdItemObj.SetValidUsage(PcdItemObj.GetValidUsage() +
                                             DT.TAB_VALUE_SPLIT +
                                             CommentString)
                else:
                    PcdItemObj.SetValidUsage(CommentString)

            PcdItemObj.SetItemType(KeysList[0][0])
            #
            # Set PcdTokenSpaceCName and CName
            #
            PcdItemObj = SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj)
            #
            # Set Value/DatumType/OffSet/Token
            #
            PcdItemObj = SetValueDatumTypeMaxSizeToken(PcdItem,
                                                       CurrentLineOfPcdItem,
                                                       PcdItemObj,
                                                       KeysList[0][1],
                                                       PackageInfo)

            PcdTypeItem = KeysList[0][0]
            if self.Pcds.has_key((PcdTypeItem, PcdItemObj)):
                PcdsList = self.Pcds[PcdTypeItem, PcdItemObj]
                PcdsList.append(PcdItemObj)
                self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
            else:
                PcdsList = []
                PcdsList.append(PcdItemObj)
                self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
コード例 #9
0
ファイル: InfPomAlignment.py プロジェクト: aspirefhaha/vbox50
    def _GenDepexes(self):
        Logger.Debug(2, "Generate %s ..." % DT.TAB_DEPEX)

        PEI_LIST = [DT.SUP_MODULE_PEIM]
        SMM_LIST = [DT.SUP_MODULE_DXE_SMM_DRIVER]
        DXE_LIST = [
            DT.SUP_MODULE_DXE_DRIVER, DT.SUP_MODULE_DXE_SAL_DRIVER,
            DT.SUP_MODULE_DXE_RUNTIME_DRIVER
        ]

        IsLibraryClass = self.GetIsLibrary()
        #
        # Get all Depexes
        #
        DepexData = self.Parser.InfDepexSection.GetDepex()
        SmmDepexList = []
        DxeDepexList = []
        PeiDepexList = []
        for Depex in DepexData:
            ModuleType = Depex.GetModuleType()
            ModuleTypeList = []
            if IsLibraryClass:
                if not self.GetIsLibraryModList():
                    Logger.Error(
                        "\nMkPkg",
                        PARSER_ERROR,
                        ST.
                        ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_LIBRARY_CLASS,
                        self.GetFullPath(),
                        RaiseError=True)
                if ModuleType and ModuleType not in self.GetIsLibraryModList():
                    Logger.Error(
                        "\nMkPkg",
                        PARSER_ERROR,
                        ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED,
                        self.GetFullPath(),
                        RaiseError=True)
                if ModuleType:
                    ModuleTypeList = [ModuleType]
                else:
                    for ModuleTypeInList in self.GetIsLibraryModList():
                        if ModuleTypeInList in DT.VALID_DEPEX_MODULE_TYPE_LIST:
                            ModuleTypeList.append(ModuleTypeInList)
                if not ModuleTypeList:
                    Logger.Error(
                        "\nMkPkg",
                        PARSER_ERROR,
                        ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED,
                        self.GetFullPath(),
                        RaiseError=True)
            else:
                if not ModuleType:
                    ModuleType = self.ModuleType
                if ModuleType not in DT.VALID_DEPEX_MODULE_TYPE_LIST:
                    Logger.Error(
                        "\nMkPkg",
                        PARSER_ERROR,
                        ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR %
                        (ModuleType),
                        self.GetFullPath(),
                        RaiseError=True)
                if ModuleType != self.ModuleType:
                    Logger.Error(
                        "\nMkPkg",
                        PARSER_ERROR,
                        ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED,
                        self.GetFullPath(),
                        RaiseError=True)
                ModuleTypeList = [ModuleType]
            for ModuleType in ModuleTypeList:
                DepexIns = DepexObject()
                DepexIns.SetDepex(Depex.GetDepexContent())
                if IsLibraryClass:
                    DepexIns.SetModuleType(ModuleType)
                else:
                    if Depex.GetModuleType():
                        DepexIns.SetModuleType(Depex.GetModuleType())
                DepexIns.SetSupArchList(ConvertArchList([Depex.GetSupArch()]))
                DepexIns.SetFeatureFlag(Depex.GetFeatureFlagExp())
                if Depex.HelpString:
                    HelpIns = CommonObject.TextObject()
                    HelpIns.SetString(
                        GetHelpStringByRemoveHashKey(Depex.HelpString))
                    DepexIns.SetHelpText(HelpIns)

                if ModuleType in SMM_LIST:
                    SmmDepexList.append(DepexIns)
                if ModuleType in DXE_LIST:
                    DxeDepexList.append(DepexIns)
                if ModuleType in PEI_LIST:
                    PeiDepexList.append(DepexIns)
                if ModuleType == DT.SUP_MODULE_UEFI_DRIVER:
                    if IsLibraryClass:
                        DxeDepexList.append(DepexIns)
                    else:
                        Logger.Error(
                            "\nMkPkg",
                            PARSER_ERROR,
                            ST.ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_DRIVER,
                            self.GetFullPath(),
                            RaiseError=True)

            #End of for ModuleType in ModuleTypeList
            self._GenDepexesList(SmmDepexList, DxeDepexList, PeiDepexList)