Skip to contentSkip to conversation

scripts/tags.sh: Fix the Kconfig tags generation when using latest ctags

PATCH Superseded Kevin Hao 2 participants 3 messages Dec 29, 2022 – Dec 30, 2022

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Kevin Hao

author
#0 lore raw

PATCH 1/1 scripts/tags.sh: Fix the Kconfig tags generation when using latest ctags

The Kconfig language has already been built-in in the latest ctags, so it would error exit if we try to define it as an user-defined language via '--langdef=kconfig'. This results that there is no Kconfig tags in the final tag file. Fix this by skipping the user Kconfig definition for the latest ctags.

---
 scripts/tags.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
scripts/tags.sh +6 -4
index e137cf15aae9..c56b13ae3fdf 100755
@@ -264,10 +264,12 @@ exuberant()
 	--$CTAGS_EXTRA=+fq --c-kinds=+px --fields=+iaS --langmap=c:+.h \
 	"${regex[@]}"
 
-	setup_regex exuberant kconfig
-	all_kconfigs | xargs $1 -a                              \
-	--langdef=kconfig --language-force=kconfig "${regex[@]}"
-
+	KCONFIG_ARGS=""
+	if ! $1 --list-languages | grep -iq kconfig; then
+		setup_regex exuberant kconfig
+		KCONFIG_ARGS="--langdef=kconfig --language-force=kconfig ${regex[@]}"
+	fi
+	all_kconfigs | xargs $1 -a $KCONFIG_ARGS
 }
 
 emacs()
Signature · 1 line
2.38.1
#1 lore raw
Quoted 20 lines · Kevin Hao

The Kconfig language has already been built-in in the latest ctags, so it would error exit if we try to define it as an user-defined language via '--langdef=kconfig'. This results that there is no Kconfig tags in the final tag file. Fix this by skipping the user Kconfig definition for the latest ctags.

---
  scripts/tags.sh | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
scripts/tags.sh +0 -1
index e137cf15aae9..c56b13ae3fdf 100755
@@ -264,10 +264,12 @@ exuberant()
  	--$CTAGS_EXTRA=+fq --c-kinds=+px --fields=+iaS --langmap=c:+.h \
  	"${regex[@]}"
 
-	setup_regex exuberant kconfig

scripts/tags.sh exuberant() · line 273

Quoted 10 lines
scripts/tags.sh +6 -3
-	all_kconfigs | xargs $1 -a                              \
-	--langdef=kconfig --language-force=kconfig "${regex[@]}"
-
+	KCONFIG_ARGS=""
+	if ! $1 --list-languages | grep -iq kconfig; then
+		setup_regex exuberant kconfig
+		KCONFIG_ARGS="--langdef=kconfig --language-force=kconfig ${regex[@]}"
+	fi
+	all_kconfigs | xargs $1 -a $KCONFIG_ARGS
  }

The 'regex' array needs quoting to prevent word splitting/globbing. I would suggest to transform 'KCONFIG_ARGS' into an array as well:

KCONFIG_ARGS=()
if ! $1 --list-languages | grep -iq kconfig; then

	setup_regex exuberant kconfig
	KCONFIG_ARGS=(--langdef=kconfig --language-force=kconfig "${regex[@]}")

fi
all_kconfigs | xargs $1 -a "${KCONFIG_ARGS[@]}"

Quoted 1 line
scripts/tags.sh +0 -0
  emacs()
author
#2 lore raw
Quoted 25 lines · Cristian Ciocaltea
Quoted 23 lines · Kevin Hao

The Kconfig language has already been built-in in the latest ctags, so it would error exit if we try to define it as an user-defined language via '--langdef=kconfig'. This results that there is no Kconfig tags in the final tag file. Fix this by skipping the user Kconfig definition for the latest ctags.

---
  scripts/tags.sh | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
scripts/tags.sh +1 -4
index e137cf15aae9..c56b13ae3fdf 100755
@@ -264,10 +264,12 @@ exuberant()
  	--$CTAGS_EXTRA=+fq --c-kinds=+px --fields=+iaS --langmap=c:+.h \
  	"${regex[@]}"
-	setup_regex exuberant kconfig
-	all_kconfigs | xargs $1 -a                              \
-	--langdef=kconfig --language-force=kconfig "${regex[@]}"
-
+	KCONFIG_ARGS=""
Quoted 8 lines

scripts/tags.sh exuberant() · line 273

Quoted 6 lines
scripts/tags.sh +5 -0
+	if ! $1 --list-languages | grep -iq kconfig; then
+		setup_regex exuberant kconfig
+		KCONFIG_ARGS="--langdef=kconfig --language-force=kconfig ${regex[@]}"
+	fi
+	all_kconfigs | xargs $1 -a $KCONFIG_ARGS
  }

The 'regex' array needs quoting to prevent word splitting/globbing.

Fair enough.

Quoted 2 lines

I would
suggest to transform 'KCONFIG_ARGS' into an array as well:

Sounds great. V2 is coming.

Thanks,
Kevin

Quoted 10 lines

KCONFIG_ARGS=()
if ! $1 --list-languages | grep -iq kconfig; then

	setup_regex exuberant kconfig
	KCONFIG_ARGS=(--langdef=kconfig --language-force=kconfig "${regex[@]}")

fi
all_kconfigs | xargs $1 -a "${KCONFIG_ARGS[@]}"

Quoted 1 line
scripts/tags.sh +0 -0
  emacs()