Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] scripts/tags.sh: Prevent binary files appearing in cscope.files
       [not found] <https://lore.kernel.org/lkml/akVkIrcpNxZrrfii@levanger/>
@ 2026-07-05 17:59 ` Sergei Litvin
  2026-07-05 18:05   ` Miguel Ojeda
  2026-07-05 17:59 ` [PATCH] scripts/tags.sh: Add support for rust source files Sergei Litvin
  1 sibling, 1 reply; 3+ messages in thread
From: Sergei Litvin @ 2026-07-05 17:59 UTC (permalink / raw)
  To: nsc
  Cc: miguel.ojeda.sandonis, nathan, rust-for-linux, linux-kernel,
	linux-kbuild, ojeda, Sergei Litvin

PROBLEM

When executing the command `make COMPILED_SOURCE=1 cscope`, the resulting
`cscope.files` file contains filenames with the extensions *.rlib, *.rmeta,
and *.so.

SOLUTION

Modify the regular expression in the `all_compiled_sources()` function so
that only files with the extensions *.h, *.c, *.S, and *.rs are accepted.

---

This is the first 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/

Signed-off-by: Sergei Litvin <litvindev@gmail.com>
---
 scripts/tags.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/tags.sh b/scripts/tags.sh
index 243373683f98..c9dc2763a505 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -100,7 +100,7 @@ all_compiled_sources()
 	{
 		echo include/generated/autoconf.h
 		find $ignore -name "*.cmd" -exec \
-			grep -Poh '(?<=^  )\S+|(?<== )\S+[^\\](?=$)' {} \+ |
+			grep -Poh '(?<=^  )\S+\.([chS]|rs)(?=\s)|(?<== )\S+\.(?1)(?=$)' {} \+ |
 		awk '!a[$0]++'
 	} | xargs realpath -esq $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) |
 	sort -u
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] scripts/tags.sh: Add support for rust source files
       [not found] <https://lore.kernel.org/lkml/akVkIrcpNxZrrfii@levanger/>
  2026-07-05 17:59 ` [PATCH] scripts/tags.sh: Prevent binary files appearing in cscope.files Sergei Litvin
@ 2026-07-05 17:59 ` Sergei Litvin
  1 sibling, 0 replies; 3+ messages in thread
From: Sergei Litvin @ 2026-07-05 17:59 UTC (permalink / raw)
  To: nsc
  Cc: miguel.ojeda.sandonis, nathan, rust-for-linux, linux-kernel,
	linux-kbuild, ojeda, Sergei Litvin

PROBLEM

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.

SOLUTION

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.

This causes `make cscope` command to generate a `cscope.files` file that
contains *.rs files along with *.h, *.c, *.S

---

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/

Signed-off-by: Sergei Litvin <litvindev@gmail.com>
---
 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.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scripts/tags.sh: Prevent binary files appearing in cscope.files
  2026-07-05 17:59 ` [PATCH] scripts/tags.sh: Prevent binary files appearing in cscope.files Sergei Litvin
@ 2026-07-05 18:05   ` Miguel Ojeda
  0 siblings, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2026-07-05 18:05 UTC (permalink / raw)
  To: Sergei Litvin
  Cc: nsc, nathan, rust-for-linux, linux-kernel, linux-kbuild, ojeda

On Sun, Jul 5, 2026 at 7:59 PM Sergei Litvin <litvindev@gmail.com> wrote:
>
> PROBLEM

> SOLUTION

We don't typically use titles like these in commits. (Same for the other patch.)

> This causes `make cscope` command to generate a `cscope.files` file that
> contains *.rs files along with *.h, *.c, *.S

Missing Signed-off-by -- the one you wrote is below, in the part that
doesn't go into the commit, i.e. after the `---` line. (Same for the
other patch.)

Also consider using `-v2` in `git format-patch` to annotate which version it is.

By the way, this sounds like it could be backported? i.e. perhaps we
want a Fixes: tag and Cc: stable@vger.kernel.org.

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-05 18:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <https://lore.kernel.org/lkml/akVkIrcpNxZrrfii@levanger/>
2026-07-05 17:59 ` [PATCH] scripts/tags.sh: Prevent binary files appearing in cscope.files Sergei Litvin
2026-07-05 18:05   ` Miguel Ojeda
2026-07-05 17:59 ` [PATCH] scripts/tags.sh: Add support for rust source files Sergei Litvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox