Closed rickstaa closed 2 years ago
I'm not sure what is the best way to handle this but I guess it's not compdb
.
I never implemented the JSON file concatenation to merge multiple database into one but that maybe there are tools that do that already (e.g.jq
?).
Or maybe the clang-tidy wrapper could take a list of database, e.g.:
my-clang-tidy build/*/compile_commands.json
@Sarcasm Ah, thanks a lot for your answer. I think you are right; creating a small wrapper package that uses compdb
to create a merged output compile_commands.json
file would make more sense. This package can then search whether subfolders in a catkin build
workspace contain a compile_commands.json
file and merge them (e.g. catkin_compdb
). If frequently run into this issue, I will create such a package. For now, I will use the following syntax to merge multiple databases:
compdb -p ../build/package_1 list >> compile_commands.json
compdb -p ../build/package_2 list >> compile_commands.json
I just realized compdb
supports multiple -p
.
So I guess you can do something like:
compdb \
-p ../build/package_1 \
-p ../build/package_2 \
list > compile_commands.json
Ah, great. Thanks for the tip.
For future reference, I found another way to use clang-tidy in a catkin workspace. Vscode has the clang-tidy and catkin-tools vscode extensions. The catkin-tools does does something similar to compdb. More information about the setup can be found here.
I am currently using
compdb
to create acompile_commands.json
file that works withclang-tidy. I, however, have multiple packages in my ROS workspace that export a
comile_commands.jsonfile (i.e. have the
CMAKE_EXPORT_COMPILE_COMMANDSoption set). Therefore, I wondered if there is a way to represent all the compilation databases of the packages contained in my ROS workspace into one
compile_commands.json` output file.Related to https://github.com/Sarcasm/compdb/issues/2#issuecomment-338475035.