UEFI 代码检查工具Ecc

1、Ecc介绍:
Ecc工具是去帮助检查ueif coding style代码规范的,将代码中不符合uefi代码规范风格的daima给检查并输出,官网介绍wiki:
https://github.com/tianocore/tianocore.github.io/wiki/ECC-tool
Ecc工具目录:
edk2/BaseTools/Source/Python/Ecc
初次使用Ecc:
1、在edk2目录下执行source edksetup.sh
2、执行Ecc --help查看Ecc是否可执行,一般会有如下报错:
wmail@ubuntu:~/uefi/edk2$ source edksetup.sh
Loading previous configuration from /home/wmail/uefi/edk2/Conf/BuildEnv.sh
WORKSPACE: /home/wmail/uefi/edk2
EDK_TOOLS_PATH: /home/wmail/uefi/edk2/BaseTools
CONF_PATH: /home/wmail/uefi/edk2/Conf
wmail@ubuntu:~/uefi/edk2$
wmail@ubuntu:~/uefi/edk2$ Ecc
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/wmail/uefi/edk2/BaseTools/Source/Python/Ecc/EccMain.py”, line 19, in
from Ecc.Check import Check
File “/home/wmail/uefi/edk2/BaseTools/Source/Python/Ecc/Check.py”, line 15, in
from Ecc import c
File “/home/wmail/uefi/edk2/BaseTools/Source/Python/Ecc/c.py”, line 14, in
from Ecc import CodeFragmentCollector
File “/home/wmail/uefi/edk2/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py”, line 19, in
import antlr4 as antlr
ModuleNotFoundError: No module named ‘antlr4’
wmail@ubuntu:~/uefi/edk2$

会提示antlr4工具没有安装,根据提示安装。

2、Ecc安装步骤:
个人使用Ecc时安装了这些:Setuptools(antlr4依赖)、antlr4、python3.5.2以上版本

3、python3安装:
python3下载地址:
https://www.python.org/downloads/source/

解压文件:
tar -xvJf Python-3.8.2.tar.xz
安装:
./configure --prefix=/usr/local/Python3/ 指定python3.8安装目录
make && make install 编译、安装python3.8

make过程中发生错误:
<1>can’t decompress data; zlib not available
因为一些包没有安装,安装zlib包:
apt-get install zlib*

<2>No module named ‘_ctypes’
apt-get install libffi-dev

<3>subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1
将/usr/bin/下的lsb_release删除或者重命名

<4>No module named '_sqlite3
下载sqlite包:https://www.sqlite.org/download.html
解压:
tar -zxvf sqlite-autoconf-3310100.tar.gz
安装:
./configure
make && make install

**注意:**每次安装一个库之后,都需要再make && make install编译安装python

python3.8环境配置:
python3旧环境,在/usr/bin/下,通过ll python*查看
在这里插入图片描述
删除原先的python3软连接 rm -rf python3
备份原先的python3执行文件(多版本python3会冲突) mv python3.6 python3.6_old
链接我们安装的python3.8 ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
验证 使用python3查看版本是否已经安装更换:

4、Setuptools安装:
package下载地址:
https://pypi.org/project/setuptools/

解压文件:
unzip setuptools-46.1.1.zip

安装:
python3 setup.py install

5、antlr4安装:
python3使用的antlr4下载地址:
https://pypi.org/project/antlr4-python3-runtime/#files

解压文件:
tar -zxvf antlr4-python3-runtime-4.8.tar.gz

安装:
python3 setup.py install

6、Ecc使用:
Ecc工具所依赖的python和其模块都已安装,Ecc -h查看,可以显示Ecc工具的help,说明Ecc可以使用
Ecc使用参数方法:
Ecc -c config file -e exception file -t the target directory which need to be scanned by ECC -r the ECC scan result csv file
config file使用Ecc的自带config: edk2/BaseTools/Source/Python/Ecc/Config.ini
exception file位置在 edk2/BaseTools/Source/Python/Ecc/exception.xml

例如:
Ecc –c BaseTools/Source/Python/Ecc/config.ini -e BaseTools/Source/Python/Ecc/exception.xml -t ~/uefi/edk2/MdePkg/ -r MdePkgECC.csv
注意:-t后面的检查目录需要绝对路径,如果只想检查source源码,可以在添加参数-s

Ecc 参数:
wmail@ubuntu:~/uefi/edk2$ Ecc -h
Usage: build.exe [options] [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]

Copyright © 2007 - 2018, Intel Corporation All rights reserved.

