From patchwork Mon May 15 17:32:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ahmed S. Darwish" X-Patchwork-Id: 94258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp7095495vqo; Mon, 15 May 2023 10:59:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GM+W+3JUrAD9b4+G8Z+YqqU0PRxO62akCC3EbOpZNg5ZyrJWftSQfGhOwH433ojlUjIj7 X-Received: by 2002:a05:6a00:2442:b0:63b:854c:e0f6 with SMTP id d2-20020a056a00244200b0063b854ce0f6mr48116743pfj.21.1684173561433; Mon, 15 May 2023 10:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684173561; cv=none; d=google.com; s=arc-20160816; b=BjtfUeuxwEadJUzapBnF5XghmP9qxM/iPXtp6o8FT9+XXs9dPURRjfbu4Rrjjjz/20 9MeFRAi6Y34q81+vcsHaKIyfF9OgDJNK3BDRY4cfKX5swNktf0pjXnuurpKRhtlmqOIu d/nVcLyKEXEWkztAktamod5jrbR6prGxyAuBUzayI7OWdbX4VkV6yH3DLe/kaXDlwunn xIY0R6ZQ0cKR/VfoVKMMPElCebtbJeVkJ58OxTPK7R3wRfI+y9EuWQ0AT/hjQcjAfEQY L+EEUys48AJUnvMVW5nOAZzxdy74YZWgUUagGJEXBVpgkWNmwsBIOnjucMc1/a8TQ1oC 58Jw== 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 header.b=hpbSqhlE; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a056a00001000b0064693201e15si17639047pfk.344.2023.05.15.10.59.07; Mon, 15 May 2023 10:59:21 -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 header.b=hpbSqhlE; 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 S244154AbjEORfW (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765378300728517582?= X-GMAIL-MSGID: =?utf-8?q?1765983976512785637?= 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