Skip to content

Instantly share code, notes, and snippets.

@Triavanicus
Created January 23, 2019 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Triavanicus/68ffa5024cf64d04722e725eb2ca7ba8 to your computer and use it in GitHub Desktop.
Save Triavanicus/68ffa5024cf64d04722e725eb2ca7ba8 to your computer and use it in GitHub Desktop.
I created a bash script that used sed to convert CMake's compile_commands.json into a .clang_complete file
#!/bin/bash
usage() {
echo "Cmake commands to clang complete generator usage:"
echo "$0 input/directory [output/directory]"
}
generate_file() {
cat $1/compile_commands.json |
sed -r '/command/!d
s/^ *"command": "//
s/",$//
s/ |(-c |-o )/\n\1/g' |
sed -r '/^(\/|-o|-c|$)/d' |
sort -u > $2/.clang_complete
}
if [[ $# -eq 0 ]] || [[ $# -gt 2 ]]; then
usage
exit 1
elif [[ $# -eq 1 ]]; then
generate_file $1 "."
elif [[ $# -eq 2 ]]; then
generate_file $1 $2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment