[PATCH v4] scripts/tags.sh: Add support for rust source files

Sergei Litvin posted 1 patch 1 week, 4 days ago
scripts/tags.sh | 40 +++++++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 9 deletions(-)
[PATCH v4] scripts/tags.sh: Add support for rust source files
Posted by Sergei Litvin 1 week, 4 days ago
When executing the command `make cscope`, the `cscope.files` file generated
by it includes only filenames with the extensions *.h, *.c, *.S and not includes
filenames with *.rs extensions.

To fix this, modify the functions `find_arch_sources()`,
`find_arch_include_sources()`, `find_include_sources()`, and
`find_other_sources()` so that they can accept an unlimited number of filename
patterns as parameters for the search. Add the `setup_name_pattern()` function
to convert these filename pattern parameters into a list of parameters that can
be passed to the `find` utility via the new `pattern` variable.

Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Boqun Feng <boqun@kernel.org>
Cc: Gary Guo <gary@garyguo.net>
Cc: Björn Roy Baron <bjorn3_gh@protonmail.com>
Cc: Benno Lossin <lossin@kernel.org>
Cc: Andreas Hindborg <a.hindborg@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Trevor Gross <tmgross@umich.edu>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Daniel Almeida <daniel.almeida@collabora.com>
Cc: Tamir Duberstein <tamird@kernel.org>
Cc: Alexandre Courbot <acourbot@nvidia.com>
Cc: Onur Özkan <work@onurozkan.dev>
Cc: nsc@kernel.org
Cc: nathan@kernel.org
Signed-off-by: Sergei Litvin <litvindev@gmail.com>

---

This is the second part of this patch:
https://lore.kernel.org/lkml/20260602121521.11650-1-litvindev@gmail.com/

which I have split into two parts, as suggested by Nicolas Schier here:
https://lore.kernel.org/lkml/akVkIrcpNxZrrfii@levanger/

Changes since V3:
https://lore.kernel.org/lkml/20260714122441.78158-1-litvindev@gmail.com/

- Fixed list of "Cc:" tags

Changes since V2:
https://lore.kernel.org/lkml/20260714083709.69517-1-litvindev@gmail.com/

as suggested by Miguel Ojeda here:
https://lore.kernel.org/lkml/CANiq72k0RbkWk=8hiNzHUmFWr=6OA2DBHAUew4OfZb_Umb=6hA@mail.gmail.com/

- Remove "Cc: stable@vger.kernel.org" tag, because this commit introduces a new
feature.

Changes since V1:
https://lore.kernel.org/lkml/20260705175957.4672-1-litvindev@gmail.com/

as suggested by Miguel Ojeda here:
https://lore.kernel.org/lkml/CANiq72kHbVQfNrum5D2a5sCd3mFQHNtigrQxP1WW=YcggxA=WQ@mail.gmail.com/

- Add "Cc: stable@vger.kernel.org" tag
- Add missed "Signed-off-by:" tag
---
 scripts/tags.sh | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/scripts/tags.sh b/scripts/tags.sh
index c9dc2763a505..41e38df96984 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -46,13 +46,31 @@ elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then
 	ALLSOURCE_ARCHS=$(find ${tree}arch/ -mindepth 1 -maxdepth 1 -type d -printf '%f ')
 fi
 
