Reviewed-by: Bob Feng <bob.c.f...@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....@intel.com>; Feng, Bob C <bob.c.f...@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.f...@intel.com> Cc: Liming Gao <liming....@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux....@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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel