-
Notifications
You must be signed in to change notification settings - Fork 1
ECC tool
ECC is a python tool which helps to detect coding style issues.
It reports errors for the codes which don't follow EDK II C Coding Standards Specification.
ECC tool is located in edk2/BaseTools/Source/Python/Ecc.
Steps to run ECC tool:
1). Enter edk2 directory, run: edksetup.bat (on Windows)
Enter edk2 directory, run: source edksetup.sh (on Linux)
2). Then in edk2 directory, you can type "Ecc" to run ECC tool directly.
3). If you meet following errors:
Error 1:
import antlr3
ImportError: No module named antlr3
This error may be met when you run ECC tool with python 2.x, then ECC depends on antlr V3.0.1, you can download it from http://www.antlr3.org/download/Python/
After download and extract it, you can enter the antlr tool directory and run:
C:\Python27\python.exe setup.py install to install it.(on Windows)
python setup.py install to install it, root access may be required.(on Linux)
Error 2:
import antlr4 as antlr
ModuleNotFoundError: No module named 'antlr4'
This error may be met when you run ECC tool with python 3.x, then ECC depends on antlr4, you can install it through following command.
py -3 -m pip install antlr4-python3-runtime to install it.(on Windows)
sudo python3 -m pip install antlr4-python3-runtime to install it. (on Linux)
4). You can type "Ecc -h/Ecc --help" to get the help info of ECC tool.
5). Common usage model:
Ecc -c config file -e exception file -t the target directory which needs to be scanned by ECC -r the ECC scan result CSV file
(Notes: Please use the full path when specify the target directory to scan.)
config.ini and exception.xml are in edk2/BaseTools/Source/Python/Ecc dir.
Config.ini is the configuration file of ECC tool. If config file is not specified when run ECC, it will use the one in Edk2/BaseTools/Source/Python/Ecc directory by default.
exception.xml is used to skip some specific coding style issues.
For example, run ECC to check the coding style in Mdepkg:
Ecc –c D:/AWORK/edk2/BaseTools/Source/Python/Ecc/config.ini
-e D:/AWORK/edk2/BaseTools/Source/Python/Ecc/exception.xml -t D:/AWORK/edk2/MdePkg -r MdePkgECC.csv
(Notes: When running ECC for a specific sub-dir, it may report some errors such as some library instances are not used, but when running ECC for the whole project, these errors are gone. We can ignore such kind of error when running ECC for a specific sub-dir.)
6). You may need to maintain the config.ini and exception.xml files by yourself for your project.
a) If you want to skip to check some sub-dir or file, you can add them to the SkipDirList, SkipFileList part in the config.ini.
A list for skip dirs when scaning source code
SkipDirList = BUILD, ..., TEST\TEST
A list for skip file when scaning source code
SkipFileList = .gitignore,...
b) If you want to skip a specific ECC error, you can add them to the exception.xml file.
The mapping relationship between exception format and ECC error like below.