From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, qemu-rust@nongnu.org,
manos.pitsidianakis@linaro.org
Subject: [RFC PATCH 4/6] rust: subprojects: add bitfield-struct
Date: Wed, 21 May 2025 10:18:43 +0200 [thread overview]
Message-ID: <20250521081845.496442-5-pbonzini@redhat.com> (raw)
In-Reply-To: <20250521081845.496442-1-pbonzini@redhat.com>
The bitfield-struct is much smaller than "bilge" and supports "const"
expressions better. The main disadvantage is that it does not let you
annotate enums as bitfields and does not integrate with arbitrary-int,
thus requiring manual size annotations for anything that is not a bool,
iNN or uNN.
Lack of support for arbitrary-int is a very minor change; enums are a
bit more annoying because they require manual implementation of two
functions from_bits() and into_bits(); however, that is already handled
by QEMU's bits! and #[derive(qemu_api_macros::TryInto)] utilities.
Together, these basically make the manual work go away.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
rust/meson.build | 3 ++
subprojects/.gitignore | 1 +
subprojects/bitfield-struct-0.9-rs.wrap | 7 ++++
.../bitfield-struct-0.9-rs/meson.build | 36 +++++++++++++++++++
4 files changed, 47 insertions(+)
create mode 100644 subprojects/bitfield-struct-0.9-rs.wrap
create mode 100644 subprojects/packagefiles/bitfield-struct-0.9-rs/meson.build
diff --git a/rust/meson.build b/rust/meson.build
index f370b0ec939..58f14a70d6d 100644
--- a/rust/meson.build
+++ b/rust/meson.build
@@ -1,3 +1,6 @@
+subproject('bitfield-struct-0.9-rs', required: true)
+bitfield_struct_dep = dependency('bitfield-struct-0.9-rs')
+
subdir('qemu-api-macros')
subdir('bits')
subdir('qemu-api')
diff --git a/subprojects/.gitignore b/subprojects/.gitignore
index d12d34618cc..180c3134864 100644
--- a/subprojects/.gitignore
+++ b/subprojects/.gitignore
@@ -9,6 +9,7 @@
/arbitrary-int-1.2.7
/bilge-0.2.0
/bilge-impl-0.2.0
+/bitfield-struct-0.9.5
/either-1.12.0
/itertools-0.11.0
/libc-0.2.162
diff --git a/subprojects/bitfield-struct-0.9-rs.wrap b/subprojects/bitfield-struct-0.9-rs.wrap
new file mode 100644
index 00000000000..dfdbbc853af
--- /dev/null
+++ b/subprojects/bitfield-struct-0.9-rs.wrap
@@ -0,0 +1,7 @@
+[wrap-file]
+directory = bitfield-struct-0.9.5
+source_url = https://crates.io/api/v1/crates/bitfield-struct/0.9.5/download
+source_filename = bitfield-struct-0.9.5.tar.gz
+source_hash = b2869c63ccf4f8bf0d485070b880e60e097fb7aeea80ee82a0a94a957e372a0b
+#method = cargo
+patch_directory = bitfield-struct-0.9-rs
diff --git a/subprojects/packagefiles/bitfield-struct-0.9-rs/meson.build b/subprojects/packagefiles/bitfield-struct-0.9-rs/meson.build
new file mode 100644
index 00000000000..e8badb7da18
--- /dev/null
+++ b/subprojects/packagefiles/bitfield-struct-0.9-rs/meson.build
@@ -0,0 +1,36 @@
+project('bitfield-struct-0.9-rs', 'rust',
+ meson_version: '>=1.5.0',
+ version: '0.9.5',
+ license: 'MIT',
+ default_options: [])
+
+subproject('quote-1-rs', required: true)
+subproject('syn-2-rs', required: true)
+subproject('proc-macro2-1-rs', required: true)
+
+quote_dep = dependency('quote-1-rs', native: true)
+syn_dep = dependency('syn-2-rs', native: true)
+proc_macro2_dep = dependency('proc-macro2-1-rs', native: true)
+
+rust = import('rust')
+
+_bitfield_struct_rs = rust.proc_macro(
+ 'bitfield_struct',
+ files('src/lib.rs'),
+ override_options: ['rust_std=2021', 'build.rust_std=2021'],
+ rust_args: [
+ '--cap-lints', 'allow',
+ '--cfg', 'use_fallback',
+ ],
+ dependencies: [
+ quote_dep,
+ syn_dep,
+ proc_macro2_dep,
+ ],
+)
+
+bitfield_struct_dep = declare_dependency(
+ link_with: _bitfield_struct_rs,
+)
+
+meson.override_dependency('bitfield-struct-0.9-rs', bitfield_struct_dep)
--
2.49.0
next prev parent reply other threads:[~2025-05-21 8:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 8:18 [RFC PATCH 0/6] rust: make usage of bitmasks and bitfields nicer Paolo Bonzini
2025-05-21 8:18 ` [RFC PATCH 1/6] rust: add "bits", a custom bitflags implementation Paolo Bonzini
2025-05-21 8:29 ` Daniel P. Berrangé
2025-05-21 9:23 ` Manos Pitsidianakis
2025-05-21 15:05 ` Daniel P. Berrangé
2025-05-21 8:18 ` [RFC PATCH 2/6] rust: pl011: use the bits macro Paolo Bonzini
2025-05-21 8:18 ` [RFC PATCH 3/6] rust: qemu-api-macros: add from_bits and into_bits to #[derive(TryInto)] Paolo Bonzini
2025-05-21 8:18 ` Paolo Bonzini [this message]
2025-05-21 8:18 ` [RFC PATCH 5/6] rust: pl011: switch from bilge to bitfield-struct Paolo Bonzini
2025-05-21 9:21 ` Manos Pitsidianakis
2025-05-21 9:40 ` Manos Pitsidianakis
2025-05-21 13:51 ` Paolo Bonzini
2025-05-21 9:50 ` Alex Bennée
2025-05-21 11:12 ` Manos Pitsidianakis
2025-05-21 13:54 ` Paolo Bonzini
2025-05-21 8:18 ` [RFC PATCH 6/6] rust: remove bilge crate Paolo Bonzini
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=20250521081845.496442-5-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).