Created
January 23, 2019 23:08
-
-
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
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 | |
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