Skip to content

Commit

Permalink
add test for generating static inline wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
karolherbst committed Oct 25, 2023
1 parent a019331 commit 5e4d96c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test cases/rust/12 bindgen/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
12 changes: 12 additions & 0 deletions test cases/rust/12 bindgen/src/header3.h
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 14 additions & 0 deletions test cases/rust/12 bindgen/src/main3.rs
Original file line number Diff line number Diff line change
@@ -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)));
};
}

0 comments on commit 5e4d96c

Please sign in to comment.