public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Carsey, Jaben" <jaben.carsey@intel.com>
To: "Zhu, Yonghong" <yonghong.zhu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Feng, YunhuaX" <yunhuax.feng@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [Patch V2] BaseTools: Fix parsing multiple nest !include issue
Date: Thu, 28 Jun 2018 20:48:16 +0000	[thread overview]
Message-ID: <CB6E33457884FA40993F35157061515CA40C6E2C@FMSMSX103.amr.corp.intel.com> (raw)
In-Reply-To: <1530167244-27416-1-git-send-email-yonghong.zhu@intel.com>

If you change the raw string ("!INCLUDE) to use the one defined in DataType.py (TAB_INCLUDE), then I like it.  Note that you will need to lower() instead of upper() to support this change.

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Yonghong Zhu
> Sent: Wednesday, June 27, 2018 11:27 PM
> To: edk2-devel@lists.01.org
> Cc: Feng, YunhuaX <yunhuax.feng@intel.com>; Gao, Liming
> <liming.gao@intel.com>
> Subject: [edk2] [Patch V2] BaseTools: Fix parsing multiple nest !include issue
> 
> From: Yunhua Feng <yunhuax.feng@intel.com>
> 
> Fix the bug !include file in Components subsection meet syntax error.
> 
> 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      | 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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2018-06-28 20:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28  6:27 [Patch V2] BaseTools: Fix parsing multiple nest !include issue Yonghong Zhu
2018-06-28 20:48 ` Carsey, Jaben [this message]
2018-06-29  5:41   ` Zhu, Yonghong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CB6E33457884FA40993F35157061515CA40C6E2C@FMSMSX103.amr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox