-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcsb
executable file
·43 lines (41 loc) · 1.33 KB
/
csb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
# Build and move cscope and etags (or ctags) database to $HOME/.cstags_dir/
#
# Always use `set nocscoperelative` in vim as this script changes path of cscope
# database and absolute path is needed.
#
# Usage:
#
# * `csb ~/esp/esp-idf/ ../dwm/ ../dmneu/ ~/repo/st` (give directories as input)
# * `csb` (build from current directory)
#
# This will create a cscope database for directories and place it in
# `$HOME/.cstags_dir/`.
if [ $1 ]; then
STARTDIR=$PWD
for i in $@; do
cd $i
target_dir="`basename $PWD`"
cwd=$PWD
mkdir -p $HOME/.cstags_dir/$target_dir
cd $HOME/.cstags_dir/$target_dir
find $cwd -name '*.c' -o -name '*.h' -o -name '*.cpp' > cscope.files
sed -i 's/^/"/; s/$/"/' cscope.files
cscope -bi cscope.files
cp $HOME/.cstags_dir/$target_dir/cscope.out $cwd
ctags -e -R $cwd
cd $STARTDIR
done
echo "Ran \`csb' for $@."
else
target_dir="`basename $PWD`"
cwd=$PWD
mkdir -p $HOME/.cstags_dir/$target_dir
cd $HOME/.cstags_dir/$target_dir
find $cwd -name '*.c' -o -name '*.h' -o -name '*.cpp' > cscope.files
sed -i 's/^/"/; s/$/"/' cscope.files
cscope -bi cscope.files
cp $HOME/.cstags_dir/$target_dir/cscope.out $cwd
ctags -e -R $cwd
echo "Ran \`csb' for $(basename $PWD)."
fi