aboutsummaryrefslogtreecommitdiffstats
path: root/tagger.sh
blob: f0b0d173a68c06372a4bae2f6c232afe7a6c9fa9 (plain) (blame)
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
#!/usr/bin/sh

CC=clang
CXX=clang++
C_EXT=c
CXX_EXT=cpp
EXTENSION=
CTAGS_I_PATH=./
RECURSIVE=false
while [[ $# -gt 0 ]]
do
  passarg="$1"
  case $passarg in
    --dir)
      CTAGS_I_PATH="$2"
      shift
      ;;
    --lang)
      LANG="$2"
      shift
      ;;
    --cc)
      CC="$2"
      shift
      ;;
    --cxx)
      CXX="$2"
      shift
      ;;
    --recursive|-r)
      RECURSIVE=true
      ;;
    --ex)
      EXTENSION="$2"
      shift
      ;;
  esac
  shift
done

if [[ $LANG == "c" ]];then
  if [[ $EXTENSION == "" ]];then
    EXTENSION="c"
  fi
elif [[ $LANG == "cpp" ]];then
  if [[ $EXTENSION == "" ]];then
    EXTENSION="cpp"
  fi
fi

for file in $CTAGS_I_PATH/*.$EXTENSION;do
  TEMP_FILE=$(mktemp)
  echo $file > $TEMP_FILE
done

if [[ $LANG == "cpp" ]];then
  $CXX -c -I $CTAGS_I_PATH -M $TEMP_FILE| sed -e 's/[\\ ]/\n/g'|sed -e '/^$$/d' -e '/\.o:[ \t]*$$/d'|ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
elif [[ $LANG == "c" ]];then
  $CC -c -I $CTAGS_I_PATH -M $TEMP_FILE|sed -e 's/[\\ ]/\n/g'|sed -e '/^$$/d' -e '/\.o:[ \t]*$$/d'|ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
fi