add test for generating static inline wrappers

pull/12181/head
Karol Herbst 1 year ago committed by Dylan Baker
parent d44185026d
commit 8137eb437a
  1. 28
      test cases/rust/12 bindgen/meson.build
  2. 12
      test cases/rust/12 bindgen/src/header3.h
  3. 14
      test cases/rust/12 bindgen/src/main3.rs

@ -99,6 +99,34 @@ rust_bin2 = executable(
test('generated header', rust_bin2)
if prog_bindgen.version().version_compare('>= 0.65')
# 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)
endif
subdir('sub')
subdir('dependencies')

@ -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;
}

@ -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)));
};
}
Loading…
Cancel
Save