## @file
# This file contained the miscellaneous functions for INF parser
#
# Copyright (c) 2011, 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.
#
'''
InfParserMisc
'''
##
# Import Modules
#
import re
#
# Global variable
#
#
# Sections can exist in INF file
#
gINF_SECTION_DEF = {
#
# EDK1 section
# TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE
#
}
## InfExpandMacro
#
# Expand MACRO definition with MACROs defined in [Defines] section and specific section.
# The MACROs defined in specific section has high priority and will be expanded firstly.
#
# @param LineInfo Contain information of FileName, LineContent, LineNo
# @param GlobalMacros MACROs defined in INF [Defines] section
# @param SectionMacros MACROs defined in INF specific section
# @param Flag If the flag set to True, need to skip macros in a quoted string
#
if GlobalMacros == None:
GlobalMacros = {}
if SectionMacros == None:
SectionMacros = {}
#
# First, replace MARCOs with value defined in specific section
#
(LineContent, LineNo),
Flag)
#
# Then replace MARCOs with value defined in [Defines] section
#
(LineContent, LineNo),
Flag)
#
# no macro found in String, stop replacing
#
return Content
else:
#
# Still have MACROs can't be expanded.
#
return Content
## IsBinaryInf
#
# Judge whether the INF file is Binary INF or Common INF
#
# @param FileLineList A list contain all INF file content.
#
if not FileLineList:
return False
for Line in FileLineList:
return False
return True
return False
## IsLibInstanceInfo
#
# Judge whether the string contain the information of ## @LIB_INSTANCES.
#
# @param String
#
# @return Flag
#
return True
else:
return False
## IsAsBuildOptionInfo
#
# Judge whether the string contain the information of ## @ASBUILD.
#
# @param String
#
# @return Flag
#
return True
else:
return False
#
# Macros defined in [Define] section are file scope global
#
self.FileLocalMacros = {}
#
# Current Section Header content.
#
self.SectionHeaderContent = []
#
# Last time Section Header content.
#
self.InfDefSection = None
self.InfBuildOptionSection = None
self.InfLibraryClassSection = None
self.InfPackageSection = None
self.InfPcdSection = None
self.InfSourcesSection = None
self.InfUserExtensionSection = None
self.InfProtocolSection = None
self.InfPpiSection = None
self.InfGuidSection = None
self.InfDepexSection = None
self.InfPeiDepexSection = None
self.InfDxeDepexSection = None
self.InfSmmDepexSection = None
self.InfBinariesSection = None
self.InfSpecialCommentSection = None