public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Feng, Bob C" <bob.c.feng@intel.com>
To: "Fan, ZhijuX" <zhijux.fan@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH] BaseTools:Evaluation of undefined macros in dsc files
Date: Thu, 17 Jan 2019 07:24:16 +0000	[thread overview]
Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16005CEE5@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <FAD0D7E0AE0FA54D987F6E72435CAFD50AF11A1E@SHSMSX101.ccr.corp.intel.com>

Reviewed-by: Bob Feng <bob.c.feng@intel.com>

-----Original Message-----
From: Fan, ZhijuX 
Sent: Wednesday, January 16, 2019 2:56 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>
Subject: [edk2][PATCH] BaseTools:Evaluation of undefined macros in dsc files

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=989

doc:If macro that is not defined is used in locations that are not expressions (where the tools would just do macro expansion as in C flags in a [BuildOptions] section), nothing will be emitted.

This is in fact not what happens.Instead, the text
$(MACRO1) is emitted verbatim into the Makefile and left the for make to process.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
---
 BaseTools/Source/Python/AutoGen/GenMake.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 4da10e3950..fe07564bb3 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -34,7 +34,7 @@ gIncludePattern = re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r
 
 ## Regular expression for matching macro used in header file inclusion  gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
-
+gMacroRePattern = re.compile('.*?(\$\(\w*?\)).*?')
 gIsFileMap = {}
 
 ## pattern for include style in Edk.x code @@ -517,7 +517,21 @@ cleanlib:
                         continue
                     # Remove duplicated include path, if any
                     if Attr == "FLAGS":
-                        Value = RemoveDupOption(Value, IncPrefix, MyAgo.IncludePathList)
+                        Value = ValueCopy = RemoveDupOption(Value, IncPrefix, MyAgo.IncludePathList)
+                        while (ValueCopy.find('$(') != -1):
+                            for macro in self._AutoGenObject.Macros:
+                                MacroName = '$(' + macro + ')'
+                                if (ValueCopy.find(MacroName) != -1):
+                                    ValueCopy = ValueCopy.replace(MacroName, self._AutoGenObject.Macros[macro])
+                                    break
+                            else:
+                                if gMacroRePattern.search(ValueCopy, re.UNICODE):
+                                    FlageReList = gMacroRePattern.findall(ValueCopy, re.UNICODE)
+                                    for FlageRe in FlageReList:
+                                        Value = Value.replace(FlageRe, '').strip()
+                                    break
+                                else:
+                                    break
                         if Tool == "OPTROM" and PCI_COMPRESS_Flag:
                             ValueList = Value.split()
                             if ValueList:
--
2.14.1.windows.1



      reply	other threads:[~2019-01-17  7:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16  6:56 [PATCH] BaseTools:Evaluation of undefined macros in dsc files Fan, ZhijuX
2019-01-17  7:24 ` Feng, Bob C [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=08650203BA1BD64D8AD9B6D5D74A85D16005CEE5@SHSMSX101.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