Message ID | Y5UP+tnnxNgoi6A2@mail.google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1533772wrr; Sat, 10 Dec 2022 15:25:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5WsYb4rsI6i3eDyVnpzj2bLmuiyRilwaCdcO1ofOlxIGCCCdUZ3pv7VlsWoU6Ij5Suh1VX X-Received: by 2002:a05:6a20:bca9:b0:ac:ab16:442 with SMTP id fx41-20020a056a20bca900b000acab160442mr12488050pzb.4.1670714739714; Sat, 10 Dec 2022 15:25:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670714739; cv=none; d=google.com; s=arc-20160816; b=SitbWukvAVEVHhtRP9/UqgJ4i/mRl1KyDmyj5JVGGg6D/1NCm3kejSqa9eu0g9+Gp6 VZ/kI5lUyNV2WGi1plIDtk4SfQv0pNUiA8V/zvy6MieX/vScMyVDJPZyQt6xlCAhU3PD iT3B+9QgaSETVrP9xabGCkolfC8LthKToRLk5tuxpom5H4rCjWElNS40uc4UyOe/gLim alyY+sqC8bpH4KhnDa4uZPPh6b2N6s+uw5GjkOqJ0Q7zXK6yYFvCCq8Zweq2F4q6TZPR jiAbRB0xW4q7Pdq1hnwPdnEq226MUjYXXy3XQqahIWP3PlKnIkZrZ/V3QW3tR2HFVHat bmcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=fbQVHhDJyzijvT4x1l1d64e6Tgo3Ph+ZZvjIzYq/8P0=; b=R2OkTSg8o1JqdqMfMHIUjQ9RiL6U2YiQ7sfFmUzjW8eSdhaEoWFU93RrR/Ueho9tz4 pkKHSHAMTnRoc4WMmbVgQ8uFouuxQVdB0lheXkCZtqBeBhUFmznrtQndAJ1Pv/sLpVi/ aktdHcN+5vZb7cp4JT4pkDKIE5+l8bzXBeuREoNbSIb0qrfNszkmQPj+I2FoBg7Gs95u CaX676XvN3NbySKibD8G75ilpoCIoU91F1M0h6DrX1m5ueO8fOYqQeS5fCDfgZKOtPnn 1tqmBNED8yx7nh+k/UA0Ka5CXOmsz9yapn02oUTydsk3iyAh3IQ454ym0a+/5HshAoTg +G6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BC51zln0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f26-20020a63101a000000b0046f357face9si5324628pgl.356.2022.12.10.15.25.26; Sat, 10 Dec 2022 15:25:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BC51zln0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbiLJXCo (ORCPT <rfc822;jz.zhangjin@gmail.com> + 99 others); Sat, 10 Dec 2022 18:02:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbiLJXC3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 10 Dec 2022 18:02:29 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D74291402E; Sat, 10 Dec 2022 15:02:27 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id 21so6157178pfw.4; Sat, 10 Dec 2022 15:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=fbQVHhDJyzijvT4x1l1d64e6Tgo3Ph+ZZvjIzYq/8P0=; b=BC51zln0pmZC6OGmdhqN2MW43ldQkZqt7n/UKeTJ2K5nyKNKixaasUFdg1UtQr/7Dy 7dwNkuh7zWWPAZ3DR1gk7EH9nwVHvm2vP1BBAeK/f3luz0TviH5CTGJOhY8mD7UF7e1P xjS/w5zerB9WfgCmdrewkqOkW30R5ptrhehbA9gwHFlWTgumHLf5h2HBCjOojKyn2Ryz 0qY+ywf3tuBtmsHlktfEeUuUkWOb6AF6UwksylVoOcedPUeFzOQj0bHq3poA+6rUxHkW WTAfLI1sqbuEnJ4hD2vp8Zt6lJBjWJ8f/u6ig8rB9N56Jezq4pdfC4KjNhKcj0Melnj7 t6qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fbQVHhDJyzijvT4x1l1d64e6Tgo3Ph+ZZvjIzYq/8P0=; b=KlTE8NTK7lPOnr22VVdSfkalf186aLmXOWbr/j3JtJgwSeFe/xzsg3HHm9+GDokjAS 8jVJttogs/CmdD/bx03M+no8nQlsj5oFO6WfKndEd6AYu11X6YJZUzPBWJXo6F28O5sU vj+zcQy9ZH144w+1Rpxmnmrb78ILI82TCkavpSoK5kObwTay7zot2lcQuoAN+dDYqC0F 1WjleDyoUfllBR7UjZ8F5Kjsg5lMKhpnZG6jsGf9XILoppF6XRHwvSvMUf3n/3AugsZ7 3Q8vN6j5oCuicy+hNdC33twPDrZgw2Th+vaNUMI90dBUUvJH4l3k5s2AqfqSHr6Y5YCr ZqHA== X-Gm-Message-State: ANoB5plLMgm7jqOrKEcDV7TKGh7Z/cPWE73LOQNyuQmTBuIlevIe4e6M hhVJrPMNJv/7AIwREJSCcPE= X-Received: by 2002:aa7:9089:0:b0:566:900d:8242 with SMTP id i9-20020aa79089000000b00566900d8242mr2345930pfa.3.1670713347279; Sat, 10 Dec 2022 15:02:27 -0800 (PST) Received: from mail.google.com (125-237-37-88-fibre.sparkbb.co.nz. [125.237.37.88]) by smtp.gmail.com with ESMTPSA id x12-20020aa79acc000000b0057725613627sm3283714pfp.142.2022.12.10.15.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Dec 2022 15:02:26 -0800 (PST) Date: Sun, 11 Dec 2022 12:02:18 +1300 From: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com> To: Masahiro Yamada <masahiroy@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu>, Jonathan Corbet <corbet@lwn.net>, Cristian Ciocaltea <cristian.ciocaltea@collabora.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Vipin Sharma <vipinsh@google.com> Cc: linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, paulo.miguel.almeida.rodenas@gmail.com Subject: [PATCH v2] scripts/tags.sh: choose which directories to exclude from being indexed Message-ID: <Y5UP+tnnxNgoi6A2@mail.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <Y5T66yWNVAZNIaJ0@mail.google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751871378752683049?= X-GMAIL-MSGID: =?utf-8?q?1751871378752683049?= |
Series |
[v2] scripts/tags.sh: choose which directories to exclude from being indexed
|
|
Commit Message
Paulo Miguel Almeida
Dec. 10, 2022, 11:02 p.m. UTC
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.
This patch makes it possible for the devs to specify which folders
they don't want to include into database as part of the
find_other_sources func if a makefile variable IGNOREDIRS is present,
otherwise the original behaviour is kept.
Example:
make ARCH=x86 IGNOREDIRS=drivers/gpu/drm/radeon,tools cscope
Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
---
Changelog:
- v2: change approach to include everything unless specified by the
IGNOREDIRS variable: (Req: Vipin Sharma)
- v1: https://lore.kernel.org/lkml/Y5OKDvbGk4Kro6MK@mail.google.com/
---
Documentation/kbuild/kbuild.rst | 7 +++++++
scripts/tags.sh | 11 +++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
Comments
On Sun, Dec 11, 2022 at 12:02:18PM +1300, Paulo Miguel Almeida wrote: > This patch makes it possible for the devs to specify which folders > they don't want to include into database as part of the > find_other_sources func if a makefile variable IGNOREDIRS is present, > otherwise the original behaviour is kept. Better say "Add IGNOREDIRS variable, which specifies which directories to be ignored from indexing." > @@ -278,6 +278,13 @@ To get all available archs you can also specify all. E.g.:: > > $ make ALLSOURCE_ARCHS=all tags > > +IGNOREDIRS > +--------------- > +For tags/TAGS/cscope targets, you can choose which directories won't > +be included in the databases, separated by comma. E.g.: > + > + $ make IGNOREDIRS=drivers/gpu/drm/radeon,tools cscope > + Use two-colon syntax (::) for code block above to be consistent with other code blocks. Thanks.
On Sun, Dec 11, 2022 at 11:21:33AM +0700, Bagas Sanjaya wrote: > On Sun, Dec 11, 2022 at 12:02:18PM +1300, Paulo Miguel Almeida wrote: > > This patch makes it possible for the devs to specify which folders > > they don't want to include into database as part of the > > find_other_sources func if a makefile variable IGNOREDIRS is present, > > otherwise the original behaviour is kept. > > Better say "Add IGNOREDIRS variable, which specifies which directories > to be ignored from indexing." > > > @@ -278,6 +278,13 @@ To get all available archs you can also specify all. E.g.:: > > > > $ make ALLSOURCE_ARCHS=all tags > > > > +IGNOREDIRS > > +--------------- > > +For tags/TAGS/cscope targets, you can choose which directories won't > > +be included in the databases, separated by comma. E.g.: > > + > > + $ make IGNOREDIRS=drivers/gpu/drm/radeon,tools cscope > > + > > Use two-colon syntax (::) for code block above to be consistent with > other code blocks. > > Thanks. > > -- > An old man doll... just what I always wanted! - Clara Hi Bagas, thanks for taking the time to review this patch. I will make the changes that you've pointed out. thanks! - Paulo A,
On Sat, Dec 10, 2022 at 3:02 PM Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com> wrote: > > 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. > > This patch makes it possible for the devs to specify which folders > they don't want to include into database as part of the > find_other_sources func if a makefile variable IGNOREDIRS is present, > otherwise the original behaviour is kept. > > Example: > make ARCH=x86 IGNOREDIRS=drivers/gpu/drm/radeon,tools cscope > > Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com> > --- > Changelog: > > - v2: change approach to include everything unless specified by the > IGNOREDIRS variable: (Req: Vipin Sharma) > - v1: https://lore.kernel.org/lkml/Y5OKDvbGk4Kro6MK@mail.google.com/ > --- > Documentation/kbuild/kbuild.rst | 7 +++++++ > scripts/tags.sh | 11 +++++++++-- > 2 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst > index 08f575e6236c..5f99f30e20d8 100644 > --- a/Documentation/kbuild/kbuild.rst > +++ b/Documentation/kbuild/kbuild.rst > @@ -278,6 +278,13 @@ To get all available archs you can also specify all. E.g.:: > > $ make ALLSOURCE_ARCHS=all tags > > +IGNOREDIRS > +--------------- > +For tags/TAGS/cscope targets, you can choose which directories won't > +be included in the databases, separated by comma. E.g.: > + > + $ make IGNOREDIRS=drivers/gpu/drm/radeon,tools cscope > + > KBUILD_BUILD_TIMESTAMP > ---------------------- > Setting this to a date string overrides the timestamp used in the > diff --git a/scripts/tags.sh b/scripts/tags.sh > index e137cf15aae9..554721e9cad2 100755 > --- a/scripts/tags.sh > +++ b/scripts/tags.sh > @@ -59,10 +59,17 @@ find_include_sources() > } > > # find sources in rest of tree > -# we could benefit from a list of dirs to search in here > find_other_sources() > { > - find ${tree}* $ignore \ > + local loc_ignore=${ignore} > + if [ -n "${IGNOREDIRS}" ]; then > + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) > + for i in ${exp_ignored_dirs}; do > + loc_ignore="${loc_ignore} ( -path $i ) -prune -o" > + done > + fi > + This should be global overwrite instead of just in this function. Before find_other_sources() is executed, this script finds files in arch directories. So, if you keep it local then those files cannot be excluded which makes execution of the command incorrect: make IGNOREDIRS=arch/x86 cscope Above command will still index all of the code in arch/x86. Something like this will be better. --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -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" +if [ -n "${IGNOREDIRS}" ]; then + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) + for i in ${exp_ignored_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 @@ -62,9 +69,9 @@ find_include_sources() # we could benefit from a list of dirs to search in here find_other_sources() { - find ${tree}* $ignore \ - \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ - -name "$1" -not -type l -print; + find ${tree}* ${ignore} \ + \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ + -name "$1" -not -type l -print; } We will still have to specify arch/x86 and arch/x86/include but this works and keeps the definition of IGNOREDIRS relatively correct. > + find ${tree}* ${loc_ignore} \ > \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ > -name "$1" -not -type l -print; > } > -- > 2.38.1 >
On Mon, Dec 12, 2022 at 01:27:37PM -0800, Vipin Sharma wrote: > On Sat, Dec 10, 2022 at 3:02 PM Paulo Miguel Almeida > <paulo.miguel.almeida.rodenas@gmail.com> wrote: > > # find sources in rest of tree > > -# we could benefit from a list of dirs to search in here > > find_other_sources() > > { > > - find ${tree}* $ignore \ > > + local loc_ignore=${ignore} > > + if [ -n "${IGNOREDIRS}" ]; then > > + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) > > + for i in ${exp_ignored_dirs}; do > > + loc_ignore="${loc_ignore} ( -path $i ) -prune -o" > > + done > > + fi > > + > > This should be global overwrite instead of just in this function. > Before find_other_sources() is executed, this script finds files in > arch directories. So, if you keep it local then those files cannot be > excluded which makes execution of the command incorrect: > > make IGNOREDIRS=arch/x86 cscope > Hi Vipin, thanks for taking the time to review this patch. I see where you are coming from. I was aware of the 'loophole' that the current approach could have but, to be honest, I thought that there would be very little use in being able to exclude arch/.*?/ files. The reason for that being that I thought the most common usage for this feature would be to ignore folders within subsystems like drivers and tools to ensure code navigation would be less 'messy'. Additionally, if we go with the global IGNOREDIRS approach you just described, we could have some conflicting options too such as: make ALLSOURCE_ARCHS="x86 arm" IGNOREDIRS=arch/x86 cscope My 2 cents is that ALLSOURCE_ARCHS is already the mechanism for excluding archs so it's 'okay' to keep IGNOREDIRS as is. Let me know your thoughts. Thanks! - Paulo A. > Above command will still index all of the code in arch/x86. Something > like this will be better. > > --- a/scripts/tags.sh > +++ b/scripts/tags.sh > @@ -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" > > +if [ -n "${IGNOREDIRS}" ]; then > + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) > + for i in ${exp_ignored_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 > @@ -62,9 +69,9 @@ find_include_sources() > # we could benefit from a list of dirs to search in here > find_other_sources() > { > - find ${tree}* $ignore \ > - \( -path ${tree}include -o -path ${tree}arch -o -name > '.tmp_*' \) -prune -o \ > - -name "$1" -not -type l -print; > + find ${tree}* ${ignore} \ > + \( -path ${tree}include -o -path ${tree}arch -o -name > '.tmp_*' \) -prune -o \ > + -name "$1" -not -type l -print; > } > > We will still have to specify arch/x86 and arch/x86/include but this > works and keeps the definition of IGNOREDIRS relatively correct. > > > > + find ${tree}* ${loc_ignore} \ > > \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ > > -name "$1" -not -type l -print; > > } > > -- > > 2.38.1 > >
On Mon, Dec 12, 2022 at 1:59 PM Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com> wrote: > > On Mon, Dec 12, 2022 at 01:27:37PM -0800, Vipin Sharma wrote: > > On Sat, Dec 10, 2022 at 3:02 PM Paulo Miguel Almeida > > <paulo.miguel.almeida.rodenas@gmail.com> wrote: > > > # find sources in rest of tree > > > -# we could benefit from a list of dirs to search in here > > > find_other_sources() > > > { > > > - find ${tree}* $ignore \ > > > + local loc_ignore=${ignore} > > > + if [ -n "${IGNOREDIRS}" ]; then > > > + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) > > > + for i in ${exp_ignored_dirs}; do > > > + loc_ignore="${loc_ignore} ( -path $i ) -prune -o" > > > + done > > > + fi > > > + > > > > This should be global overwrite instead of just in this function. > > Before find_other_sources() is executed, this script finds files in > > arch directories. So, if you keep it local then those files cannot be > > excluded which makes execution of the command incorrect: > > > > make IGNOREDIRS=arch/x86 cscope > > > > Hi Vipin, thanks for taking the time to review this patch. > > I see where you are coming from. I was aware of the 'loophole' that the > current approach could have but, to be honest, I thought that there > would be very little use in being able to exclude arch/.*?/ files. > > The reason for that being that I thought the most common usage for this > feature would be to ignore folders within subsystems like drivers and > tools to ensure code navigation would be less 'messy'. Yes, the original intent was to make driver code browsing less messy but if we are introducing an option we should adapt it for generic cases and correct the semantics. > > Additionally, if we go with the global IGNOREDIRS approach you just > described, we could have some conflicting options too such as: > > make ALLSOURCE_ARCHS="x86 arm" IGNOREDIRS=arch/x86 cscope > I don't think this is conflicting, to me it is more complementary. Above line shows get all code for x86 and arm but don't get x86 source code ("arch/x86/include" is fine). This can even be fine tuned to sub directories. I just now noticed after seeing your command, ALLSOURCE_ARCHS take space separated values, whereas, IGNOREDIRS take comma separated values. They both should be in the same format, since ALLSOURCE_ARCHS was already there, it is better to change IGNOREDIRS. Can you also change IGNOREDIRS to IGNORE_DIRS? It is much easier to read this way. Sorry, I should have said this in the beginning. > My 2 cents is that ALLSOURCE_ARCHS is already the mechanism for > excluding archs so it's 'okay' to keep IGNOREDIRS as is. > > Let me know your thoughts. > > Thanks! > > - Paulo A. > > > Above command will still index all of the code in arch/x86. Something > > like this will be better. > > > > --- a/scripts/tags.sh > > +++ b/scripts/tags.sh > > @@ -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" > > > > +if [ -n "${IGNOREDIRS}" ]; then > > + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) > > + for i in ${exp_ignored_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 > > @@ -62,9 +69,9 @@ find_include_sources() > > # we could benefit from a list of dirs to search in here > > find_other_sources() > > { > > - find ${tree}* $ignore \ > > - \( -path ${tree}include -o -path ${tree}arch -o -name > > '.tmp_*' \) -prune -o \ > > - -name "$1" -not -type l -print; > > + find ${tree}* ${ignore} \ > > + \( -path ${tree}include -o -path ${tree}arch -o -name > > '.tmp_*' \) -prune -o \ > > + -name "$1" -not -type l -print; > > } > > > > We will still have to specify arch/x86 and arch/x86/include but this > > works and keeps the definition of IGNOREDIRS relatively correct. > > > > > > > + find ${tree}* ${loc_ignore} \ > > > \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ > > > -name "$1" -not -type l -print; > > > } > > > -- > > > 2.38.1 > > >
On Mon, Dec 12, 2022 at 02:32:41PM -0800, Vipin Sharma wrote: > On Mon, Dec 12, 2022 at 1:59 PM Paulo Miguel Almeida > <paulo.miguel.almeida.rodenas@gmail.com> wrote: > > > > On Mon, Dec 12, 2022 at 01:27:37PM -0800, Vipin Sharma wrote: > > > On Sat, Dec 10, 2022 at 3:02 PM Paulo Miguel Almeida > > > <paulo.miguel.almeida.rodenas@gmail.com> wrote: > > > > # find sources in rest of tree > > > > -# we could benefit from a list of dirs to search in here > > > > find_other_sources() > > > > { > > > > - find ${tree}* $ignore \ > > > > + local loc_ignore=${ignore} > > > > + if [ -n "${IGNOREDIRS}" ]; then > > > > + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) > > > > + for i in ${exp_ignored_dirs}; do > > > > + loc_ignore="${loc_ignore} ( -path $i ) -prune -o" > > > > + done > > > > + fi > > > > + > > > > > > This should be global overwrite instead of just in this function. > > > Before find_other_sources() is executed, this script finds files in > > > arch directories. So, if you keep it local then those files cannot be > > > excluded which makes execution of the command incorrect: > > > > > > make IGNOREDIRS=arch/x86 cscope > > > > > > > Hi Vipin, thanks for taking the time to review this patch. > > > > I see where you are coming from. I was aware of the 'loophole' that the > > current approach could have but, to be honest, I thought that there > > would be very little use in being able to exclude arch/.*?/ files. > > > > The reason for that being that I thought the most common usage for this > > feature would be to ignore folders within subsystems like drivers and > > tools to ensure code navigation would be less 'messy'. > > Yes, the original intent was to make driver code browsing less messy > but if we are introducing an option we should adapt it for generic > cases and correct the semantics. Agreed. > > > > > Additionally, if we go with the global IGNOREDIRS approach you just > > described, we could have some conflicting options too such as: > > > > make ALLSOURCE_ARCHS="x86 arm" IGNOREDIRS=arch/x86 cscope > > > > I don't think this is conflicting, to me it is more complementary. > Above line shows get all code for x86 and arm but don't get x86 source > code ("arch/x86/include" is fine). This can even be fine tuned to sub > directories. > That's a fair point. I had not thought about it that way. Thanks! Will implement the changes when I get home. > I just now noticed after seeing your command, ALLSOURCE_ARCHS take > space separated values, whereas, IGNOREDIRS take comma separated > values. They both should be in the same format, since ALLSOURCE_ARCHS > was already there, it is better to change IGNOREDIRS. > > Can you also change IGNOREDIRS to IGNORE_DIRS? It is much easier to > read this way. Sorry, I should have said this in the beginning. > Yep, no problem! :-) > > My 2 cents is that ALLSOURCE_ARCHS is already the mechanism for > > excluding archs so it's 'okay' to keep IGNOREDIRS as is. > > > > Let me know your thoughts. > > > > Thanks! > > > > - Paulo A. > > > > > Above command will still index all of the code in arch/x86. Something > > > like this will be better. > > > > > > --- a/scripts/tags.sh > > > +++ b/scripts/tags.sh > > > @@ -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" > > > > > > +if [ -n "${IGNOREDIRS}" ]; then > > > + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) > > > + for i in ${exp_ignored_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 > > > @@ -62,9 +69,9 @@ find_include_sources() > > > # we could benefit from a list of dirs to search in here > > > find_other_sources() > > > { > > > - find ${tree}* $ignore \ > > > - \( -path ${tree}include -o -path ${tree}arch -o -name > > > '.tmp_*' \) -prune -o \ > > > - -name "$1" -not -type l -print; > > > + find ${tree}* ${ignore} \ > > > + \( -path ${tree}include -o -path ${tree}arch -o -name > > > '.tmp_*' \) -prune -o \ > > > + -name "$1" -not -type l -print; > > > } > > > > > > We will still have to specify arch/x86 and arch/x86/include but this > > > works and keeps the definition of IGNOREDIRS relatively correct. > > > > > > > > > > + find ${tree}* ${loc_ignore} \ > > > > \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ > > > > -name "$1" -not -type l -print; > > > > } > > > > -- > > > > 2.38.1 > > > >
diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst index 08f575e6236c..5f99f30e20d8 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -278,6 +278,13 @@ To get all available archs you can also specify all. E.g.:: $ make ALLSOURCE_ARCHS=all tags +IGNOREDIRS +--------------- +For tags/TAGS/cscope targets, you can choose which directories won't +be included in the databases, separated by comma. E.g.: + + $ make IGNOREDIRS=drivers/gpu/drm/radeon,tools cscope + KBUILD_BUILD_TIMESTAMP ---------------------- Setting this to a date string overrides the timestamp used in the diff --git a/scripts/tags.sh b/scripts/tags.sh index e137cf15aae9..554721e9cad2 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -59,10 +59,17 @@ find_include_sources() } # find sources in rest of tree -# we could benefit from a list of dirs to search in here find_other_sources() { - find ${tree}* $ignore \ + local loc_ignore=${ignore} + if [ -n "${IGNOREDIRS}" ]; then + exp_ignored_dirs=$(sed 's/,/ /g' <<< ${IGNOREDIRS}) + for i in ${exp_ignored_dirs}; do + loc_ignore="${loc_ignore} ( -path $i ) -prune -o" + done + fi + + find ${tree}* ${loc_ignore} \ \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ -name "$1" -not -type l -print; }