-
Notifications
You must be signed in to change notification settings - Fork 0
/
mycscope.sh
executable file
·129 lines (111 loc) · 2.37 KB
/
mycscope.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh
#=========================================================================
# Description: 用于cscope和ctags生成数据库文件tags和cscope.out
# Version: 1.4
#=========================================================================
IGNORE_DIR=""
INCLUDE_DIR=""
#INCLUDE_FILE_TYPE="\.c$|\.h$|\.S$|\.cpp$|\.java$|\.lds$|\.ld*|\.chh$|\.cc$"
INCLUDE_FILE_TYPE="\.c$|\.h$|\.S$|\.s$|\.cpp$|\.java$|\.lds$|\.ld.*|\.chh$|\.cc$|\.hpp$"
cs_init()
{
if [ ! -e ./cscope.ignore ]; then
touch ./cscope.ignore
fi
if [ ! -e ./cscope.include ]; then
touch ./cscope.include
fi
IGNORE_DIR=`awk ' {
if(null != $0)
{
if(i == 0)
{
i++;
printf("-path %s ",$0);
}
else
{
printf("-o -path %s ",$0);
}
} }' ./cscope.ignore`
INCLUDE_DIR=`awk '{printf(" %s ",$0);}' ./cscope.include`
#echo "INCLUDE_DIR=" $INCLUDE_DIR
#echo "IGNORE_DIR=" $IGNORE_DIR
if [ ! -e ./cscope.files ]; then
if [ -z "$IGNORE_DIR" ]; then #字符串为null,即长度为0
#find . -name "*.h" -o -name "*.c" -o -name "*.cc" -o -name "*.cpp" > cscope.files
#modify the cscope code to allow index link file
#find -L . | grep -E '\.c$|\.h$|\.S$|\.cpp$|\.java$|\.lds$|\.ld*|\.chh$|\.cc$' > cscope.files
find -L ${INCLUDE_DIR} | grep -E ${INCLUDE_FILE_TYPE} > cscope.files
else
#find -L . \( -path ./kk -o -path ./mm -o -path ./nn/yy \) -prune -o -print
find -L ${INCLUDE_DIR} \( ${IGNORE_DIR} \) -prune -o -print | grep -E ${INCLUDE_FILE_TYPE} > cscope.files
fi
fi
}
cs_reinit()
{
rm cscope.files -f
cs_init
}
cs_data()
{
cscope -Rbqk -i ./cscope.files #cscope.files为查找的文件列表
#ctags -R *
ctags -R --c++-kinds=+p --c-kinds=+p --fields=+iaS --extra=+q -L ./cscope.files #cscope.files为查找的文件列表
echo "create database ok!"
}
cs_clean()
{
rm cscope.* -f
rm tags -f
echo "clean ok!"
}
cs_all()
{
cs_clean
cs_init
cs_data
}
help()
{
echo ""
echo " mycscope.sh <init|reinit|data|all|clean>"
echo ""
echo " eg: mycscope.sh init"
echo " mycscope.sh reinit"
echo " mycscope.sh data"
echo " mycscope.sh all"
echo " mycscope.sh clean"
echo " "
}
main()
{
if [ $# -ne 1 ]; then
help
exit 1
fi
case "$1" in
init)
cs_init
;;
reinit)
cs_reinit
;;
data)
cs_data
;;
all)
cs_all
;;
clean)
cs_clean
;;
*)
echo "EORROR : $1"
help
exit 1
;;
esac
}
main $@