History

scripts/tags.sh: Resolve gtags empty index generation

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 9da0763bdd82 ("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").

Ahmed S. Darwish committed 3 years ago

Commit e1b37561 parent ac263341 file · +8 −1Browse files

Unified · Split

scripts/tags.sh+8−1
@@ -32,6 +32,13 @@ else · 31 unmodified lines
32 tree=${srctree}/32 tree=${srctree}/
33fi33fi
34 34
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.
38if [[ "$1" == "gtags" && -n "${tree}" ]]; then
39 tree=$(realpath "$tree")/
40fi
41
35# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH42# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
36if [ "${ALLSOURCE_ARCHS}" = "" ]; then43if [ "${ALLSOURCE_ARCHS}" = "" ]; then
37 ALLSOURCE_ARCHS=${SRCARCH}44 ALLSOURCE_ARCHS=${SRCARCH}
@@ -131,7 +138,7 @@ docscope() · 93 unmodified lines
131 138
132dogtags()139dogtags()
133{140{
134 all_target_sources | gtags -i -f -141 all_target_sources | gtags -i -C "${tree:-.}" -f - "$PWD"
135}142}
136 143
137# Basic regular expressions with an optional /kind-spec/ for ctags and144# Basic regular expressions with an optional /kind-spec/ for ctags and

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t