public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools:Evaluation of undefined macros in dsc files
@ 2019-01-16  6:56 Fan, ZhijuX
  2019-01-17  7:24 ` Feng, Bob C
  0 siblings, 1 reply; 2+ messages in thread
From: Fan, ZhijuX @ 2019-01-16  6:56 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: Gao, Liming, Feng, Bob C

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] BaseTools:Evaluation of undefined macros in dsc files
  2019-01-16  6:56 [PATCH] BaseTools:Evaluation of undefined macros in dsc files Fan, ZhijuX
@ 2019-01-17  7:24 ` Feng, Bob C
  0 siblings, 0 replies; 2+ messages in thread
From: Feng, Bob C @ 2019-01-17  7:24 UTC (permalink / raw)
  To: Fan, ZhijuX, edk2-devel@lists.01.org; +Cc: Gao, Liming

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-17  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox