• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## @file
2# This file is used to define class objects of INF file [Binaries] section.
3# It will consumed by InfParser.
4#
5# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
6#
7# This program and the accompanying materials are licensed and made available
8# under the terms and conditions of the BSD License which accompanies this
9# distribution. The full text of the license may be found at
10# http://opensource.org/licenses/bsd-license.php
11#
12# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15'''
16InfBinaryObject
17'''
18
19import os
20
21from copy import deepcopy
22from Library import DataType as DT
23from Library import GlobalData
24import Logger.Log as Logger
25from Logger import ToolError
26from Logger import StringTable as ST
27from Library.Misc import Sdict
28
29from Object.Parser.InfCommonObject import InfSectionCommonDef
30from Object.Parser.InfCommonObject import CurrentLine
31from Library.Misc import ConvPathFromAbsToRel
32from Library.ExpressionValidate import IsValidFeatureFlagExp
33from Library.Misc import ValidFile
34from Library.ParserValidate import IsValidPath
35
36
37class InfBianryItem():
38    def __init__(self):
39        self.FileName = ''
40        self.Target = ''
41        self.FeatureFlagExp = ''
42        self.HelpString = ''
43        self.Type = ''
44        self.SupArchList = []
45
46    def SetFileName(self, FileName):
47        self.FileName = FileName
48    def GetFileName(self):
49        return self.FileName
50
51    def SetTarget(self, Target):
52        self.Target = Target
53    def GetTarget(self):
54        return self.Target
55
56    def SetFeatureFlagExp(self, FeatureFlagExp):
57        self.FeatureFlagExp = FeatureFlagExp
58    def GetFeatureFlagExp(self):
59        return self.FeatureFlagExp
60
61    def SetHelpString(self, HelpString):
62        self.HelpString = HelpString
63    def GetHelpString(self):
64        return self.HelpString
65
66    def SetType(self, Type):
67        self.Type = Type
68    def GetType(self):
69        return self.Type
70    def SetSupArchList(self, SupArchList):
71        self.SupArchList = SupArchList
72    def GetSupArchList(self):
73        return self.SupArchList
74
75class InfBianryVerItem(InfBianryItem, CurrentLine):
76    def __init__(self):
77        InfBianryItem.__init__(self)
78        CurrentLine.__init__(self)
79        self.VerTypeName = ''
80
81    def SetVerTypeName(self, VerTypeName):
82        self.VerTypeName = VerTypeName
83    def GetVerTypeName(self):
84        return self.VerTypeName
85
86class InfBianryUiItem(InfBianryItem, CurrentLine):
87    def __init__(self):
88        InfBianryItem.__init__(self)
89        CurrentLine.__init__(self)
90        self.UiTypeName = ''
91
92    def SetUiTypeName(self, UiTypeName):
93        self.UiTypeName = UiTypeName
94    def GetVerTypeName(self):
95        return self.UiTypeName
96
97class InfBianryCommonItem(InfBianryItem, CurrentLine):
98    def __init__(self):
99        self.CommonType = ''
100        self.TagName = ''
101        self.Family = ''
102        self.GuidValue = ''
103        InfBianryItem.__init__(self)
104        CurrentLine.__init__(self)
105
106    def SetCommonType(self, CommonType):
107        self.CommonType = CommonType
108    def GetCommonType(self):
109        return self.CommonType
110
111    def SetTagName(self, TagName):
112        self.TagName = TagName
113    def GetTagName(self):
114        return self.TagName
115
116    def SetFamily(self, Family):
117        self.Family = Family
118    def GetFamily(self):
119        return self.Family
120
121    def SetGuidValue(self, GuidValue):
122        self.GuidValue = GuidValue
123    def GetGuidValue(self):
124        return self.GuidValue
125
126##
127#
128#
129#
130class InfBinariesObject(InfSectionCommonDef):
131    def __init__(self):
132        self.Binaries = Sdict()
133        #
134        # Macro defined in this section should be only used in this section.
135        #
136        self.Macros = {}
137        InfSectionCommonDef.__init__(self)
138
139    ## CheckVer
140    #
141    #
142    def CheckVer(self, Ver, __SupArchList):
143        #
144        # Check Ver
145        #
146        for VerItem in Ver:
147            IsValidFileFlag = False
148            VerContent = VerItem[0]
149            VerComment = VerItem[1]
150            VerCurrentLine = VerItem[2]
151            GlobalData.gINF_CURRENT_LINE = VerCurrentLine
152            InfBianryVerItemObj = None
153            #
154            # Should not less than 2 elements
155            #
156            if len(VerContent) < 2:
157                Logger.Error("InfParser",
158                             ToolError.FORMAT_INVALID,
159                             ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (VerContent[0], 2),
160                             File=VerCurrentLine.GetFileName(),
161                             Line=VerCurrentLine.GetLineNo(),
162                             ExtraData=VerCurrentLine.GetLineString())
163                return False
164            if len(VerContent) > 4:
165                Logger.Error("InfParser",
166                             ToolError.FORMAT_INVALID,
167                             ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (VerContent[0], 4),
168                             File=VerCurrentLine.GetFileName(),
169                             Line=VerCurrentLine.GetLineNo(),
170                             ExtraData=VerCurrentLine.GetLineString())
171                return False
172            if len(VerContent) >= 2:
173                #
174                # Create a Ver Object.
175                #
176                InfBianryVerItemObj = InfBianryVerItem()
177
178                if VerContent[0] != DT.BINARY_FILE_TYPE_VER:
179                    Logger.Error("InfParser",
180                                 ToolError.FORMAT_INVALID,
181                                 ST.ERR_INF_PARSER_BINARY_VER_TYPE % DT.BINARY_FILE_TYPE_VER,
182                                 File=VerCurrentLine.GetFileName(),
183                                 Line=VerCurrentLine.GetLineNo(),
184                                 ExtraData=VerCurrentLine.GetLineString())
185
186                InfBianryVerItemObj.SetVerTypeName(VerContent[0])
187                InfBianryVerItemObj.SetType(VerContent[0])
188                #
189                # Verify File exist or not
190                #
191                FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
192                                                                              VerContent[1])))
193                if not (ValidFile(FullFileName) or ValidFile(VerContent[1])):
194                    Logger.Error("InfParser",
195                                 ToolError.FORMAT_INVALID,
196                                 ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (VerContent[1]),
197                                 File=VerCurrentLine.GetFileName(),
198                                 Line=VerCurrentLine.GetLineNo(),
199                                 ExtraData=VerCurrentLine.GetLineString())
200                #
201                # Validate file exist/format.
202                #
203                if IsValidPath(VerContent[1], GlobalData.gINF_MODULE_DIR):
204                    IsValidFileFlag = True
205                else:
206                    Logger.Error("InfParser",
207                                 ToolError.FORMAT_INVALID,
208                                 ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (VerContent[1]),
209                                 File=VerCurrentLine.GetFileName(),
210                                 Line=VerCurrentLine.GetLineNo(),
211                                 ExtraData=VerCurrentLine.GetLineString())
212                    return False
213                if IsValidFileFlag:
214                    VerContent[0] = ConvPathFromAbsToRel(VerContent[0],
215                                            GlobalData.gINF_MODULE_DIR)
216                    InfBianryVerItemObj.SetFileName(VerContent[1])
217            if len(VerContent) >= 3:
218                #
219                # Add Target information
220                #
221                InfBianryVerItemObj.SetTarget(VerContent[2])
222            if len(VerContent) == 4:
223                if VerContent[3].strip() == '':
224                    Logger.Error("InfParser",
225                                 ToolError.FORMAT_INVALID,
226                                 ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
227                                 File=VerCurrentLine.GetFileName(),
228                                 Line=VerCurrentLine.GetLineNo(),
229                                 ExtraData=VerCurrentLine.GetLineString())
230                #
231                # Validate Feature Flag Express
232                #
233                FeatureFlagRtv = IsValidFeatureFlagExp(VerContent[3].\
234                                                       strip())
235                if not FeatureFlagRtv[0]:
236                    Logger.Error("InfParser",
237                                 ToolError.FORMAT_INVALID,
238                                 ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
239                                 File=VerCurrentLine.GetFileName(),
240                                 Line=VerCurrentLine.GetLineNo(),
241                                 ExtraData=VerCurrentLine.GetLineString())
242                InfBianryVerItemObj.SetFeatureFlagExp(VerContent[3])
243
244            InfBianryVerItemObj.SetSupArchList(__SupArchList)
245
246            #
247            # Determine binary file name duplicate. Follow below rule:
248            #
249            # A binary filename must not be duplicated within
250            # a [Binaries] section. A binary filename may appear in
251            # multiple architectural [Binaries] sections. A binary
252            # filename listed in an architectural [Binaries] section
253            # must not be listed in the common architectural
254            # [Binaries] section.
255            #
256            # NOTE: This check will not report error now.
257            #
258            for Item in self.Binaries:
259                if Item.GetFileName() == InfBianryVerItemObj.GetFileName():
260                    ItemSupArchList = Item.GetSupArchList()
261                    for ItemArch in ItemSupArchList:
262                        for VerItemObjArch in __SupArchList:
263                            if ItemArch == VerItemObjArch:
264                                #
265                                # ST.ERR_INF_PARSER_ITEM_DUPLICATE
266                                #
267                                pass
268                            if ItemArch.upper() == 'COMMON' or VerItemObjArch.upper() == 'COMMON':
269                                #
270                                # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
271                                #
272                                pass
273
274            if InfBianryVerItemObj != None:
275                if self.Binaries.has_key((InfBianryVerItemObj)):
276                    BinariesList = self.Binaries[InfBianryVerItemObj]
277                    BinariesList.append((InfBianryVerItemObj, VerComment))
278                    self.Binaries[InfBianryVerItemObj] = BinariesList
279                else:
280                    BinariesList = []
281                    BinariesList.append((InfBianryVerItemObj, VerComment))
282                    self.Binaries[InfBianryVerItemObj] = BinariesList
283
284    ## ParseCommonBinary
285    #
286    # ParseCommonBinary
287    #
288    def ParseCommonBinary(self, CommonBinary, __SupArchList):
289        #
290        # Check common binary definitions
291        # Type | FileName | Target | Family | TagName | FeatureFlagExp
292        #
293        for Item in CommonBinary:
294            IsValidFileFlag = False
295            ItemContent = Item[0]
296            ItemComment = Item[1]
297            CurrentLineOfItem = Item[2]
298            GlobalData.gINF_CURRENT_LINE = CurrentLineOfItem
299            InfBianryCommonItemObj = None
300            if ItemContent[0] == 'SUBTYPE_GUID':
301                if len(ItemContent) < 3:
302                    Logger.Error("InfParser",
303                                 ToolError.FORMAT_INVALID,
304                                 ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0], 3),
305                                 File=CurrentLineOfItem.GetFileName(),
306                                 Line=CurrentLineOfItem.GetLineNo(),
307                                 ExtraData=CurrentLineOfItem.GetLineString())
308                    return False
309            else:
310                if len(ItemContent) < 2:
311                    Logger.Error("InfParser",
312                                 ToolError.FORMAT_INVALID,
313                                 ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0], 2),
314                                 File=CurrentLineOfItem.GetFileName(),
315                                 Line=CurrentLineOfItem.GetLineNo(),
316                                 ExtraData=CurrentLineOfItem.GetLineString())
317                    return False
318
319            if len(ItemContent) > 7:
320                Logger.Error("InfParser",
321                             ToolError.FORMAT_INVALID,
322                             ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (ItemContent[0], 7),
323                             File=CurrentLineOfItem.GetFileName(),
324                             Line=CurrentLineOfItem.GetLineNo(),
325                             ExtraData=CurrentLineOfItem.GetLineString())
326                return False
327            if len(ItemContent) >= 2:
328                #
329                # Create a Common Object.
330                #
331                InfBianryCommonItemObj = InfBianryCommonItem()
332                #
333                # Convert Binary type.
334                #
335                BinaryFileType = ItemContent[0].strip()
336                if BinaryFileType == 'RAW' or BinaryFileType == 'ACPI' or BinaryFileType == 'ASL':
337                    BinaryFileType = 'BIN'
338
339                if BinaryFileType not in DT.BINARY_FILE_TYPE_LIST:
340                    Logger.Error("InfParser",
341                                 ToolError.FORMAT_INVALID,
342                                 ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE % \
343                                 (DT.BINARY_FILE_TYPE_LIST.__str__()),
344                                 File=CurrentLineOfItem.GetFileName(),
345                                 Line=CurrentLineOfItem.GetLineNo(),
346                                 ExtraData=CurrentLineOfItem.GetLineString())
347
348                if BinaryFileType == 'SUBTYPE_GUID':
349                    BinaryFileType = 'FREEFORM'
350
351                if BinaryFileType == 'LIB' or BinaryFileType == 'UEFI_APP':
352                    Logger.Error("InfParser",
353                                 ToolError.FORMAT_INVALID,
354                                 ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE % \
355                                 (DT.BINARY_FILE_TYPE_LIST.__str__()),
356                                 File=CurrentLineOfItem.GetFileName(),
357                                 Line=CurrentLineOfItem.GetLineNo(),
358                                 ExtraData=CurrentLineOfItem.GetLineString())
359
360                InfBianryCommonItemObj.SetType(BinaryFileType)
361                InfBianryCommonItemObj.SetCommonType(ItemContent[0])
362                FileName = ''
363                if BinaryFileType == 'FREEFORM':
364                    InfBianryCommonItemObj.SetGuidValue(ItemContent[1])
365                    if len(ItemContent) >= 3:
366                        FileName = ItemContent[2]
367                    else:
368                        Logger.Error("InfParser",
369                                 ToolError.FORMAT_INVALID,
370                                 ST.ERR_INF_PARSER_BINARY_ITEM_FILENAME_NOT_EXIST,
371                                 File=CurrentLineOfItem.GetFileName(),
372                                 Line=CurrentLineOfItem.GetLineNo(),
373                                 ExtraData=CurrentLineOfItem.GetLineString())
374                else:
375                    FileName = ItemContent[1]
376                #
377                # Verify File exist or not
378                #
379                FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
380                                                                              FileName)))
381                if not (ValidFile(FullFileName) or ValidFile(FileName)):
382                    Logger.Error("InfParser",
383                                 ToolError.FORMAT_INVALID,
384                                 ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (FileName),
385                                 File=CurrentLineOfItem.GetFileName(),
386                                 Line=CurrentLineOfItem.GetLineNo(),
387                                 ExtraData=CurrentLineOfItem.GetLineString())
388                #
389                # Validate file exist/format.
390                #
391                if IsValidPath(FileName, GlobalData.gINF_MODULE_DIR):
392                    IsValidFileFlag = True
393                else:
394                    Logger.Error("InfParser",
395                                ToolError.FORMAT_INVALID,
396                                ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (FileName),
397                                File=CurrentLineOfItem.GetFileName(),
398                                Line=CurrentLineOfItem.GetLineNo(),
399                                ExtraData=CurrentLineOfItem.GetLineString())
400                    return False
401                if IsValidFileFlag:
402                    ItemContent[0] = ConvPathFromAbsToRel(ItemContent[0], GlobalData.gINF_MODULE_DIR)
403                    InfBianryCommonItemObj.SetFileName(FileName)
404            if len(ItemContent) >= 3:
405                #
406                # Add Target information
407                #
408                if BinaryFileType != 'FREEFORM':
409                    InfBianryCommonItemObj.SetTarget(ItemContent[2])
410
411            if len(ItemContent) >= 4:
412                #
413                # Add Family information
414                #
415                if BinaryFileType != 'FREEFORM':
416                    InfBianryCommonItemObj.SetFamily(ItemContent[3])
417                else:
418                    InfBianryCommonItemObj.SetTarget(ItemContent[3])
419
420            if len(ItemContent) >= 5:
421                #
422                # TagName entries are build system specific. If there
423                # is content in the entry, the tool must exit
424                # gracefully with an error message that indicates build
425                # system specific content cannot be distributed using
426                # the UDP
427                #
428                if BinaryFileType != 'FREEFORM':
429                    if ItemContent[4].strip() != '':
430                        Logger.Error("InfParser",
431                                     ToolError.FORMAT_INVALID,
432                                     ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % (ItemContent[4]),
433                                     File=CurrentLineOfItem.GetFileName(),
434                                     Line=CurrentLineOfItem.GetLineNo(),
435                                     ExtraData=CurrentLineOfItem.GetLineString())
436                else:
437                    InfBianryCommonItemObj.SetFamily(ItemContent[4])
438
439            if len(ItemContent) >= 6:
440                #
441                # Add FeatureFlagExp
442                #
443                if BinaryFileType != 'FREEFORM':
444                    if ItemContent[5].strip() == '':
445                        Logger.Error("InfParser",
446                                     ToolError.FORMAT_INVALID,
447                                     ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
448                                     File=CurrentLineOfItem.GetFileName(),
449                                     Line=CurrentLineOfItem.GetLineNo(),
450                                     ExtraData=CurrentLineOfItem.GetLineString())
451                    #
452                    # Validate Feature Flag Express
453                    #
454                    FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[5].strip())
455                    if not FeatureFlagRtv[0]:
456                        Logger.Error("InfParser",
457                                     ToolError.FORMAT_INVALID,
458                                     ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
459                                     File=CurrentLineOfItem.GetFileName(),
460                                     Line=CurrentLineOfItem.GetLineNo(),
461                                     ExtraData=CurrentLineOfItem.GetLineString())
462                    InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[5])
463                else:
464                    if ItemContent[5].strip() != '':
465                        Logger.Error("InfParser",
466                                     ToolError.FORMAT_INVALID,
467                                     ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % (ItemContent[5]),
468                                     File=CurrentLineOfItem.GetFileName(),
469                                     Line=CurrentLineOfItem.GetLineNo(),
470                                     ExtraData=CurrentLineOfItem.GetLineString())
471
472            if len(ItemContent) == 7:
473                if ItemContent[6].strip() == '':
474                    Logger.Error("InfParser",
475                                     ToolError.FORMAT_INVALID,
476                                     ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
477                                     File=CurrentLineOfItem.GetFileName(),
478                                     Line=CurrentLineOfItem.GetLineNo(),
479                                     ExtraData=CurrentLineOfItem.GetLineString())
480                #
481                # Validate Feature Flag Express
482                #
483                FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[6].strip())
484                if not FeatureFlagRtv[0]:
485                    Logger.Error("InfParser",
486                                 ToolError.FORMAT_INVALID,
487                                 ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
488                                 File=CurrentLineOfItem.GetFileName(),
489                                 Line=CurrentLineOfItem.GetLineNo(),
490                                 ExtraData=CurrentLineOfItem.GetLineString())
491                InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[6])
492
493            InfBianryCommonItemObj.SetSupArchList(__SupArchList)
494
495            #
496            # Determine binary file name duplicate. Follow below rule:
497            #
498            # A binary filename must not be duplicated within
499            # a [Binaries] section. A binary filename may appear in
500            # multiple architectural [Binaries] sections. A binary
501            # filename listed in an architectural [Binaries] section
502            # must not be listed in the common architectural
503            # [Binaries] section.
504            #
505            # NOTE: This check will not report error now.
506            #
507#            for Item in self.Binaries:
508#                if Item.GetFileName() == InfBianryCommonItemObj.GetFileName():
509#                    ItemSupArchList = Item.GetSupArchList()
510#                    for ItemArch in ItemSupArchList:
511#                        for ComItemObjArch in __SupArchList:
512#                            if ItemArch == ComItemObjArch:
513#                                #
514#                                # ST.ERR_INF_PARSER_ITEM_DUPLICATE
515#                                #
516#                                pass
517#
518#                            if ItemArch.upper() == 'COMMON' or ComItemObjArch.upper() == 'COMMON':
519#                                #
520#                                # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
521#                                #
522#                                pass
523
524            if InfBianryCommonItemObj != None:
525                if self.Binaries.has_key((InfBianryCommonItemObj)):
526                    BinariesList = self.Binaries[InfBianryCommonItemObj]
527                    BinariesList.append((InfBianryCommonItemObj, ItemComment))
528                    self.Binaries[InfBianryCommonItemObj] = BinariesList
529                else:
530                    BinariesList = []
531                    BinariesList.append((InfBianryCommonItemObj, ItemComment))
532                    self.Binaries[InfBianryCommonItemObj] = BinariesList
533
534    def SetBinary(self, UiInf=None, Ver=None, CommonBinary=None, ArchList=None):
535
536        __SupArchList = []
537        for ArchItem in ArchList:
538            #
539            # Validate Arch
540            #
541            if (ArchItem == '' or ArchItem == None):
542                ArchItem = 'COMMON'
543            __SupArchList.append(ArchItem)
544
545        if UiInf != None:
546            if len(UiInf) > 0:
547                #
548                # Check UI
549                #
550                for UiItem in UiInf:
551                    IsValidFileFlag = False
552                    InfBianryUiItemObj = None
553                    UiContent = UiItem[0]
554                    UiComment = UiItem[1]
555                    UiCurrentLine = UiItem[2]
556                    GlobalData.gINF_CURRENT_LINE = deepcopy(UiItem[2])
557                    #
558                    # Should not less than 2 elements
559                    #
560                    if len(UiContent) < 2:
561                        Logger.Error("InfParser",
562                                     ToolError.FORMAT_INVALID,
563                                     ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (UiContent[0], 2),
564                                     File=UiCurrentLine.GetFileName(),
565                                     Line=UiCurrentLine.GetLineNo(),
566                                     ExtraData=UiCurrentLine.GetLineString())
567                        return False
568
569                    if len(UiContent) > 4:
570                        Logger.Error("InfParser",
571                                     ToolError.FORMAT_INVALID,
572                                     ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (UiContent[0], 4),
573                                     File=UiCurrentLine.GetFileName(),
574                                     Line=UiCurrentLine.GetLineNo(),
575                                     ExtraData=UiCurrentLine.GetLineString())
576                        return False
577                    if len(UiContent) >= 2:
578                        #
579                        # Create an Ui Object.
580                        #
581                        InfBianryUiItemObj = InfBianryUiItem()
582                        if UiContent[0] != 'UI':
583                            Logger.Error("InfParser",
584                                         ToolError.FORMAT_INVALID,
585                                         ST.ERR_INF_PARSER_BINARY_VER_TYPE % ('UI'),
586                                         File=UiCurrentLine.GetFileName(),
587                                         Line=UiCurrentLine.GetLineNo(),
588                                         ExtraData=UiCurrentLine.GetLineString())
589                        InfBianryUiItemObj.SetUiTypeName(UiContent[0])
590                        InfBianryUiItemObj.SetType(UiContent[0])
591                        #
592                        # Verify File exist or not
593                        #
594                        FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
595                                                                                      UiContent[1])))
596                        if not (ValidFile(FullFileName) or ValidFile(UiContent[1])):
597                            Logger.Error("InfParser",
598                                         ToolError.FORMAT_INVALID,
599                                         ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (UiContent[1]),
600                                         File=UiCurrentLine.GetFileName(),
601                                         Line=UiCurrentLine.GetLineNo(),
602                                         ExtraData=UiCurrentLine.GetLineString())
603                        #
604                        # Validate file exist/format.
605                        #
606                        if IsValidPath(UiContent[1], GlobalData.gINF_MODULE_DIR):
607                            IsValidFileFlag = True
608                        else:
609                            Logger.Error("InfParser",
610                                         ToolError.FORMAT_INVALID,
611                                         ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (UiContent[1]),
612                                         File=UiCurrentLine.GetFileName(),
613                                         Line=UiCurrentLine.GetLineNo(),
614                                         ExtraData=UiCurrentLine.GetLineString())
615                            return False
616                        if IsValidFileFlag:
617                            UiContent[0] = ConvPathFromAbsToRel(UiContent[0], GlobalData.gINF_MODULE_DIR)
618                            InfBianryUiItemObj.SetFileName(UiContent[1])
619                    if len(UiContent) >= 3:
620                        #
621                        # Add Target information
622                        #
623                        InfBianryUiItemObj.SetTarget(UiContent[2])
624                    if len(UiContent) == 4:
625                        if UiContent[3].strip() == '':
626                            Logger.Error("InfParser",
627                                         ToolError.FORMAT_INVALID,
628                                         ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
629                                         File=UiCurrentLine.GetFileName(),
630                                         Line=UiCurrentLine.GetLineNo(),
631                                         ExtraData=UiCurrentLine.GetLineString())
632                        #
633                        # Validate Feature Flag Express
634                        #
635                        FeatureFlagRtv = IsValidFeatureFlagExp(UiContent[3].strip())
636                        if not FeatureFlagRtv[0]:
637                            Logger.Error("InfParser",
638                                         ToolError.FORMAT_INVALID,
639                                         ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
640                                         File=UiCurrentLine.GetFileName(),
641                                         Line=UiCurrentLine.GetLineNo(),
642                                         ExtraData=UiCurrentLine.GetLineString())
643                        InfBianryUiItemObj.SetFeatureFlagExp(UiContent[3])
644
645                    InfBianryUiItemObj.SetSupArchList(__SupArchList)
646
647                    #
648                    # Determine binary file name duplicate. Follow below rule:
649                    #
650                    # A binary filename must not be duplicated within
651                    # a [Binaries] section. A binary filename may appear in
652                    # multiple architectural [Binaries] sections. A binary
653                    # filename listed in an architectural [Binaries] section
654                    # must not be listed in the common architectural
655                    # [Binaries] section.
656                    #
657                    # NOTE: This check will not report error now.
658                    #
659#                    for Item in self.Binaries:
660#                        if Item.GetFileName() == InfBianryUiItemObj.GetFileName():
661#                            ItemSupArchList = Item.GetSupArchList()
662#                            for ItemArch in ItemSupArchList:
663#                                for UiItemObjArch in __SupArchList:
664#                                    if ItemArch == UiItemObjArch:
665#                                        #
666#                                        # ST.ERR_INF_PARSER_ITEM_DUPLICATE
667#                                        #
668#                                        pass
669#                                    if ItemArch.upper() == 'COMMON' or UiItemObjArch.upper() == 'COMMON':
670#                                        #
671#                                        # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
672#                                        #
673#                                        pass
674
675                    if InfBianryUiItemObj != None:
676                        if self.Binaries.has_key((InfBianryUiItemObj)):
677                            BinariesList = self.Binaries[InfBianryUiItemObj]
678                            BinariesList.append((InfBianryUiItemObj, UiComment))
679                            self.Binaries[InfBianryUiItemObj] = BinariesList
680                        else:
681                            BinariesList = []
682                            BinariesList.append((InfBianryUiItemObj, UiComment))
683                            self.Binaries[InfBianryUiItemObj] = BinariesList
684        if Ver != None and len(Ver) > 0:
685            self.CheckVer(Ver, __SupArchList)
686        if CommonBinary and len(CommonBinary) > 0:
687            self.ParseCommonBinary(CommonBinary, __SupArchList)
688
689        return True
690
691    def GetBinary(self):
692        return self.Binaries
693