Blame view
scripts/tags.sh
9.47 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 |
set -x fi |
ae63b2d7b scripts/tags.sh: ... |
13 14 15 16 |
# RCS_FIND_IGNORE has escaped ()s -- remove them. ignore="$(echo "$RCS_FIND_IGNORE" | sed 's|\\||g' )" # tags and cscope files should also ignore MODVERSION *.mod.c files ignore="$ignore ( -name *.mod.c ) -prune -o" |
a680eedc6 tags and cscope s... |
17 |
|
4431d4ce9 tags: Fix spellin... |
18 |
# Do not use full path if we do not use O=.. builds |
e93bc1a0c Revert "kbuild: s... |
19 20 |
# Use make O=. {tags|cscope} # to force full paths for a non-O= build |
a6ba0cb35 kbuild: fix strin... |
21 |
if [ "${KBUILD_SRC}" = "" ]; then |
a680eedc6 tags and cscope s... |
22 23 |
tree= else |
709cc372c kbuild: fix make ... |
24 |
tree=${srctree}/ |
a680eedc6 tags and cscope s... |
25 |
fi |
bc75cc6b5 tags: Add the abi... |
26 27 28 29 30 31 32 33 |
# 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... |
34 35 36 |
# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH if [ "${ALLSOURCE_ARCHS}" = "" ]; then ALLSOURCE_ARCHS=${SRCARCH} |
bc75cc6b5 tags: Add the abi... |
37 38 |
elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then find_all_archs |
4f628248a kbuild: reintrodu... |
39 |
fi |
a680eedc6 tags and cscope s... |
40 41 42 |
# find sources in arch/$ARCH find_arch_sources() { |
f81b1be40 tags: include hea... |
43 44 45 |
for i in $archincludedir; do prune="$prune -wholename $i -prune -o" done |
596585090 scripts/tags.sh: ... |
46 |
find ${tree}arch/$1 $ignore $subarchprune $prune -name "$2" -print; |
a680eedc6 tags and cscope s... |
47 48 49 50 51 |
} # find sources in arch/$1/include find_arch_include_sources() { |
596585090 scripts/tags.sh: ... |
52 53 |
include=$(find ${tree}arch/$1/ $subarchprune \ -name include -type d -print); |
f81b1be40 tags: include hea... |
54 55 56 57 |
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 |
} |
923e02ecf scripts/tags.sh: ... |
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 |
all_compiled_sources() { for i in $(all_sources); do case "$i" in *.[cS]) j=${i/\.[cS]/\.o} if [ -e $j ]; then echo $i fi ;; *) echo $i ;; esac done } all_target_sources() { if [ -n "$COMPILED_SOURCE" ]; then all_compiled_sources else all_sources fi } |
a680eedc6 tags and cscope s... |
118 119 |
all_kconfigs() { |
953fae66d kbuild: fix tags ... |
120 121 122 123 |
for arch in $ALLSOURCE_ARCHS; do find_sources $arch 'Kconfig*' done find_other_sources 'Kconfig*' |
a680eedc6 tags and cscope s... |
124 125 126 127 |
} all_defconfigs() { |
4f628248a kbuild: reintrodu... |
128 |
find_sources $ALLSOURCE_ARCHS "defconfig" |
a680eedc6 tags and cscope s... |
129 130 131 132 |
} docscope() { |
923e02ecf scripts/tags.sh: ... |
133 |
(echo \-k; echo \-q; all_target_sources) > cscope.files |
a680eedc6 tags and cscope s... |
134 135 |
cscope -b -f cscope.out } |
f4ed1009f kbuild: add GNU G... |
136 137 |
dogtags() { |
923e02ecf scripts/tags.sh: ... |
138 |
all_target_sources | gtags -i -f - |
f4ed1009f kbuild: add GNU G... |
139 |
} |
a680eedc6 tags and cscope s... |
140 141 |
exuberant() { |
923e02ecf scripts/tags.sh: ... |
142 |
all_target_sources | xargs $1 -a \ |
6cf3a6eff scripts/tags.sh: ... |
143 144 |
-I __initdata,__exitdata,__initconst, \ -I __cpuinitdata,__initdata_memblock \ |
f5a82137a scripts/tags.sh: ... |
145 |
-I __refdata,__attribute,__maybe_unused,__always_unused \ |
1b2643f0d scripts/tags.sh: ... |
146 147 |
-I __acquires,__releases,__deprecated \ -I __read_mostly,__aligned,____cacheline_aligned \ |
a680eedc6 tags and cscope s... |
148 |
-I ____cacheline_aligned_in_smp \ |
f5a82137a scripts/tags.sh: ... |
149 |
-I __cacheline_aligned,__cacheline_aligned_in_smp \ |
a680eedc6 tags and cscope s... |
150 |
-I ____cacheline_internodealigned_in_smp \ |
1b2643f0d scripts/tags.sh: ... |
151 |
-I __used,__packed,__packed2__,__must_check,__must_hold \ |
f5a82137a scripts/tags.sh: ... |
152 |
-I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL,ACPI_EXPORT_SYMBOL \ |
7db86dc97 ctags: usability fix |
153 |
-I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ |
1b2643f0d scripts/tags.sh: ... |
154 |
-I static,const \ |
0a18a9386 tags: put functio... |
155 |
--extra=+f --c-kinds=+px \ |
9c65426ad tags, powerpc: Up... |
156 |
--regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ |
15664125f scripts/tags.sh: ... |
157 158 |
--regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ |
358142dd8 scripts/tags.sh: ... |
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
--regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' \ --regex-c++='/PAGEFLAG\(([^,)]*).*/Page\1/' \ --regex-c++='/PAGEFLAG\(([^,)]*).*/SetPage\1/' \ --regex-c++='/PAGEFLAG\(([^,)]*).*/ClearPage\1/' \ --regex-c++='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/' \ --regex-c++='/TESTPAGEFLAG\(([^,)]*).*/Page\1/' \ --regex-c++='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/' \ --regex-c++='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/' \ --regex-c++='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ --regex-c++='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \ --regex-c++='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/' \ --regex-c++='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ --regex-c++='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/' \ --regex-c++='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/' \ --regex-c++='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/' \ --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/' \ --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/' \ --regex-c++='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/' \ --regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ --regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ |
1fa850596 scripts/tags.sh: ... |
180 |
--regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ |
22beb565d scripts/tags.sh: ... |
181 |
--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ |
1b2643f0d scripts/tags.sh: ... |
182 183 184 185 186 187 188 189 190 191 192 193 |
--regex-c='/PCI_OP_READ\((\w*).*[1-4]\)/pci_bus_read_config_\1/' \ --regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \ --regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/' \ --regex-c='/DEFINE_(RAW_SPINLOCK|RWLOCK|SEQLOCK)\((\w*)/\2/v/' \ --regex-c='/DECLARE_(RWSEM|COMPLETION)\((\w*)/\2/v/' \ --regex-c='/DECLARE_BITMAP\((\w*)/\1/v/' \ --regex-c='/(^|\s)(|L|H)LIST_HEAD\((\w*)/\3/v/' \ --regex-c='/(^|\s)RADIX_TREE\((\w*)/\2/v/' \ --regex-c='/DEFINE_PER_CPU\(([^,]*,\s*)(\w*).*\)/\2/v/' \ --regex-c='/DEFINE_PER_CPU_SHARED_ALIGNED\(([^,]*,\s*)(\w*).*\)/\2/v/' \ --regex-c='/DECLARE_WAIT_QUEUE_HEAD\((\w*)/\1/v/' \ --regex-c='/DECLARE_(TASKLET|WORK|DELAYED_WORK)\((\w*)/\2/v/' \ |
987d0c8e9 scripts/tags.sh: ... |
194 195 196 |
--regex-c='/DEFINE_PCI_DEVICE_TABLE\((\w*)/\1/v/' \ --regex-c='/(^\s)OFFSET\((\w*)/\2/v/' \ --regex-c='/(^\s)DEFINE\((\w*)/\2/v/' |
a680eedc6 tags and cscope s... |
197 198 199 200 201 202 203 204 205 206 207 208 |
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/' |
a680eedc6 tags and cscope s... |
209 210 211 212 |
} emacs() { |
923e02ecf scripts/tags.sh: ... |
213 |
all_target_sources | xargs $1 -a \ |
9f14b4201 scripts/tags.sh: ... |
214 |
--regex='/^\(ENTRY\|_GLOBAL\)(\([^)]*\)).*/\2/' \ |
4d7a2fa87 scripts/tags.sh: ... |
215 216 |
--regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ |
358142dd8 scripts/tags.sh: ... |
217 |
--regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \ |
9f14b4201 scripts/tags.sh: ... |
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
--regex='/PAGEFLAG(\([^,)]*\).*/Page\1/' \ --regex='/PAGEFLAG(\([^,)]*\).*/SetPage\1/' \ --regex='/PAGEFLAG(\([^,)]*\).*/ClearPage\1/' \ --regex='/TESTSETFLAG(\([^,)]*\).*/TestSetPage\1/' \ --regex='/TESTPAGEFLAG(\([^,)]*\).*/Page\1/' \ --regex='/SETPAGEFLAG(\([^,)]*\).*/SetPage\1/' \ --regex='/__SETPAGEFLAG(\([^,)]*\).*/__SetPage\1/' \ --regex='/TESTCLEARFLAG(\([^,)]*\).*/TestClearPage\1/' \ --regex='/__TESTCLEARFLAG(\([^,)]*\).*/TestClearPage\1/' \ --regex='/CLEARPAGEFLAG(\([^,)]*\).*/ClearPage\1/' \ --regex='/__CLEARPAGEFLAG(\([^,)]*\).*/__ClearPage\1/' \ --regex='/__PAGEFLAG(\([^,)]*\).*/__SetPage\1/' \ --regex='/__PAGEFLAG(\([^,)]*\).*/__ClearPage\1/' \ --regex='/PAGEFLAG_FALSE(\([^,)]*\).*/Page\1/' \ --regex='/TESTSCFLAG(\([^,)]*\).*/TestSetPage\1/' \ --regex='/TESTSCFLAG(\([^,)]*\).*/TestClearPage\1/' \ --regex='/SETPAGEFLAG_NOOP(\([^,)]*\).*/SetPage\1/' \ --regex='/CLEARPAGEFLAG_NOOP(\([^,)]*\).*/ClearPage\1/' \ --regex='/__CLEARPAGEFLAG_NOOP(\([^,)]*\).*/__ClearPage\1/' \ --regex='/TESTCLEARFLAG_FALSE(\([^,)]*\).*/TestClearPage\1/' \ --regex='/__TESTCLEARFLAG_FALSE(\([^,)]*\).*/__TestClearPage\1/' \ --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' \ --regex='/PCI_OP_READ(\([a-z]*[a-z]\).*[1-4])/pci_bus_read_config_\1/' \ --regex='/PCI_OP_WRITE(\([a-z]*[a-z]\).*[1-4])/pci_bus_write_config_\1/' |
a680eedc6 tags and cscope s... |
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
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 |
923e02ecf scripts/tags.sh: ... |
260 |
all_target_sources | xargs $1 -a |
a680eedc6 tags and cscope s... |
261 262 |
fi } |
a680eedc6 tags and cscope s... |
263 |
# Support um (which uses SUBARCH) |
a6ba0cb35 kbuild: fix strin... |
264 265 |
if [ "${ARCH}" = "um" ]; then if [ "$SUBARCH" = "i386" ]; then |
a680eedc6 tags and cscope s... |
266 |
archinclude=x86 |
a6ba0cb35 kbuild: fix strin... |
267 |
elif [ "$SUBARCH" = "x86_64" ]; then |
a680eedc6 tags and cscope s... |
268 269 270 271 |
archinclude=x86 else archinclude=${SUBARCH} fi |
596585090 scripts/tags.sh: ... |
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
elif [ "${SRCARCH}" = "arm" -a "${SUBARCH}" != "" ]; then subarchdir=$(find ${tree}arch/$SRCARCH/ -name "mach-*" -type d -o \ -name "plat-*" -type d); for i in $subarchdir; do case "$i" in *"mach-"${SUBARCH}) ;; *"plat-"${SUBARCH}) ;; *) subarchprune="$subarchprune \ -wholename $i -prune -o" ;; esac done |
a680eedc6 tags and cscope s... |
287 |
fi |
66979224c scripts: refactor... |
288 |
remove_structs= |
a680eedc6 tags and cscope s... |
289 290 291 292 |
case "$1" in "cscope") docscope ;; |
f4ed1009f kbuild: add GNU G... |
293 294 295 |
"gtags") dogtags ;; |
a680eedc6 tags and cscope s... |
296 |
"tags") |
2e6cb8b0d kbuild: remove a ... |
297 |
rm -f tags |
a680eedc6 tags and cscope s... |
298 |
xtags ctags |
66979224c scripts: refactor... |
299 |
remove_structs=y |
a680eedc6 tags and cscope s... |
300 301 302 |
;; "TAGS") |
2e6cb8b0d kbuild: remove a ... |
303 |
rm -f TAGS |
a680eedc6 tags and cscope s... |
304 |
xtags etags |
66979224c scripts: refactor... |
305 |
remove_structs=y |
a680eedc6 tags and cscope s... |
306 307 |
;; esac |
66979224c scripts: refactor... |
308 309 |
# Remove structure forward declarations. |
0eb043d0e Subject: [PATCH] ... |
310 |
if [ -n "$remove_structs" ]; then |
66979224c scripts: refactor... |
311 312 |
LANG=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 fi |