+setup_name_pattern()
+{
+	pattern=()
+	for ext; do
+		if [ ${#pattern[@]} -gt 0 ]; then
+			pattern+=("-o" "-name" "$ext")
+		else
+			pattern+=("(" "-name" "$ext")
+		fi
+	done
+	if [ ${#pattern[@]} -gt 0 ]; then
+		pattern+=(")")
+	fi
+}
+
 # find sources in arch/$1
 find_arch_sources()
 {
 	for i in $archincludedir; do
 		local prune="$prune ( -path $i ) -prune -o"
 	done
-	find ${tree}arch/$1 $ignore $prune -name "$2" -not -type l -print;
+	local src=${tree}arch/$1
+	shift
+	setup_name_pattern "$@"
+	find $src $ignore $prune "${pattern[@]}" -not -type l -print;
 }
 
 # find sources in arch/$1/include
@@ -61,14 +79,17 @@ find_arch_include_sources()
 	local include=$(find ${tree}arch/$1/ -name include -type d -print);
 	if [ -n "$include" ]; then
 		archincludedir="$archincludedir $include"
-		find $include $ignore -name "$2" -not -type l -print;
+		shift
+		setup_name_pattern "$@"
+		find $include $ignore "${pattern[@]}" -not -type l -print;
 	fi
 }
 
 # find sources in include/
 find_include_sources()
 {
-	find ${tree}include $ignore -name config -prune -o -name "$1" \
+	setup_name_pattern "$@"
+	find ${tree}include $ignore -name config -prune -o "${pattern[@]}" \
 		-not -type l -print;
 }
 
@@ -76,23 +97,24 @@ find_include_sources()
 # we could benefit from a list of dirs to search in here
 find_other_sources()
 {
+	setup_name_pattern "$@"
 	find ${tree}* $ignore \
 	     \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \
-	       -name "$1" -not -type l -print;
+	       "${pattern[@]}" -not -type l -print;
 }
 
 all_sources()
 {
-	find_arch_include_sources ${SRCARCH} '*.[chS]'
+	find_arch_include_sources ${SRCARCH} '*.[chS]' '*.rs'
 	if [ -n "$archinclude" ]; then
-		find_arch_include_sources $archinclude '*.[chS]'
+		find_arch_include_sources $archinclude '*.[chS]' '*.rs'
 	fi
-	find_include_sources '*.[chS]'
+	find_include_sources '*.[chS]' '*.rs'
 	for arch in $ALLSOURCE_ARCHS
 	do
-		find_arch_sources $arch '*.[chS]'
+		find_arch_sources $arch '*.[chS]' '*.rs'
 	done
-	find_other_sources '*.[chS]'
+	find_other_sources '*.[chS]' '*.rs'
 }
 
 all_compiled_sources()
-- 
2.55.0

Re: [PATCH v4] scripts/tags.sh: Add support for rust source files
Posted by Nicolas Schier 1 week, 3 days ago
On Tue, Jul 14, 2026 at 02:52:59PM +0200, Sergei Litvin wrote:
> When executing the command `make cscope`, the `cscope.files` file generated
> by it includes only filenames with the extensions *.h, *.c, *.S and not includes
> filenames with *.rs extensions.

With removed Cc trailers and adjusted line break in the commit message, applied
to kbuild/linux.git (kbuild-next-unstable), thanks!

[1/1] scripts/tags.sh: Prevent binary files appearing in cscope.files
      https://git.kernel.org/kbuild/c/4859c0d5

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped,
reverted or modified (e.g. trailers). Patches applied to the
kbuild-next-unstable branch are accepted pending wider testing in
linux-next and any post-commit review; they will generally be moved
to the kbuild-next branch in about a week if no issues are found.

Best regards,
-- 
Nicolas
Re: [PATCH v4] scripts/tags.sh: Add support for rust source files
Posted by Miguel Ojeda 1 week, 4 days ago
On Tue, Jul 14, 2026 at 3:01 PM Sergei Litvin <litvindev@gmail.com> wrote:
>
> - Fixed list of "Cc:" tags

Just to clarify, I meant to Cc in the header, rather than add everyone
as an explicit Cc tag -- the Cc: tag is (usually) meant to be a more
explicit Cc to indicate in the commit message that the particular
person had a chance to comment etc.

[ Some people do use it for every single Cc, but that is a minority
last time I took a look at it. I think it may make things easier for
some tooling, but it adds a lot of noise and reduces the signal of the
tag. ]

In any case, no need for a new version to change that! :)

Thanks!

Cheers,
Miguel
Re: [PATCH v4] scripts/tags.sh: Add support for rust source files
Posted by Nicolas Schier 1 week, 4 days ago
On Tue, Jul 14, 2026 at 02:52:59PM +0200, Sergei Litvin wrote:
> When executing the command `make cscope`, the `cscope.files` file generated
> by it includes only filenames with the extensions *.h, *.c, *.S and not includes
> filenames with *.rs extensions.
> 
> To fix this, modify the functions `find_arch_sources()`,
> `find_arch_include_sources()`, `find_include_sources()`, and
> `find_other_sources()` so that they can accept an unlimited number of filename
> patterns as parameters for the search. Add the `setup_name_pattern()` function
> to convert these filename pattern parameters into a list of parameters that can
> be passed to the `find` utility via the new `pattern` variable.
> 
> Cc: Miguel Ojeda <ojeda@kernel.org>
> Cc: Boqun Feng <boqun@kernel.org>
> Cc: Gary Guo <gary@garyguo.net>
> Cc: Björn Roy Baron <bjorn3_gh@protonmail.com>
> Cc: Benno Lossin <lossin@kernel.org>
> Cc: Andreas Hindborg <a.hindborg@kernel.org>
> Cc: Alice Ryhl <aliceryhl@google.com>
> Cc: Trevor Gross <tmgross@umich.edu>
> Cc: Danilo Krummrich <dakr@kernel.org>
> Cc: Daniel Almeida <daniel.almeida@collabora.com>
> Cc: Tamir Duberstein <tamird@kernel.org>
> Cc: Alexandre Courbot <acourbot@nvidia.com>
> Cc: Onur Özkan <work@onurozkan.dev>
> Cc: nsc@kernel.org
> Cc: nathan@kernel.org
> Signed-off-by: Sergei Litvin <litvindev@gmail.com>
> 
> ---
> 
> This is the second part of this patch:
> https://lore.kernel.org/lkml/20260602121521.11650-1-litvindev@gmail.com/
> 
> which I have split into two parts, as suggested by Nicolas Schier here:
> https://lore.kernel.org/lkml/akVkIrcpNxZrrfii@levanger/
> 
> Changes since V3:
> https://lore.kernel.org/lkml/20260714122441.78158-1-litvindev@gmail.com/
> 
> - Fixed list of "Cc:" tags
> 
> Changes since V2:
> https://lore.kernel.org/lkml/20260714083709.69517-1-litvindev@gmail.com/
> 
> as suggested by Miguel Ojeda here:
> https://lore.kernel.org/lkml/CANiq72k0RbkWk=8hiNzHUmFWr=6OA2DBHAUew4OfZb_Umb=6hA@mail.gmail.com/
> 
> - Remove "Cc: stable@vger.kernel.org" tag, because this commit introduces a new
> feature.
> 
> Changes since V1:
> https://lore.kernel.org/lkml/20260705175957.4672-1-litvindev@gmail.com/
> 
> as suggested by Miguel Ojeda here:
> https://lore.kernel.org/lkml/CANiq72kHbVQfNrum5D2a5sCd3mFQHNtigrQxP1WW=YcggxA=WQ@mail.gmail.com/
> 
> - Add "Cc: stable@vger.kernel.org" tag
> - Add missed "Signed-off-by:" tag
> ---
>  scripts/tags.sh | 40 +++++++++++++++++++++++++++++++---------
>  1 file changed, 31 insertions(+), 9 deletions(-)
> 

Tested-by: Nicolas Schier <n.schier@fritz.com>
Reviewed-by: Nicolas Schier <n.schier@fritz.com>


-- 
Nicolas