Blame view
scripts/tags.sh
9.51 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 |
for i in $archincludedir; do prune="$prune -wholename $i -prune -o" done |
596585090 scripts/tags.sh: ... |
47 |
find ${tree}arch/$1 $ignore $subarchprune $prune -name "$2" -print; |
a680eedc6 tags and cscope s... |
48 49 50 51 52 |
} # find sources in arch/$1/include find_arch_include_sources() { |
596585090 scripts/tags.sh: ... |
53 54 |
include=$(find ${tree}arch/$1/ $subarchprune \ -name include -type d -print); |
f81b1be40 tags: include hea... |
55 56 57 58 |
if [ -n "$include" ]; then archincludedir="$archincludedir $include" find $include $ignore -name "$2" -print; fi |
a680eedc6 tags and cscope s... |
59 60 61 62 63 |
} # find sources in include/ find_include_sources() { |
709cc372c kbuild: fix make ... |
64 |
find ${tree}include $ignore -name config -prune -o -name "$1" -print; |
a680eedc6 tags and cscope s... |
65 66 67 68 69 70 71 72 |
} # 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 ... |
73 |
-name "$1" -print; |
a680eedc6 tags and cscope s... |
74 75 76 77 |
} find_sources() { |
709cc372c kbuild: fix make ... |
78 |
find_arch_sources $1 "$2" |
a680eedc6 tags and cscope s... |
79 80 81 82 |
} all_sources() { |
a8bac511c tags: Use $SRCARCH |
83 |
find_arch_include_sources ${SRCARCH} '*.[chS]' |
a680eedc6 tags and cscope s... |
84 |
if [ ! -z "$archinclude" ]; then |
709cc372c kbuild: fix make ... |
85 |
find_arch_include_sources $archinclude '*.[chS]' |
a680eedc6 tags and cscope s... |
86 |
fi |
4f628248a kbuild: reintrodu... |
87 |
find_include_sources '*.[chS]' |
f81b1be40 tags: include hea... |
88 89 90 91 |
for arch in $ALLSOURCE_ARCHS do find_sources $arch '*.[chS]' done |
4f628248a kbuild: reintrodu... |
92 |
find_other_sources '*.[chS]' |
a680eedc6 tags and cscope s... |
93 |
} |
923e02ecf scripts/tags.sh: ... |
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 |
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... |
119 120 |
all_kconfigs() { |
953fae66d kbuild: fix tags ... |
121 122 123 124 |
for arch in $ALLSOURCE_ARCHS; do find_sources $arch 'Kconfig*' done find_other_sources 'Kconfig*' |
a680eedc6 tags and cscope s... |
125 126 127 128 |
} all_defconfigs() { |
4f628248a kbuild: reintrodu... |
129 |
find_sources $ALLSOURCE_ARCHS "defconfig" |
a680eedc6 tags and cscope s... |
130 131 132 133 |
} docscope() { |
923e02ecf scripts/tags.sh: ... |
134 |
(echo \-k; echo \-q; all_target_sources) > cscope.files |
a680eedc6 tags and cscope s... |
135 136 |
cscope -b -f cscope.out } |
f4ed1009f kbuild: add GNU G... |
137 138 |
dogtags() { |
923e02ecf scripts/tags.sh: ... |
139 |
all_target_sources | gtags -i -f - |
f4ed1009f kbuild: add GNU G... |
140 |
} |
a680eedc6 tags and cscope s... |
141 142 |
exuberant() { |
923e02ecf scripts/tags.sh: ... |
143 |
all_target_sources | xargs $1 -a \ |
6cf3a6eff scripts/tags.sh: ... |
144 145 |
-I __initdata,__exitdata,__initconst, \ -I __cpuinitdata,__initdata_memblock \ |
f5a82137a scripts/tags.sh: ... |
146 |
-I __refdata,__attribute,__maybe_unused,__always_unused \ |
1b2643f0d scripts/tags.sh: ... |
147 148 |
-I __acquires,__releases,__deprecated \ -I __read_mostly,__aligned,____cacheline_aligned \ |
a680eedc6 tags and cscope s... |
149 |
-I ____cacheline_aligned_in_smp \ |
f5a82137a scripts/tags.sh: ... |
150 |
-I __cacheline_aligned,__cacheline_aligned_in_smp \ |
a680eedc6 tags and cscope s... |
151 |
-I ____cacheline_internodealigned_in_smp \ |
1b2643f0d scripts/tags.sh: ... |
152 |
-I __used,__packed,__packed2__,__must_check,__must_hold \ |
f5a82137a scripts/tags.sh: ... |
153 |
-I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL,ACPI_EXPORT_SYMBOL \ |
7db86dc97 ctags: usability fix |
154 |
-I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ |
1b2643f0d scripts/tags.sh: ... |
155 |
-I static,const \ |
0a18a9386 tags: put functio... |
156 |
--extra=+f --c-kinds=+px \ |
9c65426ad tags, powerpc: Up... |
157 |
--regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ |
15664125f scripts/tags.sh: ... |
158 159 |
--regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ |
358142dd8 scripts/tags.sh: ... |
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
--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: ... |
181 |
--regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ |
22beb565d scripts/tags.sh: ... |
182 |
--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ |
1b2643f0d scripts/tags.sh: ... |
183 184 185 186 187 188 189 190 191 192 193 194 |
--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: ... |
195 196 197 |
--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... |
198 199 200 201 202 203 204 205 206 207 208 209 |
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... |
210 211 212 213 |
} emacs() { |
923e02ecf scripts/tags.sh: ... |
214 |
all_target_sources | xargs $1 -a \ |
9f14b4201 scripts/tags.sh: ... |
215 |
--regex='/^\(ENTRY\|_GLOBAL\)(\([^)]*\)).*/\2/' \ |
4d7a2fa87 scripts/tags.sh: ... |
216 217 |
--regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ |
358142dd8 scripts/tags.sh: ... |
218 |
--regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \ |
9f14b4201 scripts/tags.sh: ... |
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
--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... |
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
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: ... |
261 |
all_target_sources | xargs $1 -a |
a680eedc6 tags and cscope s... |
262 263 |
fi } |
a680eedc6 tags and cscope s... |
264 |
# Support um (which uses SUBARCH) |
a6ba0cb35 kbuild: fix strin... |
265 266 |
if [ "${ARCH}" = "um" ]; then if [ "$SUBARCH" = "i386" ]; then |
a680eedc6 tags and cscope s... |
267 |
archinclude=x86 |
a6ba0cb35 kbuild: fix strin... |
268 |
elif [ "$SUBARCH" = "x86_64" ]; then |
a680eedc6 tags and cscope s... |
269 270 271 272 |
archinclude=x86 else archinclude=${SUBARCH} fi |
596585090 scripts/tags.sh: ... |
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
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... |
288 |
fi |
66979224c scripts: refactor... |
289 |
remove_structs= |
a680eedc6 tags and cscope s... |
290 291 292 293 |
case "$1" in "cscope") docscope ;; |
f4ed1009f kbuild: add GNU G... |
294 295 296 |
"gtags") dogtags ;; |
a680eedc6 tags and cscope s... |
297 |
"tags") |
2e6cb8b0d kbuild: remove a ... |
298 |
rm -f tags |
a680eedc6 tags and cscope s... |
299 |
xtags ctags |
66979224c scripts: refactor... |
300 |
remove_structs=y |
a680eedc6 tags and cscope s... |
301 302 303 |
;; "TAGS") |
2e6cb8b0d kbuild: remove a ... |
304 |
rm -f TAGS |
a680eedc6 tags and cscope s... |
305 |
xtags etags |
66979224c scripts: refactor... |
306 |
remove_structs=y |
a680eedc6 tags and cscope s... |
307 308 |
;; esac |
66979224c scripts: refactor... |
309 310 |
# Remove structure forward declarations. |
0eb043d0e Subject: [PATCH] ... |
311 |
if [ -n "$remove_structs" ]; then |
66979224c scripts: refactor... |
312 313 |
LANG=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 fi |