xref: /qemu/rust/qemu-api/meson.build (revision 96215036f47403438c7c7869b7cd419bd7a11f82)
1_qemu_api_cfg = run_command(rustc_args,
2  '--config-headers', config_host_h, '--features', files('Cargo.toml'),
3  capture: true, check: true).stdout().strip().splitlines()
4
5# _qemu_api_cfg += ['--cfg', 'feature="allocator"']
6if get_option('debug_mutex')
7  _qemu_api_cfg += ['--cfg', 'feature="debug_cell"']
8endif
9
10_qemu_api_rs = static_library(
11  'qemu_api',
12  structured_sources(
13    [
14      'src/lib.rs',
15      'src/assertions.rs',
16      'src/bindings.rs',
17      'src/bitops.rs',
18      'src/callbacks.rs',
19      'src/cell.rs',
20      'src/chardev.rs',
21      'src/errno.rs',
22      'src/error.rs',
23      'src/irq.rs',
24      'src/memory.rs',
25      'src/module.rs',
26      'src/prelude.rs',
27      'src/qdev.rs',
28      'src/qom.rs',
29      'src/sysbus.rs',
30      'src/timer.rs',
31      'src/vmstate.rs',
32      'src/zeroable.rs',
33    ],
34    {'.' : bindings_rs},
35  ),
36  override_options: ['rust_std=2021', 'build.rust_std=2021'],
37  rust_abi: 'rust',
38  rust_args: _qemu_api_cfg,
39  dependencies: [anyhow_rs, foreign_rs, libc_rs, qemu_api_macros, qemuutil_rs,
40                 qom, hwcore, chardev, migration],
41)
42
43rust.test('rust-qemu-api-tests', _qemu_api_rs,
44          suite: ['unit', 'rust'])
45
46qemu_api = declare_dependency(link_with: [_qemu_api_rs],
47  dependencies: [qemu_api_macros, qom, hwcore, chardev, migration])
48
49# Doctests are essentially integration tests, so they need the same dependencies.
50# Note that running them requires the object files for C code, so place them
51# in a separate suite that is run by the "build" CI jobs rather than "check".
52rust.doctest('rust-qemu-api-doctests',
53     _qemu_api_rs,
54     protocol: 'rust',
55     dependencies: qemu_api,
56     suite: ['doc', 'rust'])
57
58test('rust-qemu-api-integration',
59    executable(
60        'rust-qemu-api-integration',
61        files('tests/tests.rs', 'tests/vmstate_tests.rs'),
62        override_options: ['rust_std=2021', 'build.rust_std=2021'],
63        rust_args: ['--test'],
64        install: false,
65        dependencies: [qemu_api]),
66    args: [
67        '--test', '--test-threads', '1',
68        '--format', 'pretty',
69    ],
70    protocol: 'rust',
71    suite: ['unit', 'rust'])
72