Loading

c项目生成compile_commands.json

一、生成compile_commands.json

1.1、compile_commands.json内容

cmake生成compile_commands.jsons

https://blog.csdn.net/qq_23599965/article/details/90697236

方法
CMakeList.txt在Main文件夹下,

cd main
mkdir build
cd build
cmake ../Main -DCMAKE_EXPORT_COMPILE_COMMANDS=1

提取结果

[
    {
      "directory": "/root/data/clang-llvm/TestProject/build",
      "command": "/bin/c++  -I/root/data/clang-llvm/TestProject/Main/include  -o CMakeFiles/t.dir/t.cpp.o -c /root/data/clang-llvm/TestProject/Main/t.cpp",
      "file": "/root/data/clang-llvm/TestProject/Main/t.cpp"
    }
]

1.2、bear生成compile_commands.json

以bash为例子
代码仓库
https://git.savannah.gnu.org/cgit/bash.git

mkdir build
cd build
bear -- ../configure --prefix=//media/data/clang-llvm/bash/build
bear -- make
posted @ 2022-09-13 15:22  xine  阅读(3283)  评论(0编辑  收藏  举报