From patchwork Mon Jan 9 20:45:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 41095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2371927wrt; Mon, 9 Jan 2023 12:47:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXv42VRtNKQW2dZj4piXlDsTEXWpf893DF2wQlg/GjcCYwWOg/qBeuLXMLtEikOY82PBtnvD X-Received: by 2002:a17:907:3888:b0:83f:757e:f182 with SMTP id sq8-20020a170907388800b0083f757ef182mr54196892ejc.65.1673297274451; Mon, 09 Jan 2023 12:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673297274; cv=none; d=google.com; s=arc-20160816; b=ruFPC9bNyrbqVvJT37uWvkYlWoCAwqYjij8wYlger/jEYYknSS+GqCrPg2aMp6t2XF 99oK3sQxNy9BUQ30OzH8gWXLBFzuQAwn3WeByzGiYbGzINJYAk9sPoAQQ5Rboki4QbGt NM+m9R8KlQ8CKqINpbBB4u73T3q19FVSSP+yOXgAxb5e3Gs5XUcSuVg6DAgx8/q0EN6u culPX2760dU/zzBJi4C3cypL6Al7Q+e6+NFrcFGSvg3KUSx4+BDnfBvEO5BBUEhrXpNp Kjz966dLGI0Ah32Tp6lJ45ZTjkr7tTVbDgUYmw1usNLzJSgpPLw6deRI88dq3VEXDRvx 5V2g== 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:from :dkim-signature; bh=ZWQ+MnRbIGzuWA7jC9vqyHBj2IYEPHPhMFNM/PxtaFs=; b=EHkFlmCXfROH3jAcNVd18oKa6HDO5F6AnzaeexEndrXQheGqUOasUY+87Rvw6LH2se DtezvPhnqyKTdKZnI2n5mx9j5+n25vwsvxKCoQLKmL7low2VV2Pq805OjoQ6sDkn5lC9 7joQZEoY5E67wZ7Qo08uoFdoqWdHzp+xGbHX5DBMNtNmeUbZHNRV9WvOQw+pho1jipQX uMfBCKcz8wjoqjAGw1VgnfwDNUvuKh2RSZ5iG+tXTWvMFprgQIOxRmQ4ZQCUCBudFZvI SOsTs65CzxMbxVyBYC1C5z2WPCypgytrmX73tDrGB6Ko3H79r/ogIPDGZu6bfOf3T0wZ m4ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pcpNnYrY; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc37-20020a17090716a500b007c10b6790bfsi11550213ejc.68.2023.01.09.12.47.30; Mon, 09 Jan 2023 12:47:54 -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=@kernel.org header.s=k20201202 header.b=pcpNnYrY; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237192AbjAIUqN (ORCPT + 99 others); Mon, 9 Jan 2023 15:46:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235381AbjAIUqC (ORCPT ); Mon, 9 Jan 2023 15:46:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62038687A1; Mon, 9 Jan 2023 12:46:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 27C936136C; Mon, 9 Jan 2023 20:46:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F42AC433D2; Mon, 9 Jan 2023 20:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673297159; bh=+4zz4idSaVuP74R5VBf82uZ0IOSqSMwHAWJZxvct/Dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pcpNnYrYbId9bog3bv+J9Rh4LGvuYAcglUACV1lIg+8GRND1nayRRbowRjfQ3GpzQ +zOkim+iT26EYBITxs3imrZb9XTwcFPMWfOhYf4noT0oLelYtT0ZDTzuO7aEzqh4NQ YSCizcO1OwEGO/0SQ5bJ07Z1WMGAQrQqxj6Sql0C+bth7Lyu0+vQDmoVqiEJv4r00s lBZZvzF6om4TBinuPFGp0y6/q8mYIBTlcm3epoFPeqiEbL7eqv2xwR8LRfXrA9AjDY +sFUM8av4TGSSeEsYIADOdAY8z/sea/YEVg2WT3I+mAbchJFa6Qmu2ldomoBerqdet EUdi1PwK0wmMA== From: Miguel Ojeda To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= Subject: [PATCH 4/6] kbuild: rust_is_available: check if the script was invoked from Kbuild Date: Mon, 9 Jan 2023 21:45:18 +0100 Message-Id: <20230109204520.539080-4-ojeda@kernel.org> In-Reply-To: <20230109204520.539080-1-ojeda@kernel.org> References: <20230109204520.539080-1-ojeda@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754579363005778129?= X-GMAIL-MSGID: =?utf-8?q?1754579363005778129?= Sometimes [1] users may attempt to setup the Rust support by checking what Kbuild does and they end up finding out about `scripts/rust_is_available.sh`. Inevitably, they run the script directly, but unless they setup the required variables, the result of the script is not meaningful. We could add some defaults to the variables, but that could be confusing for those that may override the defaults (compared to their kernel builds), and `$CC` would not be a simple default in any case. Therefore, instead, print a warning when the script detects the user may be invoking it, by testing `$MAKEFLAGS`. Link: https://lore.kernel.org/oe-kbuild-all/Y6r4mXz5NS0+HVXo@zn.tnic/ [1] Signed-off-by: Miguel Ojeda --- scripts/rust_is_available.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/rust_is_available.sh b/scripts/rust_is_available.sh index cd87729ca3bf..0c082a248f15 100755 --- a/scripts/rust_is_available.sh +++ b/scripts/rust_is_available.sh @@ -35,6 +35,16 @@ print_docs_reference() warning=0 trap 'if [ $? -ne 0 ] || [ $warning -ne 0 ]; then print_docs_reference; fi' EXIT +# Check whether the script was invoked from Kbuild. +if [ -z "${MAKEFLAGS+x}" ]; then + echo >&2 "***" + echo >&2 "*** This script is intended to be called from Kbuild." + echo >&2 "*** Please use the 'rustavailable' target to call it instead." + echo >&2 "*** Otherwise, the results may not be meaningful." + echo >&2 "***" + warning=1 +fi + # Check that the Rust compiler exists. if ! command -v "$RUSTC" >/dev/null; then echo >&2 "***"