Created
March 11, 2024 07:11
-
-
Save xiaodong2077/35c6ea14dd388781bdcd038c7c25cb30 to your computer and use it in GitHub Desktop.
Get a whole compile_commands.json(which is used in cland and sonarlint) file with `catkin_make_isolated` of ROS. You also need to add this option `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` when you run `catkin_make_islodated`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Merge`build_isolated/*/compile_commands.json` to `build/compile_commands.json` | |
output_file="build/compile_commands.json" | |
rm -f "$output_file" | |
echo "[" > "$output_file" | |
first_file=true | |
for file in build_isolated/*/compile_commands.json; do | |
if [ -f "$file" ]; then | |
if [ "$first_file" = false ]; then | |
echo "," >> "$output_file" | |
fi | |
sed -n '/\[/,/\]/p' "$file" | sed '1d;$d' >> "$output_file" | |
echo "Merged $file into $output_file" | |
first_file=false | |
fi | |
done | |
echo "]" >> "$output_file" | |
echo "Merge process completed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment