Skip to contentSkip to conversation

scripts/tags.sh: choose which directories to exclude from being indexed

PATCH RESEND In review Paulo Miguel Almeida 2 participants 2 messages Jan 3, 2023 – Jan 10, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND v3 1/1 scripts/tags.sh: choose which directories to exclude from being indexed

It's common for drivers that share same physical components to also duplicate source code (or at least portions of it). A good example is both drivers/gpu/drm/amdgpu/* and drivers/gpu/drm/radeon/* have a header file called atombios.h.

While their contents aren't the same, a lot of their structs have the exact same names which makes navigating through the code base a bit messy as cscope will show up 'references' across drivers which aren't exactly correct.

Add IGNORE_DIRS variable, which specifies which directories to be ignored from indexing.

Example:
make ARCH=x86 IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope

---
Changelog:

- v3: change commit message wording and rst syntax (Req Bagas Sanjaya) change makefile variable scope to global, use blank space separator and change variable name to IGNORE_DIRS. (Req: Vipin Sharma)
- v2: change approach to include everything unless specified by the IGNOREDIRS variable: (Req: Vipin Sharma)
- v1: https://lore.kernel.org/lkml/[email protected]/

Additional notes (if relevant):
- Patch v3 was reviewed-by Vipin Sharma here:
https://lore.kernel.org/lkml/CAHVum0eNp5Dup_KyrS2N0zu5TfrtcCxphRnLuBFZa5PxahVg7A@mail.gmail.com/

---
 Documentation/kbuild/kbuild.rst | 7 +++++++
 scripts/tags.sh                 | 7 +++++++
 2 files changed, 14 insertions(+)
Documentation/kbuild/kbuild.rst +7 -0
index 08f575e6236c..5202186728b4 100644
@@ -278,6 +278,13 @@ To get all available archs you can also specify all. E.g.::
 
     $ make ALLSOURCE_ARCHS=all tags
 
+IGNORE_DIRS
+-----------
+For tags/TAGS/cscope targets, you can choose which directories won't
+be included in the databases, separated by blank space. E.g.::
+
+    $ make IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope
+
 KBUILD_BUILD_TIMESTAMP
 ----------------------
 Setting this to a date string overrides the timestamp used in the
scripts/tags.sh +7 -0
index e137cf15aae9..1ad45f17179a 100755
@@ -17,6 +17,13 @@ ignore="$(echo "$RCS_FIND_IGNORE" | sed 's|\\||g' )"
 # tags and cscope files should also ignore MODVERSION *.mod.c files
 ignore="$ignore ( -name *.mod.c ) -prune -o"
 
+# ignore arbitrary directories
+if [ -n "${IGNORE_DIRS}" ]; then
+	for i in ${IGNORE_DIRS}; do
+		ignore="${ignore} ( -path $i ) -prune -o"
+	done
+fi
+
 # Use make KBUILD_ABS_SRCTREE=1 {tags|cscope}
 # to force full paths for a non-O= build
 if [ "${srctree}" = "." -o -z "${srctree}" ]; then
Signature · 1 line
2.38.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 41 lines · Paulo Miguel Almeida

It's common for drivers that share same physical components to also duplicate source code (or at least portions of it). A good example is both drivers/gpu/drm/amdgpu/* and drivers/gpu/drm/radeon/* have a header file called atombios.h.

While their contents aren't the same, a lot of their structs have the exact same names which makes navigating through the code base a bit messy as cscope will show up 'references' across drivers which aren't exactly correct.

Add IGNORE_DIRS variable, which specifies which directories to be ignored from indexing.

Example:
make ARCH=x86 IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope

---
Changelog:

- v3: change commit message wording and rst syntax (Req Bagas Sanjaya) change makefile variable scope to global, use blank space separator and change variable name to IGNORE_DIRS. (Req: Vipin Sharma)
- v2: change approach to include everything unless specified by the IGNOREDIRS variable: (Req: Vipin Sharma)
- v1: https://lore.kernel.org/lkml/[email protected]/

Additional notes (if relevant):
- Patch v3 was reviewed-by Vipin Sharma here:
https://lore.kernel.org/lkml/CAHVum0eNp5Dup_KyrS2N0zu5TfrtcCxphRnLuBFZa5PxahVg7A@mail.gmail.com/

---
 Documentation/kbuild/kbuild.rst | 7 +++++++
 scripts/tags.sh                 | 7 +++++++
 2 files changed, 14 insertions(+)
Documentation/kbuild/kbuild.rst +0 -0
index 08f575e6236c..5202186728b4 100644

Documentation/kbuild/kbuild.rst To get all available archs you can also specify all. E.g.:: · line 287

Quoted 10 lines
Documentation/kbuild/kbuild.rst +7 -0
@@ -278,6 +278,13 @@ To get all available archs you can also specify all. E.g.::
 
     $ make ALLSOURCE_ARCHS=all tags
 
+IGNORE_DIRS
+-----------
+For tags/TAGS/cscope targets, you can choose which directories won't
+be included in the databases, separated by blank space. E.g.::
+
+    $ make IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope
+

Thanks for the patch!

I think it might be good to add a note about that this is not ignoring arch sources (here and in the commit message). For kbuild.rst perhaps something like: "For filtering-out sources below arch, see ALLSOURCE_ARCHS above."