hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/scripts/tags.sh
....@@ -32,6 +32,13 @@
3232 ignore="$ignore ( -path ${tree}tools ) -prune -o"
3333 fi
3434
35
+# gtags(1) refuses to index any file outside of its current working dir.
36
+# If gtags indexing is requested and the build output directory is not
37
+# the kernel source tree, index all files in absolute-path form.
38
+if [[ "$1" == "gtags" && -n "${tree}" ]]; then
39
+ tree=$(realpath "$tree")/
40
+fi
41
+
3542 # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
3643 if [ "${ALLSOURCE_ARCHS}" = "" ]; then
3744 ALLSOURCE_ARCHS=${SRCARCH}
....@@ -95,10 +102,13 @@
95102
96103 all_compiled_sources()
97104 {
98
- realpath -es $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) \
99
- include/generated/autoconf.h $(find $ignore -name "*.cmd" -exec \
100
- grep -Poh '(?(?=^source_.* \K).*|(?=^ \K\S).*(?= \\))' {} \+ |
101
- awk '!a[$0]++') | sort -u
105
+ {
106
+ echo include/generated/autoconf.h
107
+ find $ignore -name "*.cmd" -exec \
108
+ sed -n -E 's/^source_.* (.*)/\1/p; s/^ (\S.*) \\/\1/p' {} \+ |
109
+ awk '!a[$0]++'
110
+ } | xargs realpath -es $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) |
111
+ sort -u
102112 }
103113
104114 all_target_sources()
....@@ -128,7 +138,7 @@
128138
129139 dogtags()
130140 {
131
- all_target_sources | gtags -i -f -
141
+ all_target_sources | gtags -i -C "${tree:-.}" -f - "$PWD"
132142 }
133143
134144 # Basic regular expressions with an optional /kind-spec/ for ctags and