Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7372043rwb; Mon, 12 Dec 2022 13:51:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4CxKp8wCqtBK2lyg6yTa7JH/by+Flk/2syKogsD0ycGMONt+cLKGgGni5JaqQ7Gdx+gc0C X-Received: by 2002:a17:906:289b:b0:7c1:6091:e76 with SMTP id o27-20020a170906289b00b007c160910e76mr6936797ejd.53.1670881893491; Mon, 12 Dec 2022 13:51:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670881893; cv=none; d=google.com; s=arc-20160816; b=ARyuHffxpl5kmVsn80TCE0T4OtyGof+iF3qwclh2/TbUOcE9foxr3O/yr8A/1BkReb bBPLBcMq9hhgQxKJWYTVJ1dGoD0fRf+T+Xs06InXDBoomtF0KDyk+UMBZvSz412INsLZ rqvt1369dWQJb8mnX3d1EhxXlMzN8+SNOlOrZUKai/kisnz+KUf/v9pky8PFik32NoDg Ndt9tIllyFo4L1xMVGNWp37YigMwuQUYDZ6l+mmQxs0wVEIkTpAnYBwTls6pyhPx4npz GzsGnO2s6ouV6LGRPRmc1o1pW0kHwZC80jiNK6vE4eZmUSOppZDhsXTH+27xyu0IrIOq y7Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bjozKbUPp2aSy7H80qOc83Wx7QmZ8foKl3aEy6/ZtSU=; b=Qmixf+7RT+hOT6xB6HueZzcmGk8/qVlIhcgMnATPhEYRzv+coAaYJJBEvKz2cSBz8M ZNTqBqqJVBhzIhyviq6PJQalumPRZVItD8cQlGVtOKPye9tlhHiA8pGOSApw2PFn1ymt /sruhCrT5jvIb7t928pID+wJ5S0l0XdwH+6hJyHQawgCHBpppJmIIYB8tqSEl/DhTozo d21ndbxDnqPoxkkljiuw9Bkp+k2xtAi72KMsH/YbPtPUXfjumfjr7u/miHucUKgBS0ov /K7me2VH6Jdg4y4/3WzPe3EtielqRkQwVmcXW+Xowgp2O9pHXXS62Zx13DF2rMusr5da W+cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aDrhhFmv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf36-20020a1709077f2400b007c0abf0760fsi7885215ejc.54.2022.12.12.13.51.14; Mon, 12 Dec 2022 13:51:33 -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=@google.com header.s=20210112 header.b=aDrhhFmv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233083AbiLLV2X (ORCPT + 75 others); Mon, 12 Dec 2022 16:28:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233140AbiLLV2S (ORCPT ); Mon, 12 Dec 2022 16:28:18 -0500 Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1729FC1 for ; Mon, 12 Dec 2022 13:28:15 -0800 (PST) Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-3b10392c064so166222487b3.0 for ; Mon, 12 Dec 2022 13:28:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bjozKbUPp2aSy7H80qOc83Wx7QmZ8foKl3aEy6/ZtSU=; b=aDrhhFmvvBTmdmJGxUnEwEWAgqlgRJDCfh6CqevYvMpXDuusmx6aHiHlYPYu1HbZEp RpqRY8H9t36pDH0XWMsNAvJNtF5Zt/F2MbbgR8B0bhxkE1rIcqrkw4chdpIWRJ7b9+Ri +c4ZVW0xU2W02AQ5hLxH2bzjOtmacPBXhvltfYX57LN8Z9goC+3U0Nhk5y0uGsMQxp7q eJwxz/A/3kNAXsVJqvX3MSy6XFrOQs6VyYspR2eqnQfvN3cG+av+FOUPqqyhIFR8QL29 csITXurmbAfKEcE7gydokmNy9cuv349+7cJwfKxnm72quB2/fhmN/Bq00Ze9A55B3Zt9 mHPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bjozKbUPp2aSy7H80qOc83Wx7QmZ8foKl3aEy6/ZtSU=; b=Ps90lLyqL5+1zWN07pABHsQr32yPGjCFPlHQOmuNAwEkAmfiUDgY7jg7Pwq1PfbvE7 B1h93s1yV1HFCHEW/RbmsNQ9qzHMCJ93+smPWrmyBYzE+02lk0AAf2gD8dENzgnvrk5O 3JRAIk9BTmaiyd34Wn4iruuw4oTOITwm+bfdzknJ2weWsuQiAhfSr4sZrxt8gisT/7dn bGiiDncL1QkQdASF8hSfkG5SH7Y5Tuj5X61RrZC+tyASTyJi4EtCs5kBvIG9he5uhJ5b wgEcS1vzazE7sKbJ9rrLYEj8RlltKN4xSKbmitob2ZLtHZ9Z9FzQz91ntzYTtMI4XmQK cy8w== X-Gm-Message-State: ANoB5pmhJyecnzvvBcZ3mv2m342AjU6dye0obGuoBmE1nhwCA2Ru6A4H mdUznqFKcRJxhC8CVesT/Whi+J2xH5AFJUE4C39Qpw== X-Received: by 2002:a0d:dd8a:0:b0:391:c415:f872 with SMTP id g132-20020a0ddd8a000000b00391c415f872mr9059013ywe.318.1670880493965; Mon, 12 Dec 2022 13:28:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Vipin Sharma Date: Mon, 12 Dec 2022 13:27:37 -0800 Message-ID: Subject: Re: [PATCH v2] scripts/tags.sh: choose which directories to exclude from being indexed To: Paulo Miguel Almeida Cc: Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Jonathan Corbet , Cristian Ciocaltea , Greg Kroah-Hartman , linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 10, 2022 at 3:02 PM Paulo Miguel Almeida 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 > --- > 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 >