From: John Hubbard <jhubbard@nvidia.com>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: "Masahiro Yamada" <masahiroy@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nicolas@fjasle.eu>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Alice Ryhl" <aliceryhl@google.com>,
linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
"John Hubbard" <jhubbard@nvidia.com>
Subject: [PATCH] Makefile: rust-analyzer target: better error handling and comments
Date: Fri, 31 May 2024 17:48:56 -0700 [thread overview]
Message-ID: <20240601004856.206682-1-jhubbard@nvidia.com> (raw)
1) Provide a more self-explanatory error message for the "Rust not
available" case. Without this patch, if Rust is not set up properly
(which happens a lot, seeing as how one must routinely run "rustup
override ..." with each new kernel release), the "make rust-analyzer"
invocation generates a somewhat confusing message:
"No rule to make target 'rust-analyzer"
This is confusing at first, because there is, in fact, a rust-analyzer
build target. It's just not set up to handle errors gracefully.
Instead of inflicting that on the developer, just print that Rust is
not available, with a blank line above and below, so it doesn't get lost
in the noise. Now the error case looks like this:
$ make rust-analyzer
Rust is not available
make[1]: *** [/kernel_work/linux-github/Makefile:1975: rust-analyzer] Error 1
make: *** [Makefile:240: __sub-make] Error 2
2) As long as I'm there, also add some documentation about what
rust-analyzer provides.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
Makefile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index f975b6396328..aca2c96820aa 100644
--- a/Makefile
+++ b/Makefile
@@ -1967,9 +1967,13 @@ quiet_cmd_tags = GEN $@
tags TAGS cscope gtags: FORCE
$(call cmd,tags)
-# IDE support targets
+# Generate rust-project.json, which does for Rust what clangd's
+# compile_commands.json does for C/C++: provides a browsing database for code
+# editors and IDEs.
PHONY += rust-analyzer
rust-analyzer:
+ $(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh 2>/dev/null || \
+ { echo; echo "Rust is not available"; echo; false; }
$(Q)$(MAKE) $(build)=rust $@
# Script to generate missing namespace dependencies
base-commit: b050496579632f86ee1ef7e7501906db579f3457
--
2.45.1
next reply other threads:[~2024-06-01 0:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-01 0:48 John Hubbard [this message]
2024-06-14 9:00 ` [PATCH] Makefile: rust-analyzer target: better error handling and comments Alice Ryhl
2024-06-19 12:25 ` Miguel Ojeda
2024-06-20 6:12 ` John Hubbard
2024-06-20 8:31 ` Miguel Ojeda
2024-06-20 8:45 ` Greg KH
2024-06-20 20:27 ` John Hubbard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240601004856.206682-1-jhubbard@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox