BaseTools: Nested !include support in DSC and FDF files

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cecil Sheng <cecil.sheng@hp.com>
Reviewed-by: Samer El-Haj-Mahmoud <elhaj@hp.com>
Reviewed-by: Yingke Liu <yingke.d.liu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18317 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Cecil Sheng
2015-08-26 06:28:59 +00:00
committed by yingke
parent 5ca29abe52
commit 118bf0960c
2 changed files with 91 additions and 19 deletions

View File

@ -2,6 +2,7 @@
# This file is used to parse meta files
#
# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<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
@ -1010,11 +1011,6 @@ class DscParser(MetaFileParser):
File=self.MetaFile, Line=self._LineIndex + 1,
ExtraData=self._CurrentLine)
self._DirectiveStack.append((ItemType, self._LineIndex + 1, self._CurrentLine))
elif self._From > 0:
EdkLogger.error('Parser', FORMAT_INVALID,
"No '!include' allowed in included file",
ExtraData=self._CurrentLine, File=self.MetaFile,
Line=self._LineIndex + 1)
#
# Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1,
@ -1479,6 +1475,12 @@ class DscParser(MetaFileParser):
Parser = DscParser(IncludedFile1, self._FileType, IncludedFileTable,
Owner=Owner, From=Owner)
# Does not allow lower level included file to include upper level included file
if Parser._From != Owner and int(Owner) > int (Parser._From):
EdkLogger.error('parser', FILE_ALREADY_EXIST, File=self._FileWithError,
Line=self._LineIndex + 1, ExtraData="{0} is already included at a higher level.".format(IncludedFile1))
# set the parser status with current status
Parser._SectionName = self._SectionName
Parser._SectionType = self._SectionType