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 <pbonz...@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