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