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.100, mailfrom: bob.c.feng@intel.com) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Tue, 03 Sep 2019 19:10:27 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2019 19:10:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,465,1559545200"; d="scan'208";a="266493141" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga001.jf.intel.com with ESMTP; 03 Sep 2019 19:10:26 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 3 Sep 2019 19:10:26 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 3 Sep 2019 19:10:25 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.32]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.140]) with mapi id 14.03.0439.000; Wed, 4 Sep 2019 10:10:24 +0800 From: "Bob Feng" To: "devel@edk2.groups.io" , "leif.lindholm@linaro.org" CC: "Gao, Liming" Subject: Re: [edk2-devel] [edk2] [Patch 32/33] BaseTools: ECC tool Python3 adaption Thread-Topic: [edk2-devel] [edk2] [Patch 32/33] BaseTools: ECC tool Python3 adaption Thread-Index: AQHVYcDwyJrwuPgmb0q7VnQjpa41b6cYOOoAgAKHfBA= Date: Wed, 4 Sep 2019 02:10:23 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16152FF60@SHSMSX104.ccr.corp.intel.com> References: <20190129020610.14300-1-bob.c.feng@intel.com> <20190129020610.14300-33-bob.c.feng@intel.com> <20190902190211.GZ29255@bivouac.eciton.net> <20190902190438.GA29255@bivouac.eciton.net> In-Reply-To: <20190902190438.GA29255@bivouac.eciton.net> 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 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Leif, I have no Debian environment. On Debian, can python3 work with antlr3? I c= hecked the antlr3 python github repository, the source code is still in bet= a version and has not been updated for 7 years. But If yes, I think the import statement in ECC can be changed as: try: import antlr4 as antlr from Ecc.CParser4.CLexer import CLexer from Ecc.CParser4.CParser import CParser except: import antlr3 as antlr antlr.InputStream =3D antlr.StringStream from Ecc.CParser3.CLexer import CLexer from Ecc.CParser3.CParser import CParser=20 Thanks, Bob -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Leif= Lindholm Sent: Tuesday, September 3, 2019 3:05 AM To: Feng, Bob C Cc: devel@edk2.groups.io; Gao, Liming Subject: Re: [edk2-devel] [edk2] [Patch 32/33] BaseTools: ECC tool Python3= adaption Argh - forgot about the mailing list move, forwarding to current list. / Leif On Mon, Sep 02, 2019 at 08:02:11PM +0100, Leif Lindholm wrote: > Hi Bob, >=20 > I was running Ecc today, apparently for the first time since I=20 > switched to Python3 by default. >=20 > I have raised https://bugzilla.tianocore.org/show_bug.cgi?id=3D2148 over= = =20 > the way Python3 hard codes use of antlr4, whereas it seems to me it=20 > should be possible to ue Python3 with antlr3 (but not Python2 with=20 > antlr4). >=20 > However, whilst that issue could be looked at without extreme urgency,= =20 > I am curious as to what is causing the error I am seeing upon working=20 > around the import failure on my Debian installation (which lacks=20 > python3-antlr4). >=20 > The output I get when running > $ Ecc -t /work/git/edk2/EmbeddedPkg/Drivers/DtPlatformDxe/ -s >=20 > is >=20 > --- > /work/git/edk2/BaseTools/Source/Python/Ecc/EccMain.py:409: DeprecationWa= rning: time.clock has been deprecated in Python 3.3 and will be removed fro= m Python 3.8: use time.perf_counter or time.process_time instead > StartTime =3D time.clock() > 11:44:43, Sep.02 2019 [00:00] >=20 > Loading ECC configuration ... done > Building database for Meta Data File Done! > Parsing=20 > //work/git/edk2/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c > Traceback (most recent call last): > File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main > "__main__", mod_spec) > File "/usr/lib/python3.7/runpy.py", line 85, in _run_code > exec(code, run_globals) > File "/work/git/edk2/BaseTools/Source/Python/Ecc/EccMain.py", line 410= , in > Ecc =3D Ecc() > File "/work/git/edk2/BaseTools/Source/Python/Ecc/EccMain.py", line 94,= in __init__ > self.DetectOnlyScanDirs() > File "/work/git/edk2/BaseTools/Source/Python/Ecc/EccMain.py", line 130= , in DetectOnlyScanDirs > self.BuildDatabase() > File "/work/git/edk2/BaseTools/Source/Python/Ecc/EccMain.py", line 150= , in BuildDatabase > c.CollectSourceCodeDataIntoDB(EccGlobalData.gTarget) > File "/work/git/edk2/BaseTools/Source/Python/Ecc/c.py", line 526, in C= ollectSourceCodeDataIntoDB > collector.ParseFile() > File "/work/git/edk2/BaseTools/Source/Python/Ecc/CodeFragmentCollector= .py", line 517, in ParseFile > lexer =3D CLexer(cStream) > File "/work/git/edk2/BaseTools/Source/Python/Ecc/CParser3/CLexer.py", = line 147, in __init__ > Lexer.__init__(self, input) > File "/usr/lib/python3/dist-packages/antlr3/recognizers.py", line 1039= , in __init__ > BaseRecognizer.__init__(self, state) > File "/usr/lib/python3/dist-packages/antlr3/recognizers.py", line 169,= in __init__ > .format(self.api_version)) > RuntimeError: ANTLR version mismatch: The recognizer has been generated = with API V0, but this runtime does not support this. > --- >=20 > Any idea? >=20 > Best Regards, >=20 > Leif >=20 > On Tue, Jan 29, 2019 at 10:06:09AM +0800, Feng, Bob C wrote: > > v2: > > The python files under CParser4 are generated by antlr4 and for > > python3 usage. They have python3 specific syntax, for example the=20 > > data type declaration for the arguments of a function. That is not=20 > > compitable with python2. this patch is to remove these syntax. > >=20 > > ECC tool Python3 adaption. > >=20 > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Bob Feng > > Cc: Liming Gao > > --- > > BaseTools/Source/Python/Ecc/{ =3D> CParser3}/CLexer.py | 0 > > BaseTools/Source/Python/Ecc/{ =3D> CParser3}/CParser.py | 0 > > BaseTools/Source/Python/Ecc/CParser3/__init__.py | 0 > > BaseTools/Source/Python/Ecc/CParser4/C.g4 | 637 ++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++ > > BaseTools/Source/Python/Ecc/CParser4/CLexer.py | 632 ++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++ > > BaseTools/Source/Python/Ecc/CParser4/CListener.py | 815 ++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++ > > BaseTools/Source/Python/Ecc/CParser4/CParser.py | 6279 ++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++++++++++ > > + > > BaseTools/Source/Python/Ecc/CParser4/__init__.py | 0 > > BaseTools/Source/Python/Ecc/Check.py | 4 +- > > BaseTools/Source/Python/Ecc/CodeFragmentCollector.py | 20 +-- > > BaseTools/Source/Python/Ecc/Configuration.py | 3 - > > BaseTools/Source/Python/Ecc/EccMain.py | 2 +- > > BaseTools/Source/Python/Ecc/EccToolError.py | 4 +- > > BaseTools/Source/Python/Ecc/FileProfile.py | 2 +- > > BaseTools/Source/Python/Ecc/MetaDataParser.py | 2 +- > > BaseTools/Source/Python/Ecc/c.py | 6 +- > > BaseTools/Source/Python/Ecc/config.ini | 2 - > > 17 files changed, 8385 insertions(+), 23 deletions(-)