Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2386419rwd; Mon, 15 May 2023 10:56:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/tP7tPOeuSMfkas00InlG2TMKkQ0+86aVksT0GJVvzj28g+Il+XJQNDYxmo3/7O1xfz2T X-Received: by 2002:a05:6a20:9194:b0:f2:3d53:87b2 with SMTP id v20-20020a056a20919400b000f23d5387b2mr43246867pzd.31.1684173398814; Mon, 15 May 2023 10:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684173398; cv=none; d=google.com; s=arc-20160816; b=Af5Rw8sagCDGM3G0fRPpsgTolHZXPZzYmnluexIAnPpzNZLUFG1tkxsclETWL3dHpa q74Cv7YDx5KFaHo/lwWQEF73/Z96aNxahw0DJnympw/gMq9YiiXIAn5Og5g1xV2CAqmr 6mRd6SUDTaMaqiXBXDoONZHi3EYLfWMkVUP++Mo3Pp4lVuDy7bEgxZY9iF2Z3I2EwsSE 6TLKjnNIHos/5Z9VzipmqKwC116Uz51ouiaBRd4ctFWt8ZcustNUGBg/UVSkEZqPNxFY TXHN19nGhhyCr0RZeTf4J8lW4+ezZnzMZv5wwcSSJIClW1pv7L0mtQ9lvr/dbhwivPZd TkbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=7JcTY167EpnrleC2mpr2M2UN+8AlsjHmk6YdFvgjV/U=; b=xmDOTBiwxRw2GVT5LaYBkL4GLqhHukiEvNdVVanhPDSfmf/3V8BDHnlXtNwQZt3GaI OrY6rE1wR0KM1oxIAIfNeYTC0idhf8A7t+6FFmisGr5fZKubVnQI4cmXu3s5Y2teD8f4 GlhgzKjRzy9gp8gjF4kO86S/dUj4W45X2GL3mFI8u5cgcz/ZTf6Uc30djOSzVQcq3zuo vJvKsk8UkBz9e7frPCY1zVj0uGxCJoXlY1aVcdEFpqeXkVnz8kJ5Z8tJLoOGj6IQYqS5 ip+ba+Ke/ux+h13c+vESN0djliL9Xy6Y2/8ow/r+prNnfzROOinJ/OHFm4TwbMTywyHT nLBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZYkOi4JJ; dkim=neutral (no key) header.i=@linutronix.de; 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=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a056a0000c900b00643a0d26156si18077234pfj.241.2023.05.15.10.56.24; Mon, 15 May 2023 10:56:38 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=ZYkOi4JJ; dkim=neutral (no key) header.i=@linutronix.de; 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=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244425AbjEORfW (ORCPT + 99 others); Mon, 15 May 2023 13:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244462AbjEORfE (ORCPT ); Mon, 15 May 2023 13:35:04 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD2FDD8A; Mon, 15 May 2023 10:33:06 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684171985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7JcTY167EpnrleC2mpr2M2UN+8AlsjHmk6YdFvgjV/U=; b=ZYkOi4JJELeuwIPLt6cfI5OF2YVAzlCX2LhHyRsYIns5b0NvhQFSp0KgccM5TpSFAHGJqD SL5Jt/StgCFgm3+oM5yEK7dUhXqYJ2is11dmSi9snAU18xDheiKbLImCxNuNOeK4RDHSbS 6uAYHRKg99diFHy7JRvVgY7g7aUGuLqkFi01kRBcsHyuPFnchwoVVuZPwfv7z2hLZjgN+B Fdxsj15LYkRBFl0lCKbSuH8JY6z1p963+I+GS+ryNwV13fRzhCFs+TB8XkCQ31Il95ADa1 2VDx7Zf8ZrB3JhQyhYMLip7B7DaDvK03x7o3uHbEyPIShtMJEg2iv8DL5aaV3g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684171985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7JcTY167EpnrleC2mpr2M2UN+8AlsjHmk6YdFvgjV/U=; b=hpbSqhlEB/kdZTiH9IukQH5xSziRb43dM67KuRhssJnM9M90RpbzPBq675pAw3TY0LDRva B8z94xV3CydpJ6Aw== To: Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Jonathan Corbet Cc: Thomas Gleixner , linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 1/2] scripts/tags.sh: Resolve gtags empty index generation Date: Mon, 15 May 2023 19:32:16 +0200 Message-Id: <20230515173217.64864-2-darwi@linutronix.de> In-Reply-To: <20230515173217.64864-1-darwi@linutronix.de> References: <20230509012616.81579-1-darwi@linutronix.de> <20230515173217.64864-1-darwi@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org gtags considers any file outside of its current working directory "outside the source tree" and refuses to index it. For O= kernel builds, or when "make" is invoked from a directory other then the kernel source tree, gtags ignores the entire kernel source and generates an empty index. Force-set gtags current working directory to the kernel source tree. Due to commit 9da0763bdd82 ("kbuild: Use relative path when building in a subdir of the source tree"), if the kernel build is done in a sub-directory of the kernel source tree, the kernel Makefile will set the kernel's $srctree to ".." for shorter compile-time and run-time warnings. Consequently, the list of files to be indexed will be in the "../*" form, rendering all such paths invalid once gtags switches to the kernel source tree as its current working directory. If gtags indexing is requested and the build directory is not the kernel source tree, index all files in absolute-path form. Note, indexing in absolute-path form will not affect the generated index, as paths in gtags indices are always relative to the gtags "root directory" anyway (as evidenced by "gtags --dump"). Signed-off-by: Ahmed S. Darwish Cc: --- scripts/tags.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index ea31640b2671..f6b3c7cd39c7 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -32,6 +32,13 @@ else tree=${srctree}/ fi +# gtags(1) refuses to index any file outside of its current working dir. +# If gtags indexing is requested and the build output directory is not +# the kernel source tree, index all files in absolute-path form. +if [[ "$1" == "gtags" && -n "${tree}" ]]; then + tree=$(realpath "$tree")/ +fi + # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH if [ "${ALLSOURCE_ARCHS}" = "" ]; then ALLSOURCE_ARCHS=${SRCARCH} @@ -131,7 +138,7 @@ docscope() dogtags() { - all_target_sources | gtags -i -f - + all_target_sources | gtags -i -C "${tree:-.}" -f - "$PWD" } # Basic regular expressions with an optional /kind-spec/ for ctags and -- 2.30.2