From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 209A6211F8888 for ; Wed, 27 Jun 2018 23:27:29 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2018 23:27:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,282,1526367600"; d="scan'208";a="240964065" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by fmsmga005.fm.intel.com with ESMTP; 27 Jun 2018 23:27:27 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Yunhua Feng , Liming Gao Date: Thu, 28 Jun 2018 14:27:23 +0800 Message-Id: <1530167244-27416-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch V2] BaseTools: Fix parsing multiple nest !include issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2018 06:27:29 -0000 From: Yunhua Feng Fix the bug !include file in Components subsection meet syntax error. Case example: DSC components: !include Test1.txt Test1.txt: TestPkg/TestDriver.inf { PcdToken.PcdTest1 | "A" !include Test2.txt } Test2.txt: !include Test3.txt Test3.txt: PcdToken.PcdTest2 | "B" Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- .../Source/Python/Workspace/MetaFileParser.py | 28 ++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 8c860d594b..75ca630806 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -942,11 +942,18 @@ 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() + TokenList = GetSplitValueList(Line, ' ', 1) + if TokenList[0].upper() == "!INCLUDE": + for Arch, ModuleType, DefaultStore in self._Scope: + if self._SubsectionType != MODEL_UNKNOWN and Arch in OwnerId: + self._Owner[-1] = OwnerId[Arch] + self._DirectiveParser() + else: + 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: @@ -963,11 +970,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], @@ -1188,10 +1195,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 @@ -1560,28 +1568,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.12.2.windows.2