From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=zhijux.fan@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ADCCB210F16D1 for ; Tue, 15 Jan 2019 22:56:14 -0800 (PST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2019 22:56:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,485,1539673200"; d="dat'59?scan'59,208,59";a="118869241" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga003.jf.intel.com with ESMTP; 15 Jan 2019 22:56:13 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 15 Jan 2019 22:56:13 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 15 Jan 2019 22:56:13 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.196]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.150]) with mapi id 14.03.0415.000; Wed, 16 Jan 2019 14:56:11 +0800 From: "Fan, ZhijuX" To: "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Feng, Bob C" Thread-Topic: [edk2][PATCH] BaseTools:Evaluation of undefined macros in dsc files Thread-Index: AdStaI8lWmbEXyltRuiPpjUYNCoJ0A== Date: Wed, 16 Jan 2019 06:56:10 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [PATCH] BaseTools:Evaluation of undefined macros in dsc files X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2019 06:56:14 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=3D989 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 Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan --- 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 =3D re.compile(r"^[ \t]*[#%]?[ \t]*includ= e(?:[ \t]*(?:\\(?:\r\n|\r =20 ## Regular expression for matching macro used in header file inclusion gMacroPattern =3D re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICOD= E) - +gMacroRePattern =3D re.compile('.*?(\$\(\w*?\)).*?') gIsFileMap =3D {} =20 ## pattern for include style in Edk.x code @@ -517,7 +517,21 @@ cleanlib: continue # Remove duplicated include path, if any if Attr =3D=3D "FLAGS": - Value =3D RemoveDupOption(Value, IncPrefix, MyAgo.= IncludePathList) + Value =3D ValueCopy =3D RemoveDupOption(Value, Inc= Prefix, MyAgo.IncludePathList) + while (ValueCopy.find('$(') !=3D -1): + for macro in self._AutoGenObject.Macros: + MacroName =3D '$(' + macro + ')' + if (ValueCopy.find(MacroName) !=3D -1): + ValueCopy =3D ValueCopy.replace(MacroN= ame, self._AutoGenObject.Macros[macro]) + break + else: + if gMacroRePattern.search(ValueCopy, re.UN= ICODE): + FlageReList =3D gMacroRePattern.findal= l(ValueCopy, re.UNICODE) + for FlageRe in FlageReList: + Value =3D Value.replace(FlageRe, '= ').strip() + break + else: + break if Tool =3D=3D "OPTROM" and PCI_COMPRESS_Flag: ValueList =3D Value.split() if ValueList: --=20 2.14.1.windows.1