From: "Gao, Liming" <liming.gao@intel.com>
To: "Zhu, Yonghong" <yonghong.zhu@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch] BaseTools: Extend the Macro used in the FDF !include statement
Date: Mon, 23 Jan 2017 02:29:14 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D6D28CD@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1485055691-106076-1-git-send-email-yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Sunday, January 22, 2017 11:28 AM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: Extend the Macro used in the FDF !include
>statement
>
>Current it only support the system environment variables in the !include
>statement, $(WORKSPACE), $(PACKAGES_PATH), $(EFI_SOURCE),
>$(EDK_SOURCE),
>$(ECP_SOURCE), this patch extend the usage to support the Global macros
>and the macro which defined before the statement.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> BaseTools/Source/Python/GenFds/FdfParser.py | 41
>+++++++++++++++++++++--------
> 1 file changed, 30 insertions(+), 11 deletions(-)
>
>diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py
>b/BaseTools/Source/Python/GenFds/FdfParser.py
>index e1295f2..27688e2 100644
>--- a/BaseTools/Source/Python/GenFds/FdfParser.py
>+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
>@@ -618,31 +618,50 @@ class FdfParser:
> # @param self The object pointer
> #
> def PreprocessIncludeFile(self):
> # nested include support
> Processed = False
>+ MacroDict = {}
> while self.__GetNextToken():
>
>- if self.__Token == '!include':
>+ if self.__Token == 'DEFINE':
>+ if not self.__GetNextToken():
>+ raise Warning("expected Macro name", self.FileName,
>self.CurrentLineNumber)
>+ Macro = self.__Token
>+ if not self.__IsToken( "="):
>+ raise Warning("expected '='", self.FileName,
>self.CurrentLineNumber)
>+ Value = self.__GetExpression()
>+ MacroDict[Macro] = Value
>+
>+ elif self.__Token == '!include':
> Processed = True
> IncludeLine = self.CurrentLineNumber
> IncludeOffset = self.CurrentOffsetWithinLine - len('!include')
> if not self.__GetNextToken():
> raise Warning("expected include file name", self.FileName,
>self.CurrentLineNumber)
> IncFileName = self.__Token
>- __IncludeMacros = {}
>- for Macro in ['WORKSPACE', 'ECP_SOURCE', 'EFI_SOURCE',
>'EDK_SOURCE']:
>+ PreIndex = 0
>+ StartPos = IncFileName.find('$(', PreIndex)
>+ EndPos = IncFileName.find(')', StartPos+2)
>+ while StartPos != -1 and EndPos != -1:
>+ Macro = IncFileName[StartPos+2 : EndPos]
> MacroVal = self.__GetMacroValue(Macro)
>- if MacroVal:
>- __IncludeMacros[Macro] = MacroVal
>+ if not MacroVal:
>+ if Macro in MacroDict:
>+ MacroVal = MacroDict[Macro]
>+ if MacroVal != None:
>+ IncFileName = IncFileName.replace('$(' + Macro + ')', MacroVal, 1)
>+ if MacroVal.find('$(') != -1:
>+ PreIndex = StartPos
>+ else:
>+ PreIndex = StartPos + len(MacroVal)
>+ else:
>+ raise Warning("The Macro %s is not defined" %Macro,
>self.FileName, self.CurrentLineNumber)
>+ StartPos = IncFileName.find('$(', PreIndex)
>+ EndPos = IncFileName.find(')', StartPos+2)
>
>- try:
>- IncludedFile = NormPath(ReplaceMacro(IncFileName,
>__IncludeMacros, RaiseError=True))
>- except:
>- raise Warning("only these system environment variables are
>permitted to start the path of the included file: "
>- "$(WORKSPACE), $(ECP_SOURCE), $(EFI_SOURCE),
>$(EDK_SOURCE)",
>- self.FileName, self.CurrentLineNumber)
>+ IncludedFile = NormPath(IncFileName)
> #
> # First search the include file under the same directory as FDF file
> #
> IncludedFile1 = PathClass(IncludedFile,
>os.path.dirname(self.FileName))
> ErrorCode = IncludedFile1.Validate()[0]
>--
>2.6.1.windows.1
prev parent reply other threads:[~2017-01-23 2:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-22 3:28 [Patch] BaseTools: Extend the Macro used in the FDF !include statement Yonghong Zhu
2017-01-23 2:29 ` Gao, Liming [this message]
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=4A89E2EF3DFEDB4C8BFDE51014F606A14D6D28CD@shsmsx102.ccr.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