hunting/doc/clang-tidy_user_guide.md
2023-11-25 18:20:03 -08:00

42 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 1. clang-tidy使用指南
   使用clang-tidy工具进行代码规范管理。
1. 编译时实时报错;
2. 指定自研源码检测;
## 1.1. 环境搭建
1. llvm使用cmake编译cmake版本要求 3.20以上此处使用cmake-3.27.4
```
// cmake源码目录//tools/cmake/cmake-3.27.4.tar.gz
// cmake源码安装
tar zxvf cmake-3.27.4.tar.gz
cd cmake-3.27.4/
sudo apt-get install openssl // 如果执行./bootstrap提示缺少ssl相关资源执行此安装命令
./bootstrap
make
sudo make install
```
2. 安装llvm
```
// 下载源码
git clone https://github.com/llvm/llvm-project.git
cd llvm-project/
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" ../llvm
make -j8
find ./ -name clang-tidy // 确认编译完成
```
## 1.2. clang-tidy使用
修改配置:< IPC-SDK >/build/global_config.cmake
```
# ------------ build clang-tools ------------ #
if(${LINUX_TEST} MATCHES "true")
set(CLANG_TIDY_SUPPORT "true") // 使能工具
set(CLANG_FORMAT_SUPPORT "true")
set(LLVM_PATH "/home/xiaojiazhu/project/tmp/llvm-project") // llvm安装目录
endif()
# ------------ build clang-tools end ------------ #
```