Skip to content

Commit c437b26

Browse files
Ahmed S. Darwishgregkh
authored andcommitted
scripts/tags.sh: Resolve gtags empty index generation
commit e1b3756 upstream. gtags considers any file outside of its current working directory "outside the source tree" and refuses to index it. For O= kernel builds, or when "make" is invoked from a directory other then the kernel source tree, gtags ignores the entire kernel source and generates an empty index. Force-set gtags current working directory to the kernel source tree. Due to commit 9da0763 ("kbuild: Use relative path when building in a subdir of the source tree"), if the kernel build is done in a sub-directory of the kernel source tree, the kernel Makefile will set the kernel's $srctree to ".." for shorter compile-time and run-time warnings. Consequently, the list of files to be indexed will be in the "../*" form, rendering all such paths invalid once gtags switches to the kernel source tree as its current working directory. If gtags indexing is requested and the build directory is not the kernel source tree, index all files in absolute-path form. Note, indexing in absolute-path form will not affect the generated index, as paths in gtags indices are always relative to the gtags "root directory" anyway (as evidenced by "gtags --dump"). Signed-off-by: Ahmed S. Darwish <[email protected]> Cc: <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 50e36c2 commit c437b26

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scripts/tags.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ else
2525
tree=${srctree}/
2626
fi
2727

28+
# gtags(1) refuses to index any file outside of its current working dir.
29+
# If gtags indexing is requested and the build output directory is not
30+
# the kernel source tree, index all files in absolute-path form.
31+
if [[ "$1" == "gtags" && -n "${tree}" ]]; then
32+
tree=$(realpath "$tree")/
33+
fi
34+
2835
# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
2936
if [ "${ALLSOURCE_ARCHS}" = "" ]; then
3037
ALLSOURCE_ARCHS=${SRCARCH}
@@ -124,7 +131,7 @@ docscope()
124131

125132
dogtags()
126133
{
127-
all_target_sources | gtags -i -f -
134+
all_target_sources | gtags -i -C "${tree:-.}" -f - "$PWD"
128135
}
129136

130137
# Basic regular expressions with an optional /kind-spec/ for ctags and

0 commit comments

Comments
 (0)