Options:
–version show program’s version number and exit
-h, --help show this help message and exit
-a TARGETARCH, --arch=TARGETARCH
ARCHS is one of list: IA32, X64, ARM, AARCH64 or EBC,
which overrides target.txt’s TARGET_ARCH definition.
To specify more archs, please repeat this option.
-p PLATFORMFILE, --platform=PLATFORMFILE
Build the platform specified by the DSC file name
argument, overriding target.txt’s ACTIVE_PLATFORM
definition.
-m MODULEFILE, --module=MODULEFILE
Build the module specified by the INF file name
argument.
-b BUILDTARGET, --buildtarget=BUILDTARGET
Using the TARGET to build the platform, overriding
target.txt’s TARGET definition.
-t TOOLCHAIN, --tagname=TOOLCHAIN
Using the Tool Chain Tagname to build the platform,
overriding target.txt’s TOOL_CHAIN_TAG definition.
-x SKUID, --sku-id=SKUID
Using this name of SKU ID to build the platform,
overriding SKUID_IDENTIFIER in DSC file.
-n THREADNUMBER Build the platform using multi-threaded compiler. The
value overrides target.txt’s
MAX_CONCURRENT_THREAD_NUMBER. When value is set to 0,
tool automatically detect number of processor threads,
set value to 1 means disable multi-thread build, and
set value to more than 1 means user specify the
threads number to build.
-f FDFFILE, --fdf=FDFFILE
The name of the FDF file to use, which overrides the
setting in the DSC file.
-r ROMIMAGE, --rom-image=ROMIMAGE
The name of FD to be generated. The name must be from
[FD] section in FDF file.
-i FVIMAGE, --fv-image=FVIMAGE
The name of FV to be generated. The name must be from
[FV] section in FDF file.
-C CAPNAME, --capsule-image=CAPNAME
The name of Capsule to be generated. The name must be
from [Capsule] section in FDF file.
-u, --skip-autogen Skip AutoGen step.
-e, --re-parse Re-parse all meta-data files.
-c, --case-insensitive
Don’t check case of file name.
-w, --warning-as-error
Treat warning in tools as error.
-j LOGFILE, --log=LOGFILE
Put log in specified file as well as on console.
-s, --silent Make use of silent mode of (n)make.
-q, --quiet Disable all messages except FATAL ERRORS.
-v, --verbose Turn on verbose output with informational messages
printed, including library instances selected, final
dependency expression, and warning messages, etc.
-d DEBUG, --debug=DEBUG
Enable debug messages at specified level.
-D MACROS, --define=MACROS
Macro: “Name [= Value]”.
-y REPORTFILE, --report-file=REPORTFILE
Create/overwrite the report to the specified filename.
-Y REPORTTYPE, --report-type=REPORTTYPE
Flags that control the type of build report to
generate. Must be one of: [PCD, LIBRARY, FLASH,
DEPEX, BUILD_FLAGS, FIXED_ADDRESS, HASH,
EXECUTION_ORDER]. To specify more than one flag,
repeat this option on the command line and the default
flag set is [PCD, LIBRARY, FLASH, DEPEX, HASH,
BUILD_FLAGS, FIXED_ADDRESS]
-F FLAG, --flag=FLAG Specify the specific option to parse EDK UNI file.
Must be one of: [-c, -s]. -c is for EDK framework UNI
file, and -s is for EDK UEFI UNI file. This option can
also be specified by setting __*_BUILD_FLAGS in
[BuildOptions] section of platform DSC. If they are
both specified, this value will override the setting
in [BuildOptions] section of platform DSC.
-N, --no-cache Disable build cache mechanism
–conf=CONFDIRECTORY Specify the customized Conf directory.
–check-usage Check usage content of entries listed in INF file.
–ignore-sources Focus to a binary build and ignore all source files
–pcd=OPTIONPCD Set PCD value by command line. Format: “PcdName=Value”
-l COMMANDLENGTH, --cmd-len=COMMANDLENGTH
Specify the maximum line length of build command.
Default is 4096.
–hash Enable hash-based caching during build process.
–binary-destination=BINCACHEDEST
Generate a cache of binary files in the specified
directory.
–binary-source=BINCACHESOURCE
Consume a cache of binary files from the specified
directory.
–genfds-multi-thread
Enable GenFds multi thread to generate ffs file.
–no-genfds-multi-thread
Disable GenFds multi thread to generate ffs file.
–disable-include-path-check
Disable the include path check for outside of package.
wmail@ubuntu:~/uefi/edk2$

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值