xref: /qemu/rust/qemu-api/meson.build (revision b652d512855997ec89c78aa540aceadd5af13724)
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],
39)
40
41rust.test('rust-qemu-api-tests', _qemu_api_rs,
42          suite: ['unit', 'rust'])
43
44qemu_api = declare_dependency(link_with: _qemu_api_rs)
45
46# Rust executables do not support objects, so add an intermediate step.
47rust_qemu_api_objs = static_library(
48    'rust_qemu_api_objs',
49    objects: [libqom.extract_all_objects(recursive: false),
50              libhwcore.extract_all_objects(recursive: false),
51              libchardev.extract_all_objects(recursive: false),
52              libcrypto.extract_all_objects(recursive: false),
53              libauthz.extract_all_objects(recursive: false),
54              libio.extract_all_objects(recursive: false),
55              libmigration.extract_all_objects(recursive: false)])
56rust_qemu_api_deps = declare_dependency(
57    dependencies: [
58      qom_ss.dependencies(),
59      chardev_ss.dependencies(),
60      crypto_ss.dependencies(),
61      authz_ss.dependencies(),
62      io_ss.dependencies()],
63    link_whole: [rust_qemu_api_objs, libqemuutil])
64
65test('rust-qemu-api-integration',
66    executable(
67        'rust-qemu-api-integration',
68        files('tests/tests.rs', 'tests/vmstate_tests.rs'),
69        override_options: ['rust_std=2021', 'build.rust_std=2021'],
70        rust_args: ['--test'],
71        install: false,
72        dependencies: [qemu_api, qemu_api_macros, rust_qemu_api_deps]),
73    args: [
74        '--test', '--test-threads', '1',
75        '--format', 'pretty',
76    ],
77    protocol: 'rust',
78    suite: ['unit', 'rust'])
79