Debian Codegraph @

test cases/rust/44 cbindgen/meson.build

raw
1 # SPDX-License-Identifier: Apache-2.0
2 # Copyright © 2024 Intel Corporation
3
4 project(
5 'cbindgen',
6 'rust', 'c',
7 meson_version : '>= 1.12',
8 default_options : {'cpp_std' : 'c++20'},
9 )
10
11 if not find_program('cbindgen', required : false).found()
12 error('MESON_SKIP_TEST: cbindgen was not found')
13 endif
14
15 rust = import('rust')
16
17 rlib = static_library('rlib', 'lib.rs', rust_abi : 'c')
18
19 bound_h = rust.cbindgen('lib.rs', 'lib.h', config : 'config.toml')
20
21 test(
22 'uses bound rust',
23 executable('ctest', 'test1.c', bound_h, link_with : rlib)
24 )
25
26 srcs = structured_sources(
27 'lib2.rs',
28 {
29 'sub' : 'sub.rs',
30 }
31 )
32
33 rlib2 = static_library('lib2', srcs, rust_abi : 'c')
34
35 bound_h = rust.cbindgen(srcs, 'lib2.h', config : 'config.toml')
36 test(
37 'uses bound rust from structured_sources',
38 executable('ctest2', 'test1.c', bound_h, c_args : '-DUSE_LIB2', link_with : rlib2)
39 )
40
41 # The requirement of C++20 for designated initializers means this may not be
42 # supported everywhere
43 if add_languages('cpp', native : false, required : false)
44 rlib3 = static_library('lib3', 'lib.rs', rust_abi : 'c')
45
46 bound_h = rust.cbindgen('lib.rs', 'lib3.hpp', config : 'config.toml')
47 test(
48 'generates a c++ header',
49 executable('cpptest1', 'test1.cpp', bound_h, link_with : rlib2)
50 )
51 endif