## @file
# This file is used to parse INF file of EDK project
#
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import os
from CommonDataClass.DataClass import *
from Common.Identification import *
from Parser import *
import Database
## EdkInfParser() class
#
# This class defined basic INF object which is used by inheriting
#
# @param object: Inherited from object class
#
## The constructor
#
# @param self: The object pointer
# @param Filename: INF file name
# @param Database: Eot database
# @param SourceFileList: A list for all source file belonging this INF file
# @param SourceOverridePath: Override path for source file
# @param Edk_Source: Envirnoment variable EDK_SOURCE
# @param Efi_Source: Envirnoment variable EFI_SOURCE
#
def __init__(self, Filename = None, Database = None, SourceFileList = None, SourceOverridePath = None, Edk_Source = None, Efi_Source = None):
# Load Inf file if filename is not None
if Filename != None:
if SourceFileList:
for Item in SourceFileList:
self.TblInf.Insert(MODEL_EFI_SOURCE_FILE, Item, '', '', '', '', 'COMMON', -1, self.FileID, -1, -1, -1, -1, 0)
## LoadInffile() method
#
# Load INF file and insert a record in database
#
# @param self: The object pointer
# @param Filename: Input value for filename of Inf file
#
# Insert a record for file
## ParserSource() method
#
# Parse Source section and insert records in database
#
# @param self: The object pointer
# @param CurrentSection: current section name
# @param SectionItemList: the item belonging current section
# @param ArchList: A list for arch for this section
# @param ThirdList: A list for third item for this section
#
if Arch == '':
for Item in SectionItemList:
self.TblInf.Insert(MODEL_META_DATA_HEADER, Name, Value, Third, '', '', Arch, -1, self.FileID, Item[1], -1, Item[1], -1, 0)
## ParseInf() method
#
# Parse INF file and get sections information
#
# @param self: The object pointer
# @param Lines: contents of INF file
# @param FileRelativePath: relative path of the file
# @param Filename: file name of INF file
#
[], [], TAB_UNKNOWN, [], [], []
LineNo = 0
if Line == '':
continue
# Parse the new section
SectionItemList = []
ArchList = []
ThirdList = []
# Parse section name
CurrentSection = ''
LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
if CurrentSection == '':
else:
EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo)
else:
continue
# Add a section item
# End of parse
#End of For
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
#
if __name__ == '__main__':
P = EdkInfParser(os.path.normpath("C:\Framework\Edk\Sample\Platform\Nt32\Dxe\PlatformBds\PlatformBds.inf"), Db, '', '')
print Inf