mbox series

[RFC,0/2] meson: Specify Rust edition by rust_std=20XX

Message ID 20240814090820.1251026-1-junjie.mao@intel.com (mailing list archive)
Headers show
Series meson: Specify Rust edition by rust_std=20XX | expand

Message

Junjie Mao Aug. 14, 2024, 9:08 a.m. UTC
The official way to specify Rust edition in meson is the rust_std build option
[1]. It is used for generating --edition rustc options and filling
rust-project.json which provides project layout information to
rust-analyzer. Specifying Rust edition by rust_args instead causes meson to
generate "edition": "--edition" in rust-project.json, which is invalid.

Replace "--edition" rust_args with overriding of rust_std and build.rust_std to
fix the generated rust-project.json.

The rust_std option is part of the build environment and has two forms: rust_std
for the host machine and build.rust_std for the build machine. Specify both in
meson.build for completeness.

The default_options argument of project() is not used because it does not work
for rust_std in subprojects in meson 1.5.1.

This series is based on Paolo's refinement [2] to Manos's rust-pl011-rfc-v6
[3]. Feel free to squash these changes into that series.

[1] https://github.com/mesonbuild/meson/pull/7934
[2] https://gitlab.com/bonzini/qemu/-/tree/rust-for-manos
[3] https://lore.kernel.org/qemu-devel/rust-pl011-rfc-v6.git.manos.pitsidianakis@linaro.org

Junjie Mao (2):
  meson: subprojects: Specify Rust edition by rust_std=20XX
  rust: Specify Rust edition by rust_std=20XX

 rust/hw/char/pl011/meson.build                                | 4 +---
 rust/meson.build                                              | 4 +---
 rust/qemu-api/meson.build                                     | 2 +-
 subprojects/packagefiles/arbitrary-int-1-rs/meson.build       | 4 +---
 subprojects/packagefiles/bilge-impl-0.2-rs/meson.build        | 2 +-
 subprojects/packagefiles/either-1-rs/meson.build              | 2 +-
 subprojects/packagefiles/itertools-0.11-rs/meson.build        | 2 +-
 subprojects/packagefiles/proc-macro-error-1-rs/meson.build    | 2 +-
 .../packagefiles/proc-macro-error-attr-1-rs/meson.build       | 2 +-
 subprojects/packagefiles/proc-macro2-1-rs/meson.build         | 2 +-
 subprojects/packagefiles/quote-1-rs/meson.build               | 2 +-
 subprojects/packagefiles/syn-2-rs/meson.build                 | 2 +-
 subprojects/packagefiles/unicode-ident-1-rs/meson.build       | 4 +---
 13 files changed, 13 insertions(+), 21 deletions(-)

--
2.30.2

Comments

Manos Pitsidianakis Aug. 14, 2024, 11:19 a.m. UTC | #1
On Wed, 14 Aug 2024 12:08, Junjie Mao <junjie.mao@intel.com> wrote:
>The official way to specify Rust edition in meson is the rust_std build option
>[1]. It is used for generating --edition rustc options and filling
>rust-project.json which provides project layout information to
>rust-analyzer. Specifying Rust edition by rust_args instead causes meson to
>generate "edition": "--edition" in rust-project.json, which is invalid.
>
>Replace "--edition" rust_args with overriding of rust_std and build.rust_std to
>fix the generated rust-project.json.
>
>The rust_std option is part of the build environment and has two forms: rust_std
>for the host machine and build.rust_std for the build machine. Specify both in
>meson.build for completeness.
>
>The default_options argument of project() is not used because it does not work
>for rust_std in subprojects in meson 1.5.1.
>
>This series is based on Paolo's refinement [2] to Manos's rust-pl011-rfc-v6
>[3]. Feel free to squash these changes into that series.
>
>[1] https://github.com/mesonbuild/meson/pull/7934
>[2] https://gitlab.com/bonzini/qemu/-/tree/rust-for-manos
>[3] https://lore.kernel.org/qemu-devel/rust-pl011-rfc-v6.git.manos.pitsidianakis@linaro.org
>
>Junjie Mao (2):
>  meson: subprojects: Specify Rust edition by rust_std=20XX
>  rust: Specify Rust edition by rust_std=20XX
>
> rust/hw/char/pl011/meson.build                                | 4 +---
> rust/meson.build                                              | 4 +---
> rust/qemu-api/meson.build                                     | 2 +-
> subprojects/packagefiles/arbitrary-int-1-rs/meson.build       | 4 +---
> subprojects/packagefiles/bilge-impl-0.2-rs/meson.build        | 2 +-
> subprojects/packagefiles/either-1-rs/meson.build              | 2 +-
> subprojects/packagefiles/itertools-0.11-rs/meson.build        | 2 +-
> subprojects/packagefiles/proc-macro-error-1-rs/meson.build    | 2 +-
> .../packagefiles/proc-macro-error-attr-1-rs/meson.build       | 2 +-
> subprojects/packagefiles/proc-macro2-1-rs/meson.build         | 2 +-
> subprojects/packagefiles/quote-1-rs/meson.build               | 2 +-
> subprojects/packagefiles/syn-2-rs/meson.build                 | 2 +-
> subprojects/packagefiles/unicode-ident-1-rs/meson.build       | 4 +---
> 13 files changed, 13 insertions(+), 21 deletions(-)
>
>--
>2.30.2

Thank you Junjie, I have applied the changes to the next version I will 
be posting. Cheers!

Manos