-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgentags-android
More file actions
executable file
·121 lines (103 loc) · 3.16 KB
/
gentags-android
File metadata and controls
executable file
·121 lines (103 loc) · 3.16 KB
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
#!/usr/bin/env bash
# Author: Goldie Lin
# Description: Generate tag files for source code browsering.
# Requirements:
# * ctags (exuberant-ctags, or universal-ctags)
# * cscope
# * gtags (global)
# Usage: cd to codebase root directory, then run this script.
set -euo pipefail
# Variable definitions
# ====================
# tags to be generated
declare -gra tag_list=( "gtags" "ctags" "cscope" )
# filelist
declare -gr file_list="filelist.txt"
declare -gr file_list_quoted="${file_list%.*}.double-quoted.${file_list##*.}"
# required pkg list: executable, package name
declare -grA req_pkgs=(
["ctags"]="exuberant-ctags"
["cscope"]="cscope"
["gtags"]="global"
)
# Function definitions
# ====================
# check requirements
# Ref: https://github.com/bcbcarl/ultra_vim/blob/master/install.sh
check_depends() {
local i=""
for i in "${!req_pkgs[@]}"; do
if ! hash "$i" &>/dev/null; then
echo "Error: '$i' (${req_pkgs[$i]}) not installed. Aborting." >&2
exit 1
fi
done
}
# generate filelist
gen_filelist() {
# type `find -regextype help` to get supported regextypes in findutils.
find . -regextype posix-egrep \
\( -regex '^.*\/\.git(|\/.*)$' \
-o -regex '^.*\/\.repo(|\/.*)$' \
-o -regex '^.*\/\.svn(|\/.*)$' \
-o -regex '^.*\/\.bzr(|\/.*)$' \
-o -regex '^.*\/\.hg(|\/.*)$' \
-o -regex '^\.\/out(|\/.*)$' \
-o -regex '^\.\/cts(|\/.*)$' \
-o -regex '^\.\/docs(|\/.*)$' \
-o -regex '^\.\/sdk(|\/.*)$' \
-o -regex '^\.\/ndk(|\/.*)$' \
-o -regex '^\.\/gdk(|\/.*)$' \
-o -regex '^\.\/pdk(|\/.*)$' \
-o -regex '^\.\/prebuilt(|\/.*)$' \
-o -regex '^\.\/prebuilts(|\/.*)$' \
-o -regex '^\.\/developers(|\/.*)$' \
-o -regex '^\.\/development(|\/.*)$' \
\) -prune -o \
-type f -iregex \
'^.*\/(Makefile(|\..*)|[^/]*\.(c|h|l|y|S|cc|hh|cpp|hpp|cxx|hxx|c++|java|aidl|xml|pl|py|sh|mk|mak|make|makefile|gradle|dxs|dec|dsc|fdf|inf|uni|vfr))$' \
-fprintf "${file_list}" '%p\n' \
-fprintf "${file_list_quoted}" '"%p"\n'
}
# generate tags based on the same filelist
gen_tags() {
local i=""
for i in "$@"; do
case "$i" in
cscope) cscope -bqki "${file_list_quoted}";;
ctags) ctags -n --fields=+ai --C++-kinds=+p -L "${file_list}";;
gtags) gtags --accept-dotfiles -f "${file_list}";;
esac
done
}
print_usage() {
cat << _USAGE_
Usage:
# Incremental update GTAGS with whole source tree, but it'll reuse *builtin*
# file search pattern. (Not suited for kernel, too many different arch.)
global -vu
# Incremental update GTAGS for only single file you specified.
global -vu --single-update <relative/path/to/a/file.ext>
# Manually generate HTAGS hypertext XHTML in "./HTML/"
htags -xsanohITt "PROJECT TITLE"
# -t, --title title: The title of this hypertext.
# -m, --main-func name: Specify the main function name. (default is main)
firefox HTML/index.html
# Manually generate Doxygen HTML in "./html/"
doxygen -g
vi Doxyfile
INPUT = .
RECURSIVE = YES
SOURCE_BROWSER = YES
USE_HTAGS = YES
doxygen
firefox html/index.html
_USAGE_
}
main() {
check_depends
gen_filelist
gen_tags "${tag_list[@]}"
print_usage
}
main "$@"