This is a standard replacement for Box<dyn Error> which is more efficient (it only occcupies one word) and provides a backtrace of the error. This could be plumbed into &error_abort in the future.
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- rust/meson.build | 2 ++ subprojects/.gitignore | 1 + subprojects/anyhow-1.0-rs.wrap | 7 ++++ .../packagefiles/anyhow-1.0-rs/meson.build | 33 +++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 subprojects/anyhow-1.0-rs.wrap create mode 100644 subprojects/packagefiles/anyhow-1.0-rs/meson.build diff --git a/rust/meson.build b/rust/meson.build index 1f0dcce7d04..3e0b6ed4afa 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -1,7 +1,9 @@ +subproject('anyhow-1.0-rs', required: true) subproject('bilge-0.2-rs', required: true) subproject('bilge-impl-0.2-rs', required: true) subproject('libc-0.2-rs', required: true) +anyhow_rs = dependency('anyhow-1.0-rs') bilge_rs = dependency('bilge-0.2-rs') bilge_impl_rs = dependency('bilge-impl-0.2-rs') libc_rs = dependency('libc-0.2-rs') diff --git a/subprojects/.gitignore b/subprojects/.gitignore index d12d34618cc..b9ae507b85a 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -6,6 +6,7 @@ /keycodemapdb /libvfio-user /slirp +/anyhow-1.0.98 /arbitrary-int-1.2.7 /bilge-0.2.0 /bilge-impl-0.2.0 diff --git a/subprojects/anyhow-1.0-rs.wrap b/subprojects/anyhow-1.0-rs.wrap new file mode 100644 index 00000000000..53f20b2a315 --- /dev/null +++ b/subprojects/anyhow-1.0-rs.wrap @@ -0,0 +1,7 @@ +[wrap-file] +directory = anyhow-1.0.98 +source_url = https://crates.io/api/v1/crates/anyhow/1.0.98/download +source_filename = anyhow-1.0.98.tar.gz +source_hash = e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487 +#method = cargo +patch_directory = anyhow-1.0-rs diff --git a/subprojects/packagefiles/anyhow-1.0-rs/meson.build b/subprojects/packagefiles/anyhow-1.0-rs/meson.build new file mode 100644 index 00000000000..67278c25af9 --- /dev/null +++ b/subprojects/packagefiles/anyhow-1.0-rs/meson.build @@ -0,0 +1,33 @@ +project('anyhow-1.0-rs', 'rust', + meson_version: '>=1.5.0', + version: '1.0.98', + license: 'MIT OR Apache-2.0', + default_options: []) + +rustc = meson.get_compiler('rust') + +rust_args = ['--cap-lints', 'allow'] +rust_args += ['--cfg', 'feature="std"'] +if rustc.version().version_compare('<1.65.0') + error('rustc version ' + rustc.version() + ' is unsupported. Please upgrade to at least 1.65.0') +endif +rust_args += [ '--cfg', 'std_backtrace' ] # >= 1.65.0 +if rustc.version().version_compare('<1.81.0') + rust_args += [ '--cfg', 'anyhow_no_core_error' ] +endif + +_anyhow_rs = static_library( + 'anyhow', + files('src/lib.rs'), + gnu_symbol_visibility: 'hidden', + override_options: ['rust_std=2018', 'build.rust_std=2018'], + rust_abi: 'rust', + rust_args: rust_args, + dependencies: [], +) + +anyhow_dep = declare_dependency( + link_with: _anyhow_rs, +) + +meson.override_dependency('anyhow-1.0-rs', anyhow_dep) -- 2.49.0