* [Patch] BaseTools: Fix parsing multiple nest !include issue
@ 2018-06-25 0:47 Yonghong Zhu
0 siblings, 0 replies; only message in thread
From: Yonghong Zhu @ 2018-06-25 0:47 UTC (permalink / raw)
To: edk2-devel; +Cc: Yunhua Feng, Liming Gao
From: Yunhua Feng <yunhuax.feng@intel.com>
Case example:
DSC components:
!include Test1.txt
Test1.txt:
TestPkg/TestDriver.inf {
<PcdsFixedAtBuild>
PcdToken.PcdTest1 | "A"
!include Test2.txt
}
Test2.txt:
!include Test3.txt
Test3.txt:
PcdToken.PcdTest2 | "B"
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
.../Source/Python/Workspace/MetaFileParser.py | 24 ++++++++--------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 88c7bb3..f03b264 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -941,11 +941,14 @@ class DscParser(MetaFileParser):
# subsection header
elif Line[0] == TAB_OPTION_START and Line[-1] == TAB_OPTION_END:
self._SubsectionType = MODEL_META_DATA_SUBSECTION_HEADER
# directive line
elif Line[0] == '!':
- self._DirectiveParser()
+ for Arch, ModuleType, DefaultStore in self._Scope:
+ if self._SubsectionType != MODEL_UNKNOWN and Arch in OwnerId:
+ self._Owner[-1] = OwnerId[Arch]
+ self._DirectiveParser()
continue
if Line[0] == TAB_OPTION_START and not self._InSubsection:
EdkLogger.error("Parser", FILE_READ_FAILURE, "Missing the '{' before %s in Line %s" % (Line, Index+1),ExtraData=self.MetaFile)
if self._InSubsection:
@@ -962,11 +965,11 @@ class DscParser(MetaFileParser):
# Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1,
# LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1
#
for Arch, ModuleType, DefaultStore in self._Scope:
Owner = self._Owner[-1]
- if self._SubsectionType != MODEL_UNKNOWN:
+ if self._SubsectionType != MODEL_UNKNOWN and Arch in OwnerId:
Owner = OwnerId[Arch]
self._LastItem = self._Store(
self._ItemType,
self._ValueList[0],
self._ValueList[1],
@@ -1187,10 +1190,11 @@ class DscParser(MetaFileParser):
@ParseMacro
def _ComponentParser(self):
if self._CurrentLine[-1] == '{':
self._ValueList[0] = self._CurrentLine[0:-1].strip()
self._InSubsection = True
+ self._SubsectionType = MODEL_UNKNOWN
else:
self._ValueList[0] = self._CurrentLine
## [LibraryClasses] section
@ParseMacro
@@ -1559,28 +1563,18 @@ class DscParser(MetaFileParser):
self.IncludedFiles.add (IncludedFile1)
# set the parser status with current status
Parser._SectionName = self._SectionName
- if self._InSubsection:
- Parser._SectionType = self._SubsectionType
- else:
- Parser._SectionType = self._SectionType
+ Parser._SubsectionType = self._SubsectionType
+ Parser._InSubsection = self._InSubsection
+ Parser._SectionType = self._SectionType
Parser._Scope = self._Scope
Parser._Enabled = self._Enabled
# Parse the included file
Parser.Start()
- # update current status with sub-parser's status
- self._SectionName = Parser._SectionName
- if not self._InSubsection:
- self._SectionType = Parser._SectionType
- self._SubsectionType = Parser._SubsectionType
- self._InSubsection = Parser._InSubsection
-
- self._Scope = Parser._Scope
- self._Enabled = Parser._Enabled
# Insert all records in the table for the included file into dsc file table
Records = IncludedFileTable.GetAll()
if Records:
self._Content[self._ContentIndex:self._ContentIndex] = Records
--
2.6.1.windows.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-06-25 0:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-25 0:47 [Patch] BaseTools: Fix parsing multiple nest !include issue Yonghong Zhu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox