xref: /qemu/rust/qemu-api/meson.build (revision 345bef46a1b6765185bfe1450cc147f5feb5d0e7)
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/uninit.rs',
32      'src/vmstate.rs',
33      'src/zeroable.rs',
34    ],
35    {'.' : bindings_rs},
36  ),
37  override_options: ['rust_std=2021', 'build.rust_std=2021'],
38  rust_abi: 'rust',
39  rust_args: _qemu_api_cfg,
40  dependencies: [anyhow_rs, foreign_rs, libc_rs, qemu_api_macros, qemuutil_rs,
41                 qom, hwcore, chardev, migration],
42)
43
44rust.test('rust-qemu-api-tests', _qemu_api_rs,
45          suite: ['unit', 'rust'])
46
47qemu_api = declare_dependency(link_with: [_qemu_api_rs],
48  dependencies: [qemu_api_macros, qom, hwcore, chardev, migration])
49
50# Doctests are essentially integration tests, so they need the same dependencies.
51# Note that running them requires the object files for C code, so place them
52# in a separate suite that is run by the "build" CI jobs rather than "check".
53rust.doctest('rust-qemu-api-doctests',
54     _qemu_api_rs,
55     protocol: 'rust',
56     dependencies: qemu_api,
57     suite: ['doc', 'rust'])
58
59test('rust-qemu-api-integration',
60    executable(
61        'rust-qemu-api-integration',
62        files('tests/tests.rs', 'tests/vmstate_tests.rs'),
63        override_options: ['rust_std=2021', 'build.rust_std=2021'],
64        rust_args: ['--test'],
65        install: false,
66        dependencies: [qemu_api]),
67    args: [
68        '--test', '--test-threads', '1',
69        '--format', 'pretty',
70    ],
71    protocol: 'rust',
72    suite: ['unit', 'rust'])
73