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