diff --git a/test cases/rust/12 bindgen/meson.build b/test cases/rust/12 bindgen/meson.build index e36e9e2d1a7b..7fc4c50e816a 100644 --- a/test cases/rust/12 bindgen/meson.build +++ b/test cases/rust/12 bindgen/meson.build @@ -90,6 +90,32 @@ rust_bin2 = executable( test('generated header', rust_bin2) +# Test generating a static inline wrapper +gen3 = rust.bindgen( + input : 'src/header3.h', + output : 'header3.rs', + output_inline_wrapper : 'header3.c', + include_directories : 'include', +) +c_inline_wrapper = static_library('c_wrapper', gen3[1]) + +f = configure_file( + input : 'src/main3.rs', + output : 'main3.rs', + copy : true, +) + +rust_bin3 = executable( + 'rust_bin3', + [f, gen3[0]], + link_with : [ + c_lib, + c_inline_wrapper, + ], +) + +test('static inline wrapper', rust_bin3) + subdir('sub') subdir('dependencies') diff --git a/test cases/rust/12 bindgen/src/header3.h b/test cases/rust/12 bindgen/src/header3.h new file mode 100644 index 000000000000..958a79fd0f4d --- /dev/null +++ b/test cases/rust/12 bindgen/src/header3.h @@ -0,0 +1,12 @@ +// SPDX-license-identifer: Apache-2.0 +// Copyright © 2023 Red Hat, Inc + +#pragma once + +#include "other.h" + +int32_t add(const int32_t, const int32_t); + +static inline int32_t sub(const int32_t a, const int32_t b) { + return a - b; +} diff --git a/test cases/rust/12 bindgen/src/main3.rs b/test cases/rust/12 bindgen/src/main3.rs new file mode 100644 index 000000000000..fa9d30b7ccb5 --- /dev/null +++ b/test cases/rust/12 bindgen/src/main3.rs @@ -0,0 +1,14 @@ +// SPDX-license-identifer: Apache-2.0 +// Copyright © 2023 Red Hat, Inc + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +include!("header3.rs"); + +fn main() { + unsafe { + std::process::exit(add(0, sub(0, 0))); + }; +}