From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: liming.gao@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Thu, 19 Sep 2019 22:39:55 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2019 22:39:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,527,1559545200"; d="scan'208";a="388545411" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 19 Sep 2019 22:39:54 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 19 Sep 2019 22:39:53 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 19 Sep 2019 22:39:53 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.32]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.53]) with mapi id 14.03.0439.000; Fri, 20 Sep 2019 13:39:51 +0800 From: "Liming Gao" To: "Feng, Bob C" , "devel@edk2.groups.io" Subject: Re: [Patch 1/3] BaseTools: Improve GetDependencyList function Thread-Topic: [Patch 1/3] BaseTools: Improve GetDependencyList function Thread-Index: AQHVZ7iFiqOIMfxpnEG3YMTnkfjzAac0G44A Date: Fri, 20 Sep 2019 05:39:51 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4FF286@SHSMSX104.ccr.corp.intel.com> References: <20190910091650.33060-1-bob.c.feng@intel.com> In-Reply-To: <20190910091650.33060-1-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTY3OGFiODQtOTVjZC00ZjdlLWJhNDYtMWEwY2RlMDhkNmFiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidkR1SkFZUzUrb1RMRjRtbHdBVndST3B6R2luQ0psZ3JwYW4wNWhxclgyRmRuTVRuUERNTWNTRVljN2hxV2VhTiJ9 dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Bob: I find this patch will cause the dependent header files not be listed in = module Makefile.=20 Then, it will cause the incremental build issue. I don't think this is a = good fix.=20 =20 I will send the patch to revert this change.=20 Thanks Liming > -----Original Message----- > From: Feng, Bob C > Sent: Tuesday, September 10, 2019 5:17 PM > To: devel@edk2.groups.io > Cc: Gao, Liming ; Feng, Bob C > Subject: [Patch 1/3] BaseTools: Improve GetDependencyList function >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2102 >=20 > GetDependencyList get the header file via > re.findall in the whole header file. >=20 > This patch is to pre-process the header file and > to feed the shorter string to re.findall. >=20 > This patch is to improve GetDependencyList() efficiency >=20 > Cc: Liming Gao > Signed-off-by: Bob Feng > --- > BaseTools/Source/Python/AutoGen/GenMake.py | 29 ++++++++++++---------- > 1 file changed, 16 insertions(+), 13 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Sourc= e/Python/AutoGen/GenMake.py > index 47dae82e1aeb..5d02d9a05694 100755 > --- a/BaseTools/Source/Python/AutoGen/GenMake.py > +++ b/BaseTools/Source/Python/AutoGen/GenMake.py > @@ -1690,26 +1690,29 @@ def GetDependencyList(AutoGenObject, FileCache, F= ile, ForceList, SearchPathList) > CurrentFileDependencyList =3D [] > if F in DepDb: > CurrentFileDependencyList =3D DepDb[F] > else: > try: > - Fd =3D open(F.Path, 'rb') > - FileContent =3D Fd.read() > - Fd.close() > + with open(F.Path, 'rb') as Fd: > + FileContent =3D Fd.read(1) > + Fd.seek(0) > + if not FileContent: > + continue > + if FileContent[0] =3D=3D 0xff or FileContent[0] =3D= =3D 0xfe: > + FileContent2 =3D Fd.read() > + FileContent2 =3D FileContent2.decode('utf-16') > + IncludedFileList =3D gIncludePattern.findall(Fil= eContent2) > + else: > + FileLines =3D Fd.readlines() > + FileContent2 =3D [line for line in FileLines if = str(line).lstrip("#\t ")[:8] =3D=3D "include "] > + simpleFileContent=3D"".join(FileContent2) > + > + IncludedFileList =3D gIncludePattern.findall(sim= pleFileContent) > except BaseException as X: > EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3D= F.Path + "\n\t" + str(X)) > - if len(FileContent) =3D=3D 0: > + if not FileContent: > continue > - try: > - if FileContent[0] =3D=3D 0xff or FileContent[0] =3D=3D 0= xfe: > - FileContent =3D FileContent.decode('utf-16') > - else: > - FileContent =3D FileContent.decode() > - except: > - # The file is not txt file. for example .mcb file > - continue > - IncludedFileList =3D gIncludePattern.findall(FileContent) >=20 > for Inc in IncludedFileList: > Inc =3D Inc.strip() > # if there's macro used to reference header file, expand= it > HeaderList =3D gMacroPattern.findall(Inc) > -- > 2.20.1.windows.1