Commit Graph
8 Commits
Author SHA1 Message Date
Oliver Smith-Dennyandmergify[bot] 35c03c1c9f BaseTools: Ecc: Update to ANTLR 4.13.2
ANTLR 4.9 is broken in python 3.13 because
it uses a library in the autogenerated files
that is removed.

This updates to 4.13.2 and also updates the autogen
files, which contain support for python 3.13 as well
as backwards compat.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-08 22:23:35 +00:00
Oliver Smith-Dennyandmergify[bot] 9b676f7cc2 BaseTools: Ecc: Use SPDX in AutoGen Template
The ANTLR autogen files are currently created
without an SPDX identifer. Add the BSD-2-Clause-Patent
ID.

While here, correct the command to do the autogeneration
by using the right filename.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-08 22:23:35 +00:00
Michael Kubackiandmergify[bot] ba8010bc6c BaseTools/Ecc: Apply CParser4 ANTLR 4.9 regeneration whitespace changes
Whitespace-only changes produced by the ANTLR 4.9 code generator.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-27 23:18:15 +00:00
Michael Kubackiandmergify[bot] ae24028512 BaseTools/Ecc: Regenerate CParser4 files with ANTLR 4.9
The CParser4 Python parser files (CLexer.py, CParser.py, CListener.py)
were generated 7 years ago with ANTLR 4.7.1.

Meanwhile, pip-requirements.txt pins antlr4-python3-runtime to version
4.9 in commit 4a7dd50, but the files were patched, not fully
regenerated. This version mismatch produced two failures when running
EccMain.py against non-trivial C code:

1. A runtime warning on every file parsed:
   "ANTLR runtime and generated code versions disagree: 4.9!=4.7.1"

2. A crash when parsing complex C constructs that exercise the
   struct/union definition rule in CParser.py:

   TypeError: '<' not supported between instances of 'tuple' and 'int'

   This occurs in antlr4/BufferedTokenStream.py getText() because the
   4.9 runtime changed the expected argument types for that method,
   and the 4.7.1-generated parser was passing a tuple where an int is
   now required.

This change regenerates the CParser4 files with ANTLR 4.9 to resolve
the version mismatch.

Steps used to regenerate the files:

  1. Download the ANTLR 4.9 complete tool JAR:
     - `https://www.antlr.org/download/antlr-4.9-complete.jar`

  2. Generate Python3 parser files from the grammar:

     ```
     java -jar antlr-4.9-complete.jar `
       -Dlanguage=Python3 -visitor `
       -o BaseTools/Source/Python/Ecc/CParser4_new `
       BaseTools/Source/Python/Ecc/CParser4/C.g4
     ```

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-27 23:18:15 +00:00
Pierre GondoisandLiming Gao f54fe78d9a BaseTools: Remove unused import
Running the vulture tool gave the following report.
Remove the unused import.

- BPDG/BPDG.py:21:
  unused import 'encodings' (90% confidence)
- build/build.py:61:
  unused import 'Manager' (90% confidence)
- Ecc/CParser4/CLexer.py:4:
  unused import 'TextIO' (90% confidence)
- Ecc/CParser4/CParser.py:5:
  unused import 'TextIO' (90% confidence)
- Eot/CParser4/CLexer.py:4:
  unused import 'TextIO' (90% confidence)
- Eot/CParser4/CParser.py:5:
  unused import 'TextIO' (90% confidence)
- Eot/EotMain.py:28:
  unused import 'ConvertGuid' (90% confidence)
- GenFds/FdfParser.py:16:
  unused import 'hexdigits' (90% confidence)
- Table/TableEotReport.py:16:
  unused import 'EotToolError' (90% confidence)
- UPT/Library/CommentGenerating.py:19:
  unused import 'USAGE_ITEM_NOTIFY' (90% confidence)
- UPT/Library/ParserValidate.py:18:
  unused import 'COMPONENT_TYPE_LIST' (90% confidence)
- UPT/Library/UniClassObject.py:25:
  unused import 'CheckUTF16FileHeader' (90% confidence)

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01 09:51:38 +08:00
Rebecca Cran a78f525634 BaseTools: Update CParser4 to import TextIO from typing
In Python 3.13 typing.io no longer exists.
Instead, import TextIO from typing.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2025-05-26 17:09:27 -06:00
Michael D Kinney 2e351cbe8e BaseTools: Replace BSD License with BSD+Patent License
https://bugzilla.tianocore.org/show_bug.cgi?id=1373

Replace BSD 2-Clause License with BSD+Patent License.  This change is
based on the following emails:

  https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html
  https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html

RFCs with detailed process for the license change:

  V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html
  V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html
  V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
2019-04-09 09:10:20 -07:00
Feng, Bob C c60377d7f9 BaseTools: ECC tool Python3 adaption
v2:
The python files under CParser4 are generated by antlr4 and for
python3 usage. They have python3 specific syntax, for example
the data type declaration for the arguments of a function. That
is not compitable with python2. this patch is to remove these syntax.

ECC tool Python3 adaption.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2019-02-01 11:09:25 +08:00