Blame view
scripts/tags.sh
4.92 KB
a680eedc6 tags and cscope s... |
1 2 3 4 5 6 7 |
#!/bin/sh # Generate tags or cscope files # Usage tags.sh <mode> # # mode may be any of: tags, TAGS, cscope # # Uses the following environment variables: |
a8bac511c tags: Use $SRCARCH |
8 |
# ARCH, SUBARCH, SRCARCH, srctree, src, obj |
a680eedc6 tags and cscope s... |
9 |
|
a6ba0cb35 kbuild: fix strin... |
10 |
if [ "$KBUILD_VERBOSE" = "1" ]; then |
a680eedc6 tags and cscope s... |
11 12 13 14 15 16 17 18 |
set -x fi # This is a duplicate of RCS_FIND_IGNORE without escaped '()' ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \ -name CVS -o -name .pc -o -name .hg -o \ -name .git ) \ -prune -o" |
4431d4ce9 tags: Fix spellin... |
19 |
# Do not use full path if we do not use O=.. builds |
e93bc1a0c Revert "kbuild: s... |
20 21 |
# Use make O=. {tags|cscope} # to force full paths for a non-O= build |
a6ba0cb35 kbuild: fix strin... |
22 |
if [ "${KBUILD_SRC}" = "" ]; then |
a680eedc6 tags and cscope s... |
23 24 |
tree= else |
709cc372c kbuild: fix make ... |
25 |
tree=${srctree}/ |
a680eedc6 tags and cscope s... |
26 |
fi |
bc75cc6b5 tags: Add the abi... |
27 28 29 30 31 32 33 34 |
# Find all available archs find_all_archs() { ALLSOURCE_ARCHS="" for arch in `ls ${tree}arch`; do ALLSOURCE_ARCHS="${ALLSOURCE_ARCHS} "${arch##\/} done } |
4f628248a kbuild: reintrodu... |
35 36 37 |
# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH if [ "${ALLSOURCE_ARCHS}" = "" ]; then ALLSOURCE_ARCHS=${SRCARCH} |
bc75cc6b5 tags: Add the abi... |
38 39 |
elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then find_all_archs |
4f628248a kbuild: reintrodu... |
40 |
fi |
a680eedc6 tags and cscope s... |
41 42 43 |
# find sources in arch/$ARCH find_arch_sources() { |
f81b1be40 tags: include hea... |
44 45 46 47 |
for i in $archincludedir; do prune="$prune -wholename $i -prune -o" done find ${tree}arch/$1 $ignore $prune -name "$2" -print; |
a680eedc6 tags and cscope s... |
48 49 50 51 52 |
} # find sources in arch/$1/include find_arch_include_sources() { |
f81b1be40 tags: include hea... |
53 54 55 56 57 |
include=$(find ${tree}arch/$1/ -name include -type d); if [ -n "$include" ]; then archincludedir="$archincludedir $include" find $include $ignore -name "$2" -print; fi |
a680eedc6 tags and cscope s... |
58 59 60 61 62 |
} # find sources in include/ find_include_sources() { |
709cc372c kbuild: fix make ... |
63 |
find ${tree}include $ignore -name config -prune -o -name "$1" -print; |
a680eedc6 tags and cscope s... |
64 65 66 67 68 69 70 71 |
} # find sources in rest of tree # we could benefit from a list of dirs to search in here find_other_sources() { find ${tree}* $ignore \ \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \ |
709cc372c kbuild: fix make ... |
72 |
-name "$1" -print; |
a680eedc6 tags and cscope s... |
73 74 75 76 |
} find_sources() { |
709cc372c kbuild: fix make ... |
77 |
find_arch_sources $1 "$2" |
a680eedc6 tags and cscope s... |
78 79 80 81 |
} all_sources() { |
a8bac511c tags: Use $SRCARCH |
82 |
find_arch_include_sources ${SRCARCH} '*.[chS]' |
a680eedc6 tags and cscope s... |
83 |
if [ ! -z "$archinclude" ]; then |
709cc372c kbuild: fix make ... |
84 |
find_arch_include_sources $archinclude '*.[chS]' |
a680eedc6 tags and cscope s... |
85 |
fi |
4f628248a kbuild: reintrodu... |
86 |
find_include_sources '*.[chS]' |
f81b1be40 tags: include hea... |
87 88 89 90 |
for arch in $ALLSOURCE_ARCHS do find_sources $arch '*.[chS]' done |
4f628248a kbuild: reintrodu... |
91 |
find_other_sources '*.[chS]' |
a680eedc6 tags and cscope s... |
92 93 94 95 |
} all_kconfigs() { |
953fae66d kbuild: fix tags ... |
96 97 98 99 |
for arch in $ALLSOURCE_ARCHS; do find_sources $arch 'Kconfig*' done find_other_sources 'Kconfig*' |
a680eedc6 tags and cscope s... |
100 101 102 103 |
} all_defconfigs() { |
4f628248a kbuild: reintrodu... |
104 |
find_sources $ALLSOURCE_ARCHS "defconfig" |
a680eedc6 tags and cscope s... |
105 106 107 108 |
} docscope() { |
e93bc1a0c Revert "kbuild: s... |
109 |
(echo \-k; echo \-q; all_sources) > cscope.files |
a680eedc6 tags and cscope s... |
110 111 |
cscope -b -f cscope.out } |
f4ed1009f kbuild: add GNU G... |
112 113 114 115 |
dogtags() { all_sources | gtags -f - } |
a680eedc6 tags and cscope s... |
116 117 |
exuberant() { |
a680eedc6 tags and cscope s... |
118 119 120 121 122 123 |
all_sources | xargs $1 -a \ -I __initdata,__exitdata,__acquires,__releases \ -I __read_mostly,____cacheline_aligned \ -I ____cacheline_aligned_in_smp \ -I ____cacheline_internodealigned_in_smp \ -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ |
7db86dc97 ctags: usability fix |
124 |
-I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ |
0a18a9386 tags: put functio... |
125 |
--extra=+f --c-kinds=+px \ |
9c65426ad tags, powerpc: Up... |
126 |
--regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ |
15664125f scripts/tags.sh: ... |
127 128 |
--regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ |
50d6828e8 scripts/tags.sh: ... |
129 |
--regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' |
a680eedc6 tags and cscope s... |
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/' all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/' all_defconfigs | xargs -r $1 -a \ --langdef=dotconfig --language-force=dotconfig \ --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/' } emacs() { |
5123b327c kbuild: add sys_*... |
147 |
all_sources | xargs $1 -a \ |
9c65426ad tags, powerpc: Up... |
148 |
--regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/' \ |
4d7a2fa87 scripts/tags.sh: ... |
149 150 151 |
--regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' |
a680eedc6 tags and cscope s... |
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/' all_defconfigs | xargs -r $1 -a \ --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/' } xtags() { if $1 --version 2>&1 | grep -iq exuberant; then exuberant $1 elif $1 --version 2>&1 | grep -iq emacs; then emacs $1 else all_sources | xargs $1 -a fi } # Support um (which uses SUBARCH) |
a6ba0cb35 kbuild: fix strin... |
176 177 |
if [ "${ARCH}" = "um" ]; then if [ "$SUBARCH" = "i386" ]; then |
a680eedc6 tags and cscope s... |
178 |
archinclude=x86 |
a6ba0cb35 kbuild: fix strin... |
179 |
elif [ "$SUBARCH" = "x86_64" ]; then |
a680eedc6 tags and cscope s... |
180 181 182 183 184 185 186 187 188 189 |
archinclude=x86 else archinclude=${SUBARCH} fi fi case "$1" in "cscope") docscope ;; |
f4ed1009f kbuild: add GNU G... |
190 191 192 |
"gtags") dogtags ;; |
a680eedc6 tags and cscope s... |
193 |
"tags") |
2e6cb8b0d kbuild: remove a ... |
194 |
rm -f tags |
a680eedc6 tags and cscope s... |
195 196 197 198 |
xtags ctags ;; "TAGS") |
2e6cb8b0d kbuild: remove a ... |
199 |
rm -f TAGS |
a680eedc6 tags and cscope s... |
200 201 202 |
xtags etags ;; esac |