Linux command
compiledb 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate compilation database
compiledb make
Generate from make dry-run
compiledb -n make
Parse existing build log
compiledb --parse [build.log]
Output to specific file
compiledb -o [compile_commands.json] make
Exclude specific paths
compiledb --exclude [/path/to/exclude] make
说明
compiledb generates a compilation database (compile_commands.json) from build commands. This database is used by tools like clangd, clang-tidy, and IDEs for code intelligence and static analysis. The tool intercepts or parses make command output, extracting compiler invocations with their flags and source files. It supports both running builds and parsing existing build logs.
参数
- -n, --no-build
- Parse make output without actually building.
- -p, --parse _file_
- Parse existing build log file.
- -o, --output _file_
- Output file (default: compile_commands.json).
- --exclude _path_
- Exclude paths from database.
- -f, --full-path
- Use full paths for source files.
- --command-style
- Use command string instead of arguments array.
- -S, --strict
- Exit with error on parse failures.
FAQ
What is the compiledb command used for?
compiledb generates a compilation database (compile_commands.json) from build commands. This database is used by tools like clangd, clang-tidy, and IDEs for code intelligence and static analysis. The tool intercepts or parses make command output, extracting compiler invocations with their flags and source files. It supports both running builds and parsing existing build logs.
How do I run a basic compiledb example?
Run `compiledb make` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n, --no-build do in compiledb?
Parse make output without actually building.