forked from exclipy/clang_indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclic_update.sh
executable file
·61 lines (52 loc) · 1.36 KB
/
clic_update.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
#!/bin/bash
# Specify files to index here
SOURCE_PATH=`cd $1; pwd` # convert $1 to an absolute path
find $SOURCE_PATH\
-name "*.cpp" -or\
-name "*.hpp" -or\
-name "*.cxx" -or\
-name "*.hxx" -or\
-name "*.cc" -or\
-name "*.c" -or\
-name "*.h"\
| sort > files2.txt
add_to_index() {
INDEX_FILE=`echo ${1}.i.gz | tr "/" "%"`
echo clic_add index.db $INDEX_FILE `cat ${SOURCE_PATH}/.clang_complete` $1
clic_add index.db $INDEX_FILE `cat ${SOURCE_PATH}/.clang_complete` $1
}
remove_from_index() {
INDEX_FILE=`echo ${1}.i.gz | tr "/" "%"`
echo clic_rm index.db $INDEX_FILE
clic_rm index.db $INDEX_FILE
echo rm $INDEX_FILE
rm $INDEX_FILE
}
if [ ! -f index.db -o ! -f files.txt ]; then
echo "Creating database"
clic_clear index.db
for i in `cat files2.txt`; do
add_to_index $i
done
mv files2.txt files.txt
exit
fi
echo "Updating database"
#Generate the list of files added since last time
comm -23 files2.txt files.txt > filesadded.txt
for i in `cat filesadded.txt`; do
add_to_index $i
done
# Remove removed files
for i in `comm -23 files.txt files2.txt`; do
remove_from_index $i
done
# Update modified files
for i in `cat files.txt`; do
if [ -f $i -a $i -nt files.txt ]; then
remove_from_index $i
add_to_index $i
fi
done
rm filesadded.txt
mv files2.txt files.txt