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