一个用于整改 C/C++ compilation database 的 Rust 命令行工具。整改规则默认不启用,由用户通过 CLI 显式选择。
通过通用的 --rewrite <RULE> 选择要执行的整改规则。该选项可以重复传入,也支持以逗号分隔多个规则,方便后续扩展。
当前的 remove-fplugin 规则会删除:
-fplugin=/path/to/plugin.so-fplugin /path/to/plugin.so-fplugin-arg-<name>-<key>[=<value>]
同时支持条目中的 arguments 数组和 command 字符串,并保留其他 JSON 字段。
cargo run --release -- input/compile_commands.json \
--output output/compile_commands.json \
--rewrite remove-fplugin输入文件名也可以是 compile_command.json;工具不限制文件名。
不传 --rewrite 时,不会执行任何整改规则:
cargo run --release -- input/compile_commands.json \
--output output/compile_commands.json通过 --max-commands 可以限制输出的 command 数量。例如只保留输入中的前 100 条:
cargo run --release -- input/compile_commands.json \
--output output/compile_commands.json \
--max-commands 100 \
--rewrite remove-fplugin设置为 0 时输出空的 JSON 数组。不提供该选项时输出全部 command。
未来存在多个规则时,可以使用以下任一种形式:
# 重复传入
compile-command-filter input.json -o output.json \
--rewrite remove-fplugin \
--rewrite another-rule
# 逗号分隔
compile-command-filter input.json -o output.json \
--rewrite remove-fplugin,another-rule规则名由 CLI 严格校验;未知规则会直接报错并列出可用值。