Skip to content

Instantly share code, notes, and snippets.

@alex-tee
Created March 11, 2018 07:21
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 alex-tee/3c462435f9bf78123c1b51599a9862a6 to your computer and use it in GitHub Desktop.
Save alex-tee/3c462435f9bf78123c1b51599a9862a6 to your computer and use it in GitHub Desktop.
Create cscope & ctags tags recursively (C/C++) ref: https://qiita.com/faiyadesu/items/b916c1aaed731d2bcb53
#!/bin/bash
CSCOPE_DIR="$PWD/cscope"
if [ ! -d "$CSCOPE_DIR" ]; then
mkdir "$CSCOPE_DIR"
fi
echo "finding files..."
gcc -M `pkg-config --cflags --libs lilv-0` `pkg-config --cflags --libs suil-0` \
`find . -name "*.h" -printf "%h\n" | awk '!x[$0]++' | sed -e 's/^/-I /'` \
`pkg-config --cflags --libs sord-0` \
`find /usr/include/x86_64-linux-gnu/qt5/ -type d -print | sed -e 's/^/-I /'` \
`pkg-config --cflags --libs gtk+-2.0` `pkg-config --cflags --libs glib-2.0` \
`pkg-config --cflags --libs gtkmm-2.4`\
-fPIC "$@" | sed -e 's/[\\ ]/\n/g' | \
sed -e '/^$/d' -e '/\.o:[ \t]*$/d' > "$CSCOPE_DIR/cscope.files.tmp"
awk '!a[$0]++' "$CSCOPE_DIR/cscope.files.tmp" > "$CSCOPE_DIR/cscope.files"
rm "$CSCOPE_DIR/cscope.files.tmp"
echo "building cscope db...."
cscope -b -i "$CSCOPE_DIR/cscope.files"
echo "building ctags db..."
ctags -L "$CSCOPE_DIR/cscope.files" --c++-kinds=+p --fields=+iaS --extra=+q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment