xref: /openbmc/qemu/rust/qemu-api/meson.build (revision 6e7c96ae)
1_qemu_api_cfg = ['--cfg', 'MESON']
2# _qemu_api_cfg += ['--cfg', 'feature="allocator"']
3if rustc.version().version_compare('>=1.77.0')
4  _qemu_api_cfg += ['--cfg', 'has_offset_of']
5endif
6
7_qemu_api_rs = static_library(
8  'qemu_api',
9  structured_sources(
10    [
11      'src/lib.rs',
12      'src/c_str.rs',
13      'src/definitions.rs',
14      'src/device_class.rs',
15      'src/offset_of.rs',
16      'src/vmstate.rs',
17      'src/zeroable.rs',
18    ],
19    {'.' : bindings_rs},
20  ),
21  override_options: ['rust_std=2021', 'build.rust_std=2021'],
22  rust_abi: 'rust',
23  rust_args: _qemu_api_cfg,
24)
25
26rust.test('rust-qemu-api-tests', _qemu_api_rs,
27          suite: ['unit', 'rust'])
28
29qemu_api = declare_dependency(
30  link_with: _qemu_api_rs,
31  dependencies: qemu_api_macros,
32)
33
34# Rust executables do not support objects, so add an intermediate step.
35rust_qemu_api_objs = static_library(
36    'rust_qemu_api_objs',
37    objects: [libqom.extract_all_objects(recursive: false),
38              libhwcore.extract_all_objects(recursive: false)])
39
40test('rust-qemu-api-integration',
41    executable(
42        'rust-qemu-api-integration',
43        'tests/tests.rs',
44        override_options: ['rust_std=2021', 'build.rust_std=2021'],
45        rust_args: ['--test'],
46        install: false,
47        dependencies: [qemu_api, qemu_api_macros],
48        link_whole: [rust_qemu_api_objs, libqemuutil]),
49    args: [
50        '--test',
51        '--format', 'pretty',
52    ],
53    protocol: 'rust',
54    suite: ['unit', 'rust'])
55