Re: [PATCH v1 1/1] scripts/tags.sh: Fix gtags generation for O= kernel builds

From: Nathan Chancellor
Date: Thu May 04 2023 - 17:32:53 EST


On Thu, May 04, 2023 at 10:18:33PM +0200, Ahmed S. Darwish wrote:
> gtags considers any file outside of its current working directory
> "outside the source tree" and refuses to index it.
>
> For O= kernel builds, scripts/tags.sh invokes gtags with the current
> working directory set to ${O}. This leads to gtags ignoring the entire
> kernel source and generating an empty index.
>
> For O= builds, set gtags' working directory to the kernel source tree
> and explicitly set its output path through parameters instead.
>
> Signed-off-by: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>

Reviewed-by: Nathan Chancellor <nathan@xxxxxxxxxx>

> ---
> scripts/tags.sh | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/tags.sh b/scripts/tags.sh
> index ea31640b2671..1a6db535503b 100755
> --- a/scripts/tags.sh
> +++ b/scripts/tags.sh
> @@ -131,7 +131,14 @@ docscope()
>
> dogtags()
> {
> - all_target_sources | gtags -i -f -
> + # gtags refuses to index any file outside of the current working
> + # directory. For O= builds, set the current working directory to
> + # the kernel source tree and the output tags dir to ${O}.
> + suffixparams=
> + if [ -v O ]; then

I think

if [ -n "$O" ]; then

would match the style preferred by Kbuild (though that is usually for
portability sake, which probably does not matter here since bash is
explicitly requested). Perhaps not worth addressing if there is no other
reason for a v2.

> + suffixparams="-C $tree $O"
> + fi
> + all_target_sources | gtags -i -f - $suffixparams
> }
>
> # Basic regular expressions with an optional /kind-spec/ for ctags and
> --
> 2.30.2
>