Skip to content

Instantly share code, notes, and snippets.

@dragonly
Forked from xuhdev/ctags_with_dep.sh
Last active July 23, 2016 11:36
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 dragonly/634c5eff8d75c8fd3deec4a0efb99902 to your computer and use it in GitHub Desktop.
Save dragonly/634c5eff8d75c8fd3deec4a0efb99902 to your computer and use it in GitHub Desktop.
Generate ctags file for C or C++ files and its depedencies (included header files). This could avoid you to always generate a huge tags file.
#!/bin/bash
function usage() {
echo "Usage:"
echo " ./ctags_with_dep.sh file1.c file2.cpp"
}
CFLAGS="`pkg-config --cflags ImageMagick++ freetype2 fontconfig assimp` -I../Include -IFreetypeGL -I../Common/FreetypeGL"
if [ -n "$1" ]; then
gcc $CFLAGS -M $* \
| sed -e 's/[\\ ]/\n/g' \
| sed -e '/^$/d' -e '/\.o:[ \t]*$/d' \
| ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
else
usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment