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.120; helo=mga04.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 41DCE211B6C32 for ; Wed, 16 Jan 2019 23:24:21 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 23:24:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,488,1539673200"; d="scan'208";a="126718927" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 16 Jan 2019 23:24:20 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 16 Jan 2019 23:24:20 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 16 Jan 2019 23:24:19 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.196]) by shsmsx102.ccr.corp.intel.com ([169.254.2.63]) with mapi id 14.03.0415.000; Thu, 17 Jan 2019 15:24:17 +0800 From: "Feng, Bob C" To: "Fan, ZhijuX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [edk2][PATCH] BaseTools:Evaluation of undefined macros in dsc files Thread-Index: AdStaI8lWmbEXyltRuiPpjUYNCoJ0AAzPk3A Date: Thu, 17 Jan 2019 07:24:16 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16005CEE5@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Thu, 17 Jan 2019 07:24:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Fan, ZhijuX=20 Sent: Wednesday, January 16, 2019 2:56 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Feng, Bob C Subject: [edk2][PATCH] BaseTools:Evaluation of undefined macros in dsc file= s BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=3D989 doc:If macro that is not defined is used in locations that are not expressi= ons (where the tools would just do macro expansion as in C flags in a [Buil= dOptions] 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 pr= ocess. 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 gM= acroPattern =3D re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE) - +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: -- 2.14.1.windows.1