Home | History | Annotate | Download | only in PomAdapter
      1 ## @file InfPomAlignment.py

      2 # This file contained the adapter for convert INF parser object to POM Object

      3 #

      4 # Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>

      5 #

      6 # This program and the accompanying materials are licensed and made available 

      7 # under the terms and conditions of the BSD License which accompanies this 

      8 # distribution. The full text of the license may be found at 

      9 # http://opensource.org/licenses/bsd-license.php

     10 #

     11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,

     12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

     13 #

     14 '''
     15 InfPomAlignment
     16 '''
     17 ##

     18 # Import modules

     19 #

     20 import os.path
     21 from Logger import StringTable as ST
     22 import Logger.Log as Logger
     23 from Library.String import FORMAT_INVALID
     24 from Library.String import PARSER_ERROR
     25 from Library.String import NormPath
     26 from Library.String import GetSplitValueList
     27 from Library.Misc import ConvertVersionToDecimal
     28 from Library.Misc import GetHelpStringByRemoveHashKey
     29 from Library.Misc import ConvertArchList
     30 from Library.Misc import GetRelativePath
     31 from Library.Misc import PathClass
     32 from Library.Parsing import GetPkgInfoFromDec
     33 from Library.UniClassObject import UniFileClassObject
     34 from Library.UniClassObject import ConvertSpecialUnicodes
     35 from Library.UniClassObject import GetLanguageCode1766
     36 from Library import DataType as DT
     37 from Library import GlobalData
     38 from Library.ParserValidate import IsValidPath
     39 from Object.POM import CommonObject
     40 from Object.POM.ModuleObject import ModuleObject
     41 from Object.POM.ModuleObject import ExternObject
     42 from Object.POM.ModuleObject import HobObject
     43 from Object.POM.ModuleObject import EventObject
     44 from Object.POM.ModuleObject import BootModeObject
     45 from Object.POM.ModuleObject import PackageDependencyObject
     46 from Object.POM.ModuleObject import SourceFileObject
     47 from Object.POM.ModuleObject import DepexObject
     48 from Object.POM.ModuleObject import AsBuildLibraryClassObject
     49 from Object.POM.ModuleObject import AsBuiltObject
     50 from PomAdapter.InfPomAlignmentMisc import GenModuleHeaderUserExt
     51 from PomAdapter.InfPomAlignmentMisc import GenBinaryData
     52 from Parser import InfParser
     53 from PomAdapter.DecPomAlignment import DecPomAlignment
     54 from Common.MultipleWorkspace import MultipleWorkspace as mws
     55 
     56 ## InfPomAlignment

     57 #

     58 # Inherit from ModuleObject

     59 #

     60 class InfPomAlignment(ModuleObject):
     61     ## Construct of InfPomAlignment

     62     # Skip means that UPT don't care the syntax of INF, this may be the not 

     63     # distributed INF files during creation or the INF files checked for 

     64     # dependency rule during remove.

     65     #

     66     def __init__(self, FileName, WorkSpace=None, PackagePath='', Skip=False):
     67         ModuleObject.__init__(self)
     68         self.Parser = None
     69         self.FileName = FileName
     70         self.WorkSpace = WorkSpace
     71         self.CombinePath = ''
     72         self.LibModuleTypeList = []
     73         self.FullPath = ''
     74         self.ModulePath = ''
     75         self.WorkspaceDir = " "
     76         self.CustomMakefile = []
     77         self.UniFileClassObject = None
     78         self.SetPackagePath(PackagePath)
     79         #

     80         # Call GenInfPomObjects function to fill POM object.

     81         #

     82         if Skip:
     83             OrigConfig = Logger.SUPRESS_ERROR
     84             Logger.SUPRESS_ERROR = True
     85             try:
     86                 self._GenInfPomObjects(Skip)
     87             finally:
     88                 Logger.SUPRESS_ERROR = OrigConfig
     89         else:
     90             self._GenInfPomObjects(Skip)
     91 
     92     ##

     93     # Generate all POM objects, the original input comes 

     94     # from INF parser's output

     95     #

     96     def _GenInfPomObjects(self, Skip):
     97         #

     98         # Call INF Parser to get information from INF file  

     99         #

    100         self.Parser = InfParser.InfParser(self.FileName, self.WorkSpace)
    101         self.FullPath = self.Parser.FullPath
    102         self.GetFullPath()
    103         self._GenModuleHeader()
    104         #

    105         # Call GenBinaries after Module Header for Binary INF consideration.

    106         #

    107         self._GenBinaries()
    108         self._GenBuildOptions()
    109         self._GenLibraryClasses()
    110         self._GenPackages(Skip)
    111         self._GenPcds()
    112         self._GenSources()
    113         self._GenUserExtensions()
    114         self._GenGuidProtocolPpis(DT.TAB_GUIDS)
    115         self._GenGuidProtocolPpis(DT.TAB_PROTOCOLS)
    116         self._GenGuidProtocolPpis(DT.TAB_PPIS)
    117         self._GenDepexes()
    118 
    119     ## Convert [Defines] section content to InfDefObject

    120     #

    121     # Convert [Defines] section content to InfDefObject

    122     #

    123     # @param Defines        The content under [Defines] section

    124     # @param ModuleHeader   An object of ModuleHeaderClass

    125     # @param Arch           The supported ARCH

    126     #

    127     def _GenModuleHeader(self):
    128         Logger.Debug(2, "Generate ModuleHeader ...")
    129         #

    130         # Get all defines information form InfParser Object

    131         #

    132         RecordSet = self.Parser.InfDefSection.Defines
    133         #

    134         # Should only have one ArchString Item.

    135         #

    136         ArchString = RecordSet.keys()[0]
    137         ArchList = GetSplitValueList(ArchString, ' ')
    138         ArchList = ConvertArchList(ArchList)
    139         HasCalledFlag = False
    140         #

    141         # Get data from Sdict()

    142         #

    143         ValueList = RecordSet[ArchString]
    144         self.SetFileName(self.FileName)
    145         self.SetFullPath(self.FullPath)
    146         #

    147         # The INF's filename (without the directory path or the extension) 

    148         # must be used for the value of the 

    149         # ModuleSurfaceArea.Header.Name element

    150         #

    151         self.SetName(os.path.splitext(os.path.basename(self.FileName))[0])
    152         self.WorkspaceDir = " "
    153         #

    154         # CombinePath and ModulePath

    155         #

    156         CombinePath = GetRelativePath(self.FullPath, self.WorkSpace)
    157         self.SetCombinePath(CombinePath)
    158         ModulePath = os.path.split(CombinePath)[0]
    159         ModuleRelativePath = ModulePath
    160         if self.GetPackagePath() != '':
    161             ModuleRelativePath = GetRelativePath(ModulePath, self.GetPackagePath())
    162         self.SetModulePath(ModuleRelativePath)
    163         #

    164         # For Define Seciton Items.

    165         #

    166         DefineObj = ValueList
    167         #

    168         # Convert UEFI/PI version to decimal number

    169         #

    170         if DefineObj.GetUefiSpecificationVersion() != None:
    171             __UefiVersion = DefineObj.GetUefiSpecificationVersion().GetValue()
    172             __UefiVersion = ConvertVersionToDecimal(__UefiVersion)
    173             self.SetUefiSpecificationVersion(str(__UefiVersion))
    174         if DefineObj.GetPiSpecificationVersion() != None:
    175             __PiVersion = DefineObj.GetPiSpecificationVersion().GetValue()
    176             __PiVersion = ConvertVersionToDecimal(__PiVersion)
    177 
    178             self.SetPiSpecificationVersion(str(__PiVersion))
    179         SpecList = DefineObj.GetSpecification()
    180         NewSpecList = []
    181         for SpecItem in SpecList:
    182             NewSpecList.append((SpecItem[0], ConvertVersionToDecimal(SpecItem[1])))
    183         self.SetSpecList(NewSpecList)
    184 
    185         #

    186         # must exist items in INF define section

    187         # MODULE_TYPE/BASE_NAME/INF_VERSION/FILE_GUID/VERSION_STRING 

    188         #

    189         if DefineObj.GetModuleType() == None:
    190             Logger.Error("InfParser", FORMAT_INVALID,
    191                          ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("MODULE_TYPE"), File=self.FullPath)
    192         else:
    193             self.SetModuleType(DefineObj.GetModuleType().GetValue())
    194             ModuleType = DefineObj.GetModuleType().GetValue()
    195             if ModuleType:
    196                 #

    197                 # Drivers and applications are not allowed to have a MODULE_TYPE of "BASE". Only 

    198                 # libraries are permitted to a have a MODULE_TYPE of "BASE".

    199                 #

    200                 if len(DefineObj.LibraryClass) == 0 and ModuleType == 'BASE':
    201                     Logger.Error("InfParser",
    202                                  FORMAT_INVALID,
    203                                  ST.ERR_INF_PARSER_MODULETYPE_INVALID,
    204                                  File=self.FullPath,
    205                                  Line=DefineObj.ModuleType.CurrentLine.LineNo,
    206                                  ExtraData=DefineObj.ModuleType.CurrentLine.LineString)
    207                 self.LibModuleTypeList.append(ModuleType)
    208         if DefineObj.GetBaseName() == None:
    209             Logger.Error("InfParser", FORMAT_INVALID,
    210                          ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("BASE_NAME"), File=self.FullPath)
    211         else:
    212             self.SetBaseName(DefineObj.GetBaseName().GetValue())
    213         if DefineObj.GetModuleUniFileName():
    214             self.UniFileClassObject = UniFileClassObject([PathClass(DefineObj.GetModuleUniFileName())])
    215         else:
    216             self.UniFileClassObject = None
    217         if DefineObj.GetInfVersion() == None:
    218             Logger.Error("InfParser", FORMAT_INVALID,
    219                          ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("INF_VERSION"), File=self.FullPath)
    220         else:
    221             self.SetVersion(DefineObj.GetInfVersion().GetValue())
    222         if DefineObj.GetFileGuid() == None:
    223             Logger.Error("InfParser", FORMAT_INVALID,
    224                          ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("FILE_GUID"), File=self.FullPath)
    225         else:
    226             self.SetGuid(DefineObj.GetFileGuid().GetValue())
    227         if DefineObj.GetVersionString() == None:
    228             #

    229             # VERSION_STRING is missing from the [Defines] section, tools must assume that the module's version is 0.

    230             #

    231             self.SetVersion('0')
    232         else:
    233             #

    234             # Get version of INF

    235             #

    236             if DefineObj.GetVersionString().GetValue() != "":
    237                 #

    238                 # EDK2 inf

    239                 #

    240                 VersionString = DefineObj.GetVersionString().GetValue()
    241                 if len(VersionString) > 0:
    242                     VersionString = ConvertVersionToDecimal(VersionString)
    243                     self.SetVersion(VersionString)
    244             else:
    245                 #

    246                 # EDK1 inf

    247                 #

    248                 Logger.Error("Parser", PARSER_ERROR, ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF, ExtraData=self.FullPath,
    249                              RaiseError=Logger.IS_RAISE_ERROR)
    250         #

    251         # if there is Shadow, Should judge the MODULE_TYPE in 

    252         # SEC, PEI_CORE and PEIM

    253         #

    254         if DefineObj.GetShadow():
    255             ModuleTypeValue = DefineObj.GetModuleType().GetValue()
    256             if not (ModuleTypeValue == 'SEC' or ModuleTypeValue == 'PEI_CORE' or ModuleTypeValue == 'PEIM'):
    257                 Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SHADOW_INVALID, File=self.FullPath)
    258 
    259         if DefineObj.GetPcdIsDriver() != None:
    260             self.SetPcdIsDriver(DefineObj.GetPcdIsDriver().GetValue())
    261         #

    262         # LIBRARY_CLASS

    263         #

    264         self._GenModuleHeaderLibClass(DefineObj, ArchList)
    265         #

    266         # CUSTOM_MAKEFILE

    267         #

    268         self.CustomMakefile = DefineObj.GetCustomMakefile()
    269         #

    270         # Externs in Defines section

    271         # Only one define section, so just call once.

    272         #

    273         if not HasCalledFlag:
    274             self._GenModuleHeaderExterns(DefineObj)
    275             HasCalledFlag = True
    276         #

    277         # each module has only one module header

    278         #

    279         self.SetSupArchList(ArchList)
    280         #

    281         # Get Hob/BootMode/EventList information

    282         #

    283         self._GenSpecialComments()
    284         #

    285         # put all define statement into user-extension sections

    286         #     

    287         DefinesDictNew = GenModuleHeaderUserExt(DefineObj, ArchString)
    288         if DefinesDictNew:
    289             UserExtension = CommonObject.UserExtensionObject()
    290             UserExtension.SetDefinesDict(DefinesDictNew)
    291             UserExtension.SetIdentifier('DefineModifiers')
    292             UserExtension.SetUserID('EDK2')
    293             self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
    294         #

    295         # Get all meta-file header information

    296         # the record is list of items formated: 

    297         # [LineValue, Arch, StartLine, ID, Third]

    298         #

    299         InfHeaderObj = self.Parser.InfHeader
    300         #

    301         # Put header information into POM object

    302         #

    303         if self.UniFileClassObject:
    304             Lang = DT.TAB_LANGUAGE_EN_X
    305         else:
    306             Lang = DT.TAB_LANGUAGE_EN_US
    307         if InfHeaderObj.GetAbstract():
    308             self.SetAbstract((Lang, InfHeaderObj.GetAbstract()))
    309         if InfHeaderObj.GetDescription():
    310             self.SetDescription((Lang, InfHeaderObj.GetDescription()))
    311         if InfHeaderObj.GetCopyright():
    312             self.SetCopyright(('', InfHeaderObj.GetCopyright()))
    313         if InfHeaderObj.GetLicense():
    314             self.SetLicense(('', InfHeaderObj.GetLicense()))
    315         #

    316         # Put Binary header information into POM object

    317         #

    318         InfBinaryHeaderObj = self.Parser.InfBinaryHeader
    319         if InfBinaryHeaderObj.GetAbstract():
    320             self.SetBinaryHeaderAbstract((Lang, InfBinaryHeaderObj.GetAbstract()))
    321         if InfBinaryHeaderObj.GetDescription():
    322             self.SetBinaryHeaderDescription((Lang, InfBinaryHeaderObj.GetDescription()))
    323         if InfBinaryHeaderObj.GetCopyright():
    324             self.SetBinaryHeaderCopyright(('', InfBinaryHeaderObj.GetCopyright()))
    325         if InfBinaryHeaderObj.GetLicense():
    326             self.SetBinaryHeaderLicense(('', InfBinaryHeaderObj.GetLicense()))
    327 
    328     ## GenModuleHeaderLibClass

    329     #

    330     #

    331     def _GenModuleHeaderLibClass(self, DefineObj, ArchList):
    332         LibraryList = DefineObj.GetLibraryClass()
    333         for LibraryItem in LibraryList:
    334             Lib = CommonObject.LibraryClassObject()
    335             Lib.SetLibraryClass(LibraryItem.GetLibraryName())
    336             Lib.SetUsage(DT.USAGE_ITEM_PRODUCES)
    337             SupModuleList = LibraryItem.GetTypes()
    338             self.LibModuleTypeList += SupModuleList
    339             Lib.SetSupModuleList(SupModuleList)
    340             Lib.SetSupArchList(ArchList)
    341             self.SetLibraryClassList(self.GetLibraryClassList() + [Lib])
    342             self.SetIsLibrary(True)
    343             self.SetIsLibraryModList(self.GetIsLibraryModList() + SupModuleList)
    344 
    345     ## GenModuleHeaderExterns

    346     #

    347     #

    348     def _GenModuleHeaderExterns(self, DefineObj):
    349         EntryPointList = DefineObj.GetEntryPoint()
    350         for EntryPoint in EntryPointList:
    351             Image = ExternObject()
    352             Image.SetEntryPoint(EntryPoint.GetCName())
    353             #

    354             # Future enhancement

    355             #

    356             self.SetExternList(self.GetExternList() + [Image])
    357         #

    358         # UNLOAD_IMAGE

    359         # 

    360         UnloadImageList = DefineObj.GetUnloadImages()
    361         for UnloadImage in UnloadImageList:
    362             Image = ExternObject()
    363             #

    364             # Future enhancement

    365             #                

    366             Image.SetUnloadImage(UnloadImage.GetCName())
    367             self.SetExternList(self.GetExternList() + [Image])
    368         #

    369         # CONSTRUCTOR

    370         #

    371         ConstructorList = DefineObj.GetConstructor()
    372         for ConstructorItem in ConstructorList:
    373             Image = ExternObject()
    374             #

    375             # Future enhancement

    376             #                  

    377             Image.SetConstructor(ConstructorItem.GetCName())
    378             self.SetExternList(self.GetExternList() + [Image])
    379         #

    380         # DESTRUCTOR

    381         #

    382         DestructorList = DefineObj.GetDestructor()
    383         for DestructorItem in DestructorList:
    384             Image = ExternObject()
    385             #

    386             # Future enhancement

    387             #                

    388             Image.SetDestructor(DestructorItem.GetCName())
    389             self.SetExternList(self.GetExternList() + [Image])
    390 
    391     ## GenModuleHeaderExterns

    392     # BootMode/HOB/Event

    393     #

    394     def _GenSpecialComments(self):
    395         SpecialCommentsList = self.Parser.InfSpecialCommentSection.GetSpecialComments()
    396         for Key in SpecialCommentsList:
    397             if Key == DT.TYPE_HOB_SECTION:
    398                 HobList = []
    399                 for Item in SpecialCommentsList[Key]:
    400                     Hob = HobObject()
    401                     Hob.SetHobType(Item.GetHobType())
    402                     Hob.SetUsage(Item.GetUsage())
    403                     Hob.SetSupArchList(Item.GetSupArchList())
    404                     if Item.GetHelpString():
    405                         HelpTextObj = CommonObject.TextObject()
    406                         if self.UniFileClassObject:
    407                             HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
    408                         HelpTextObj.SetString(Item.GetHelpString())
    409                         Hob.SetHelpTextList([HelpTextObj])
    410                     HobList.append(Hob)
    411                 self.SetHobList(HobList)
    412             elif Key == DT.TYPE_EVENT_SECTION:
    413                 EventList = []
    414                 for Item in SpecialCommentsList[Key]:
    415                     Event = EventObject()
    416                     Event.SetEventType(Item.GetEventType())
    417                     Event.SetUsage(Item.GetUsage())
    418                     if Item.GetHelpString():
    419                         HelpTextObj = CommonObject.TextObject()
    420                         if self.UniFileClassObject:
    421                             HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
    422                         HelpTextObj.SetString(Item.GetHelpString())
    423                         Event.SetHelpTextList([HelpTextObj])
    424                     EventList.append(Event)
    425                 self.SetEventList(EventList)
    426             elif Key == DT.TYPE_BOOTMODE_SECTION:
    427                 BootModeList = []
    428                 for Item in SpecialCommentsList[Key]:
    429                     BootMode = BootModeObject()
    430                     BootMode.SetSupportedBootModes(Item.GetSupportedBootModes())
    431                     BootMode.SetUsage(Item.GetUsage())
    432                     if Item.GetHelpString():
    433                         HelpTextObj = CommonObject.TextObject()
    434                         if self.UniFileClassObject:
    435                             HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
    436                         HelpTextObj.SetString(Item.GetHelpString())
    437                         BootMode.SetHelpTextList([HelpTextObj])
    438                     BootModeList.append(BootMode)
    439                 self.SetBootModeList(BootModeList)
    440 
    441     ## GenBuildOptions

    442     #

    443     # Gen BuildOptions of Inf

    444     # [<Family>:]<ToolFlag>=Flag

    445     #

    446     #

    447     def _GenBuildOptions(self):
    448         Logger.Debug(2, "Generate %s ..." % DT.TAB_BUILD_OPTIONS)
    449         #

    450         # Get all BuildOptions

    451         #

    452         BuildOptionsList = self.Parser.InfBuildOptionSection.GetBuildOptions()
    453         if not GlobalData.gIS_BINARY_INF:
    454             BuildOptionDict = {}
    455             for BuildOptionObj in BuildOptionsList:
    456                 ArchList = BuildOptionObj.GetSupArchList()
    457                 ArchList = ConvertArchList(ArchList)
    458                 BuildOptionsContent = BuildOptionObj.GetContent()
    459                 ArchString = ' '.join(ArchList)
    460                 if not BuildOptionsContent:
    461                     continue
    462                 BuildOptionDict[ArchString] = BuildOptionsContent
    463             if not BuildOptionDict:
    464                 return
    465             UserExtension = CommonObject.UserExtensionObject()
    466             UserExtension.SetBuildOptionDict(BuildOptionDict)
    467             UserExtension.SetIdentifier('BuildOptionModifiers')
    468             UserExtension.SetUserID('EDK2')
    469             self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
    470         else:
    471             #

    472             # Not process this information, will be processed in GenBinaries()

    473             #

    474             pass
    475 
    476     ## GenLibraryClasses

    477     #

    478     # Get LibraryClass of Inf

    479     # <LibraryClassKeyWord>|<LibraryInstance>

    480     #

    481     # @param ContainerFile: The Inf file full path

    482     #

    483     def _GenLibraryClasses(self):
    484         Logger.Debug(2, "Generate %s ..." % DT.TAB_LIBRARY_CLASSES)
    485         if not GlobalData.gIS_BINARY_INF:
    486             #

    487             # Get all LibraryClasses

    488             #

    489             LibClassObj = self.Parser.InfLibraryClassSection.LibraryClasses
    490             Keys = LibClassObj.keys()
    491             for Key in Keys:
    492                 LibraryClassData = LibClassObj[Key]
    493                 for Item in LibraryClassData:
    494                     LibraryClass = CommonObject.LibraryClassObject()
    495                     LibraryClass.SetUsage(DT.USAGE_ITEM_CONSUMES)
    496                     LibraryClass.SetLibraryClass(Item.GetLibName())
    497                     LibraryClass.SetRecommendedInstance(None)
    498                     LibraryClass.SetFeatureFlag(Item.GetFeatureFlagExp())
    499                     LibraryClass.SetSupArchList(ConvertArchList(Item.GetSupArchList()))
    500                     LibraryClass.SetSupModuleList(Item.GetSupModuleList())
    501                     HelpStringObj = Item.GetHelpString()
    502                     if HelpStringObj != None:
    503                         CommentString = GetHelpStringByRemoveHashKey(HelpStringObj.HeaderComments +
    504                                                                      HelpStringObj.TailComments)
    505                         HelpTextHeaderObj = CommonObject.TextObject()
    506                         if self.UniFileClassObject:
    507                             HelpTextHeaderObj.SetLang(DT.TAB_LANGUAGE_EN_X)
    508                         HelpTextHeaderObj.SetString(CommentString)
    509                         LibraryClass.SetHelpTextList([HelpTextHeaderObj])
    510                     self.SetLibraryClassList(self.GetLibraryClassList() + [LibraryClass])
    511 
    512     ## GenPackages

    513     #

    514     # Gen Packages of Inf

    515     #

    516     #

    517     # @param ContainerFile: The Inf file full path

    518     #

    519     def _GenPackages(self, Skip):
    520         Logger.Debug(2, "Generate %s ..." % DT.TAB_PACKAGES)
    521         #

    522         # Get all Packages

    523         #

    524         PackageObj = self.Parser.InfPackageSection.Packages
    525         #

    526         # Go through each arch

    527         #

    528         for PackageItemObj in PackageObj:
    529             #

    530             # Need package information for dependency check usage

    531             #

    532             PackageDependency = PackageDependencyObject()
    533             PackageDependency.SetPackageFilePath(NormPath(PackageItemObj.GetPackageName()))
    534             PackageDependency.SetSupArchList(ConvertArchList(PackageItemObj.GetSupArchList()))
    535             PackageDependency.SetFeatureFlag(PackageItemObj.GetFeatureFlagExp())
    536 
    537             PkgInfo = GetPkgInfoFromDec(mws.join(self.WorkSpace, NormPath(PackageItemObj.GetPackageName())))
    538             if PkgInfo[1] and PkgInfo[2]:
    539                 PackageDependency.SetGuid(PkgInfo[1])
    540                 PackageDependency.SetVersion(PkgInfo[2])
    541             elif Skip:
    542                 continue
    543             else:
    544                 Logger.Error("\nUPT", PARSER_ERROR,
    545                              ST.ERR_INF_GET_PKG_DEPENDENCY_FAIL % PackageItemObj.GetPackageName(), File=self.FullPath)
    546 
    547             PackageDependencyList = self.GetPackageDependencyList()
    548             PackageDependencyList.append(PackageDependency)
    549             self.SetPackageDependencyList(PackageDependencyList)
    550 
    551     ## GenPcds

    552     #

    553     # Gen Pcds of Inf

    554     # <TokenSpaceGuidCName>.<PcdCName>[|<Value> [|<FFE>]]

    555     #

    556     # @param ContainerFile: The Inf file full path

    557     #

    558     def _GenPcds(self):
    559         if not GlobalData.gIS_BINARY_INF:
    560             Logger.Debug(2, "Generate %s ..." % DT.TAB_PCDS)
    561             #

    562             # Get all Pcds

    563             #

    564             PcdObj = self.Parser.InfPcdSection.Pcds
    565             KeysList = PcdObj.keys()
    566             #

    567             # Go through each arch

    568             #

    569             for (PcdType, PcdKey) in KeysList:
    570                 PcdData = PcdObj[PcdType, PcdKey]
    571                 for PcdItemObj in PcdData:
    572                     CommentList = PcdItemObj.GetHelpStringList()
    573                     if CommentList:
    574                         for CommentItem in CommentList:
    575                             Pcd = CommonObject.PcdObject()
    576                             Pcd.SetCName(PcdItemObj.GetCName())
    577                             Pcd.SetTokenSpaceGuidCName(PcdItemObj.GetTokenSpaceGuidCName())
    578                             Pcd.SetDefaultValue(PcdItemObj.GetDefaultValue())
    579                             Pcd.SetItemType(PcdType)
    580                             Pcd.SetValidUsage(CommentItem.GetUsageItem())
    581                             Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp())
    582                             Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportArchList()))
    583                             HelpTextObj = CommonObject.TextObject()
    584                             if self.UniFileClassObject:
    585                                 HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
    586                             HelpTextObj.SetString(CommentItem.GetHelpStringItem())
    587                             Pcd.SetHelpTextList([HelpTextObj])
    588                             PcdList = self.GetPcdList()
    589                             PcdList.append(Pcd)
    590                 self.SetPcdList(PcdList)
    591 
    592     ## GenSources

    593     #

    594     # Gen Sources of Inf

    595     # <Filename>[|<Family>[|<TagName>[|<ToolCode>[|<PcdFeatureFlag>]]]]

    596     #

    597     # @param ContainerFile: The Inf file full path

    598     #

    599     def _GenSources(self):
    600         Logger.Debug(2, "Generate %s ..." % DT.TAB_SOURCES)
    601 
    602         #

    603         # Get all SourceFiles

    604         #

    605         SourceObj = self.Parser.InfSourcesSection.Sources
    606         DataList = SourceObj.keys()
    607         #

    608         # Go through each arch

    609         #

    610         SourceList = []
    611         for Key in DataList:
    612             SourceData = SourceObj[Key]
    613             for Item in SourceData:
    614                 SourceFile = Item.GetSourceFileName()
    615                 Family = Item.GetFamily()
    616                 FeatureFlag = Item.GetFeatureFlagExp()
    617                 SupArchList = ConvertArchList(Item.GetSupArchList())
    618                 SupArchList.sort()
    619                 Source = SourceFileObject()
    620                 Source.SetSourceFile(SourceFile)
    621                 Source.SetFamily(Family)
    622                 Source.SetFeatureFlag(FeatureFlag)
    623                 Source.SetSupArchList(SupArchList)
    624                 SourceList.append(Source)
    625 
    626         self.SetSourceFileList(self.GetSourceFileList() + SourceList)
    627 
    628 
    629     ## GenUserExtensions

    630     #

    631     # Gen UserExtensions of Inf

    632     #

    633     def _GenUserExtensions(self):
    634         #

    635         # UserExtensions

    636         #

    637         UserExtensionObj = self.Parser.InfUserExtensionSection.UserExtension
    638         Keys = UserExtensionObj.keys()
    639 
    640         for Key in Keys:
    641             UserExtensionData = UserExtensionObj[Key]
    642             for UserExtensionDataObj in UserExtensionData:
    643                 UserExtension = CommonObject.UserExtensionObject()
    644                 UserId = UserExtensionDataObj.GetUserId()
    645                 if UserId.startswith('"') and UserId.endswith('"'):
    646                     UserId = UserId[1:-1]                
    647                 UserExtension.SetUserID(UserId)
    648                 Identifier = UserExtensionDataObj.GetIdString()
    649                 if Identifier.startswith('"') and Identifier.endswith('"'):
    650                     Identifier = Identifier[1:-1]
    651                 #

    652                 # Generate miscellaneous files on INF file

    653                 #

    654                 if UserId == 'TianoCore' and Identifier == 'ExtraFiles':
    655                     self._GenMiscFiles(UserExtensionDataObj.GetContent())
    656                 UserExtension.SetIdentifier(Identifier)
    657                 UserExtension.SetStatement(UserExtensionDataObj.GetContent())
    658                 UserExtension.SetSupArchList(ConvertArchList(UserExtensionDataObj.GetSupArchList()))
    659                 self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
    660                 
    661         #

    662         #  Gen UserExtensions of TianoCore."BinaryHeader"

    663         #

    664         
    665         #Get Binary header from INF file

    666         BinaryAbstractList = self.BinaryHeaderAbstractList
    667         BinaryDescriptionList = self.BinaryHeaderDescriptionList
    668         BinaryCopyrightList = self.BinaryHeaderCopyrightList
    669         BinaryLicenseList = self.BinaryHeaderLicenseList
    670         #Get Binary header from UNI file

    671         # Initialize UniStrDict, the top keys are language codes

    672         UniStrDict = {}
    673         if self.UniFileClassObject:
    674             UniStrDict = self.UniFileClassObject.OrderedStringList
    675             for Lang in UniStrDict:
    676                 for StringDefClassObject in UniStrDict[Lang]:
    677                     Lang = GetLanguageCode1766(Lang)
    678                     if StringDefClassObject.StringName == DT.TAB_INF_BINARY_ABSTRACT:
    679                         BinaryAbstractList.append((Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
    680                     if StringDefClassObject.StringName == DT.TAB_INF_BINARY_DESCRIPTION:
    681                         BinaryDescriptionList.append((Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
    682         if BinaryAbstractList or BinaryDescriptionList or BinaryCopyrightList or BinaryLicenseList:
    683             BinaryUserExtension = CommonObject.UserExtensionObject()
    684             BinaryUserExtension.SetBinaryAbstract(BinaryAbstractList)
    685             BinaryUserExtension.SetBinaryDescription(BinaryDescriptionList)
    686             BinaryUserExtension.SetBinaryCopyright(BinaryCopyrightList)
    687             BinaryUserExtension.SetBinaryLicense(BinaryLicenseList)
    688             BinaryUserExtension.SetIdentifier(DT.TAB_BINARY_HEADER_IDENTIFIER)
    689             BinaryUserExtension.SetUserID(DT.TAB_BINARY_HEADER_USERID)
    690             self.SetUserExtensionList(self.GetUserExtensionList() + [BinaryUserExtension])
    691             
    692     def _GenDepexesList(self, SmmDepexList, DxeDepexList, PeiDepexList):
    693         if SmmDepexList:
    694             self.SetSmmDepex(SmmDepexList)
    695         if DxeDepexList:
    696             self.SetDxeDepex(DxeDepexList)
    697         if PeiDepexList:
    698             self.SetPeiDepex(PeiDepexList)
    699 
    700     ## GenDepexes

    701     #

    702     # Gen Depex of Inf

    703     #

    704     # @param ContainerFile: The Inf file full path

    705     #

    706     def _GenDepexes(self):
    707         Logger.Debug(2, "Generate %s ..." % DT.TAB_DEPEX)
    708 
    709         PEI_LIST = [DT.SUP_MODULE_PEIM]
    710         SMM_LIST = [DT.SUP_MODULE_DXE_SMM_DRIVER]
    711         DXE_LIST = [DT.SUP_MODULE_DXE_DRIVER, DT.SUP_MODULE_DXE_SAL_DRIVER,
    712                     DT.SUP_MODULE_DXE_RUNTIME_DRIVER]
    713 
    714         IsLibraryClass = self.GetIsLibrary()
    715         #

    716         # Get all Depexes

    717         #

    718         DepexData = self.Parser.InfDepexSection.GetDepex()
    719         SmmDepexList = []
    720         DxeDepexList = []
    721         PeiDepexList = []
    722         for Depex in DepexData:
    723             ModuleType = Depex.GetModuleType()
    724             ModuleTypeList = []
    725             if IsLibraryClass:
    726                 if self.GetModuleType() == 'BASE' and not ModuleType:
    727                     Logger.Error("\nMkPkg", PARSER_ERROR,
    728                                  ST.ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_BASE_LIBRARY_CLASS,
    729                                  self.GetFullPath(), RaiseError=True)
    730                 if self.GetModuleType() != 'BASE' and not self.GetIsLibraryModList():
    731                     Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_LIBRARY_CLASS,
    732                                  self.GetFullPath(), RaiseError=True)
    733                 if self.GetModuleType() != 'BASE' and ModuleType and ModuleType not in self.GetIsLibraryModList():
    734                     Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED,
    735                                  self.GetFullPath(), RaiseError=True)
    736                 if ModuleType:
    737                     ModuleTypeList = [ModuleType]
    738                 else:
    739                     for ModuleTypeInList in self.GetIsLibraryModList():
    740                         if ModuleTypeInList in DT.VALID_DEPEX_MODULE_TYPE_LIST:
    741                             ModuleTypeList.append(ModuleTypeInList)
    742                 if not ModuleTypeList:
    743                     Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED,
    744                                  self.GetFullPath(), RaiseError=True)
    745             else:
    746                 if not ModuleType:
    747                     ModuleType = self.ModuleType
    748                 if ModuleType not in DT.VALID_DEPEX_MODULE_TYPE_LIST:
    749                     Logger.Error("\nMkPkg", PARSER_ERROR,
    750                                  ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR % (ModuleType),
    751                                  self.GetFullPath(), RaiseError=True)
    752                 if ModuleType != self.ModuleType:
    753                     Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED,
    754                                  self.GetFullPath(), RaiseError=True)
    755                 ModuleTypeList = [ModuleType]
    756             for ModuleType in ModuleTypeList:
    757                 DepexIns = DepexObject()
    758                 DepexIns.SetDepex(Depex.GetDepexContent())
    759                 if IsLibraryClass:
    760                     DepexIns.SetModuleType(ModuleType)
    761                 else:
    762                     if Depex.GetModuleType():
    763                         DepexIns.SetModuleType(Depex.GetModuleType())
    764                 DepexIns.SetSupArchList(ConvertArchList([Depex.GetSupArch()]))
    765                 DepexIns.SetFeatureFlag(Depex.GetFeatureFlagExp())
    766                 if Depex.HelpString:
    767                     HelpIns = CommonObject.TextObject()
    768                     if self.UniFileClassObject:
    769                         HelpIns.SetLang(DT.TAB_LANGUAGE_EN_X)
    770                     HelpIns.SetString(GetHelpStringByRemoveHashKey(Depex.HelpString))
    771                     DepexIns.SetHelpText(HelpIns)
    772 
    773                 if ModuleType in SMM_LIST:
    774                     SmmDepexList.append(DepexIns)
    775                 if ModuleType in DXE_LIST:
    776                     DxeDepexList.append(DepexIns)
    777                 if ModuleType in PEI_LIST:
    778                     PeiDepexList.append(DepexIns)
    779                 if ModuleType == DT.SUP_MODULE_UEFI_DRIVER:
    780                     if IsLibraryClass:
    781                         DxeDepexList.append(DepexIns)
    782                     else:
    783                         Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_DRIVER,
    784                                      self.GetFullPath(), RaiseError=True)
    785 
    786             #End of for ModuleType in ModuleTypeList

    787             self._GenDepexesList(SmmDepexList, DxeDepexList, PeiDepexList)
    788         #End of for Depex in DepexData

    789 
    790     ## GenBinaries

    791     #

    792     # Gen Binary of Inf, must be called after Pcd/Library is generated

    793     # <FileType>|<Filename>|<Target>[|<TokenSpaceGuidCName>.<PcdCName>]

    794     #

    795     # @param ContainerFile: The Inf file full path

    796     #

    797     def _GenBinaries(self):
    798         Logger.Debug(2, "Generate %s ..." % DT.TAB_BINARIES)
    799         BinariesDict = {}
    800 
    801         #

    802         # Get all Binary data

    803         #

    804         BinaryObj = self.Parser.InfBinariesSection.GetBinary()
    805 
    806         BinaryData = BinaryObj.keys()
    807 
    808         #

    809         # If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section, 

    810         # then the ModuleSurfaceArea.BinaryModule attribute must be set to true. Otherwise, do not use the attribute

    811         #

    812         if BinaryObj and not self.Parser.InfSourcesSection.GetSources():
    813             self.BinaryModule = True
    814         else:
    815             self.BinaryModule = False
    816 
    817         BinaryFileObjectList = []
    818         AsBuildLibraryClassList = []
    819         AsBuildBuildOptionList = []
    820         AsBuildIns = AsBuiltObject()
    821         #

    822         # Library AsBuild Info

    823         #

    824         for LibItem in self.Parser.InfLibraryClassSection.GetLibraryClasses():
    825             AsBuildLibIns = AsBuildLibraryClassObject()
    826             AsBuildLibIns.SetLibGuid(LibItem.GetFileGuid())
    827             AsBuildLibIns.SetLibVersion(LibItem.GetVersion())
    828             AsBuildLibIns.SetSupArchList(LibItem.GetSupArchList())
    829             AsBuildLibraryClassList.append(AsBuildLibIns)
    830         AsBuildIns.SetLibraryInstancesList(AsBuildLibraryClassList)
    831 
    832         #

    833         # BuildOption AsBuild Info

    834         #            

    835         for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions():
    836             AsBuildBuildOptionList.append(BuildOptionItem)
    837         AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList)
    838 
    839         #

    840         # PatchPcd and PcdEx

    841         #

    842         AsBuildIns = self._GenAsBuiltPcds(self.Parser.InfPcdSection.GetPcds(), AsBuildIns)
    843 
    844         #

    845         # Parse the DEC file that contains the GUID value of the GUID CName which is used by

    846         # SUBTYPE_GUID type binary file in the Binaries section in the INF file

    847         #

    848         DecObjList = []
    849         if not self.PackagePath:
    850             WorkSpace = os.path.normpath(self.WorkSpace)
    851             TempPath = ModulePath = os.path.normpath(self.ModulePath)
    852             while ModulePath:
    853                 TempPath = ModulePath
    854                 ModulePath = os.path.dirname(ModulePath)
    855             PackageName = TempPath
    856             DecFilePath = os.path.normpath(os.path.join(WorkSpace, PackageName))  
    857             if DecFilePath:
    858                 for File in os.listdir(DecFilePath):
    859                     if File.upper().endswith('.DEC'):
    860                         DecFileFullPath = os.path.normpath(os.path.join(DecFilePath, File))
    861                         DecObjList.append(DecPomAlignment(DecFileFullPath, self.WorkSpace))
    862                         
    863         
    864         BinariesDict, AsBuildIns, BinaryFileObjectList = GenBinaryData(BinaryData, BinaryObj,
    865                                                                        BinariesDict,
    866                                                                        AsBuildIns,
    867                                                                        BinaryFileObjectList,
    868                                                                        self.GetSupArchList(),
    869                                                                        self.BinaryModule,
    870                                                                        DecObjList)
    871                 
    872         BinariesDict2 = {}
    873         for Key in BinariesDict:
    874             ValueList = BinariesDict[Key]
    875             if len(ValueList) > 1:
    876                 BinariesDict2[Key] = ValueList
    877             else:
    878                 #

    879                 # if there is no TagName, ToolCode, HelpStr, 

    880                 # then do not need to put them into userextension

    881                 #

    882                 (Target, Family, TagName, HelpStr) = ValueList[0]
    883                 if not (Target or Family or TagName or HelpStr):
    884                     continue
    885                 else:
    886                     BinariesDict2[Key] = ValueList
    887 
    888         self.SetBinaryFileList(self.GetBinaryFileList() + BinaryFileObjectList)
    889 
    890         if BinariesDict2:
    891             UserExtension = CommonObject.UserExtensionObject()
    892             UserExtension.SetBinariesDict(BinariesDict2)
    893             UserExtension.SetIdentifier('BinaryFileModifiers')
    894             UserExtension.SetUserID('EDK2')
    895             self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
    896 
    897     ## GenAsBuiltPcds

    898     #

    899     #

    900     def _GenAsBuiltPcds(self, PcdList, AsBuildIns):
    901         AsBuildPatchPcdList = []
    902         AsBuildPcdExList = []
    903         #

    904         # Pcd AsBuild Info

    905         #

    906         for PcdItem in PcdList:
    907             if PcdItem[0].upper() == DT.TAB_INF_PATCH_PCD.upper():
    908                 PcdItemObj = PcdItem[1]
    909                 Pcd = CommonObject.PcdObject()
    910                 Pcd.SetCName(PcdItemObj.GetCName())
    911                 Pcd.SetTokenSpaceGuidCName(PcdItemObj.GetTokenSpaceGuidCName())
    912                 if PcdItemObj.GetTokenSpaceGuidValue() == '' and self.BinaryModule:
    913                     Logger.Error("\nMkPkg",
    914                                  PARSER_ERROR,
    915                                  ST.ERR_ASBUILD_PCD_TOKENSPACE_GUID_VALUE_MISS % \
    916                                  (PcdItemObj.GetTokenSpaceGuidCName()),
    917                                  self.GetFullPath(), RaiseError=True)
    918                 else:
    919                     Pcd.SetTokenSpaceGuidValue(PcdItemObj.GetTokenSpaceGuidValue())
    920                 if (PcdItemObj.GetToken() == '' or PcdItemObj.GetDatumType() == '') and self.BinaryModule:
    921                     Logger.Error("\nMkPkg",
    922                                  PARSER_ERROR,
    923                                  ST.ERR_ASBUILD_PCD_DECLARITION_MISS % \
    924                                  (PcdItemObj.GetTokenSpaceGuidCName() + '.' + PcdItemObj.GetCName()),
    925                                  self.GetFullPath(), RaiseError=True)
    926                 Pcd.SetToken(PcdItemObj.GetToken())
    927                 Pcd.SetDatumType(PcdItemObj.GetDatumType())
    928                 Pcd.SetMaxDatumSize(PcdItemObj.GetMaxDatumSize())
    929                 Pcd.SetDefaultValue(PcdItemObj.GetDefaultValue())
    930                 Pcd.SetOffset(PcdItemObj.GetOffset())
    931                 Pcd.SetItemType(PcdItem[0])
    932                 Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp())
    933                 Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportArchList()))
    934                 Pcd.SetValidUsage(PcdItemObj.GetValidUsage())
    935                 for CommentItem in PcdItemObj.GetHelpStringList():
    936                     HelpTextObj = CommonObject.TextObject()
    937                     if self.UniFileClassObject:
    938                         HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
    939                     HelpTextObj.SetString(CommentItem.GetHelpStringItem())
    940                     Pcd.SetHelpTextList(Pcd.GetHelpTextList() + [HelpTextObj])
    941                 AsBuildPatchPcdList.append(Pcd)
    942             elif PcdItem[0].upper() == DT.TAB_INF_PCD_EX.upper():
    943                 PcdItemObj = PcdItem[1]
    944                 Pcd = CommonObject.PcdObject()
    945                 Pcd.SetTokenSpaceGuidValue(PcdItemObj.GetTokenSpaceGuidValue())
    946                 Pcd.SetToken(PcdItemObj.GetToken())
    947                 Pcd.SetDatumType(PcdItemObj.GetDatumType())
    948                 Pcd.SetMaxDatumSize(PcdItemObj.GetMaxDatumSize())
    949                 Pcd.SetDefaultValue(PcdItemObj.GetDefaultValue())
    950                 Pcd.SetItemType(PcdItem[0])
    951                 Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp())
    952                 Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportArchList()))
    953                 Pcd.SetValidUsage(PcdItemObj.GetValidUsage())
    954                 for CommentItem in PcdItemObj.GetHelpStringList():
    955                     HelpTextObj = CommonObject.TextObject()
    956                     if self.UniFileClassObject:
    957                         HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
    958                     HelpTextObj.SetString(CommentItem.GetHelpStringItem())
    959                     Pcd.SetHelpTextList(Pcd.GetHelpTextList() + [HelpTextObj])
    960                 AsBuildPcdExList.append(Pcd)
    961         AsBuildIns.SetPatchPcdList(AsBuildPatchPcdList)
    962         AsBuildIns.SetPcdExList(AsBuildPcdExList)
    963 
    964         return AsBuildIns
    965 
    966     ## GenGuidProtocolPpis

    967     #

    968     # Gen Guids/Protocol/Ppis of INF

    969     # <CName>=<GuidValue>

    970     #

    971     def _GenGuidProtocolPpis(self, Type):
    972         Logger.Debug(2, "Generate %s ..." % Type)
    973         #

    974         # Get all Guid/Protocol/Ppis data

    975         #

    976         GuidObj = self.Parser.InfGuidSection.GetGuid()
    977         ProtocolObj = self.Parser.InfProtocolSection.GetProtocol()
    978         PpisObj = self.Parser.InfPpiSection.GetPpi()
    979 
    980         GuidProtocolPpiList = []
    981 
    982         if Type == DT.TAB_GUIDS:
    983             GuidData = GuidObj.keys()
    984             for Item in GuidData:
    985                 CommentList = Item.GetCommentList()
    986                 #

    987                 # Depend on CommentList content

    988                 # generate muti-guid-obj

    989                 #

    990                 if CommentList:
    991                     for GuidComentItem in CommentList:
    992                         ListObject = CommonObject.GuidObject()
    993                         ListObject.SetGuidTypeList([GuidComentItem.GetGuidTypeItem()])
    994                         ListObject.SetVariableName(GuidComentItem.GetVariableNameItem())
    995                         ListObject.SetUsage(GuidComentItem.GetUsageItem())
    996                         ListObject.SetName(Item.GetName())
    997                         ListObject.SetCName(Item.GetName())
    998                         ListObject.SetSupArchList(ConvertArchList(Item.GetSupArchList()))
    999                         ListObject.SetFeatureFlag(Item.GetFeatureFlagExp())
   1000                         HelpString = GuidComentItem.GetHelpStringItem()
   1001                         if HelpString.strip():
   1002                             HelpTxtTailObj = CommonObject.TextObject()
   1003                             if self.UniFileClassObject:
   1004                                 HelpTxtTailObj.SetLang(DT.TAB_LANGUAGE_EN_X)
   1005                             HelpTxtTailObj.SetString(HelpString)
   1006                             ListObject.SetHelpTextList([HelpTxtTailObj])
   1007                             
   1008                         GuidProtocolPpiList.append(ListObject)
   1009         elif Type == DT.TAB_PROTOCOLS:
   1010             ProtocolData = ProtocolObj.keys()
   1011             for Item in ProtocolData:
   1012                 CommentList = Item.GetCommentList()
   1013                 for CommentItem in CommentList:
   1014                     ListObject = CommonObject.ProtocolObject()
   1015                     ListObject.SetCName(Item.GetName())
   1016                     ListObject.SetSupArchList(ConvertArchList(Item.GetSupArchList()))
   1017                     ListObject.SetFeatureFlag(Item.GetFeatureFlagExp())
   1018                     ListObject.SetNotify(CommentItem.GetNotify())
   1019                     ListObject.SetUsage(CommentItem.GetUsageItem())
   1020                     HelpString = CommentItem.GetHelpStringItem()
   1021                     if HelpString.strip():
   1022                         HelpTxtObj = CommonObject.TextObject()
   1023                         if self.UniFileClassObject:
   1024                             HelpTxtObj.SetLang(DT.TAB_LANGUAGE_EN_X)
   1025                         HelpTxtObj.SetString(HelpString)
   1026                         ListObject.SetHelpTextList([HelpTxtObj])
   1027                     GuidProtocolPpiList.append(ListObject)
   1028         elif Type == DT.TAB_PPIS:
   1029             PpiData = PpisObj.keys()
   1030             for Item in PpiData:
   1031                 CommentList = Item.GetCommentList()
   1032                 for CommentItem in CommentList:
   1033                     ListObject = CommonObject.PpiObject()
   1034                     ListObject.SetCName(Item.GetName())
   1035                     ListObject.SetSupArchList(ConvertArchList(Item.GetSupArchList()))
   1036                     ListObject.SetFeatureFlag(Item.GetFeatureFlagExp())
   1037                     ListObject.SetNotify(CommentItem.GetNotify())
   1038                     ListObject.SetUsage(CommentItem.GetUsage())
   1039                     HelpString = CommentItem.GetHelpStringItem()
   1040                     if HelpString.strip():
   1041                         HelpTextObj = CommonObject.TextObject()
   1042                         if self.UniFileClassObject:
   1043                             HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
   1044                         HelpTextObj.SetString(HelpString)
   1045                         ListObject.SetHelpTextList([HelpTextObj])
   1046                     GuidProtocolPpiList.append(ListObject)
   1047 
   1048         if Type == DT.TAB_GUIDS:
   1049             self.SetGuidList(self.GetGuidList() + GuidProtocolPpiList)
   1050         elif Type == DT.TAB_PROTOCOLS:
   1051             self.SetProtocolList(self.GetProtocolList() + GuidProtocolPpiList)
   1052         elif Type == DT.TAB_PPIS:
   1053             self.SetPpiList(self.GetPpiList() + GuidProtocolPpiList)
   1054 
   1055     ## GenMiscFiles

   1056     #

   1057     # Gen MiscellaneousFiles of Inf

   1058     #

   1059     # @param ContainerFile: The Inf file full path

   1060     #

   1061     def _GenMiscFiles(self, Content):
   1062         MiscFileObj = CommonObject.MiscFileObject()
   1063         for Line in Content.splitlines():
   1064             FileName = ''
   1065             if '#' in Line:
   1066                 FileName = Line[:Line.find('#')]
   1067             else:
   1068                 FileName = Line
   1069             if FileName:
   1070                 if IsValidPath(FileName, GlobalData.gINF_MODULE_DIR):
   1071                     FileObj = CommonObject.FileObject()
   1072                     FileObj.SetURI(FileName)
   1073                     MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[FileObj])
   1074                 else:
   1075                     Logger.Error("InfParser", 
   1076                                  FORMAT_INVALID,
   1077                                  ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Line),
   1078                                  File=GlobalData.gINF_MODULE_NAME,
   1079                                  ExtraData=Line)   
   1080         self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj]) 
   1081         
   1082