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 5libc_dep = dependency('libc-0.2-rs') 6 7# _qemu_api_cfg += ['--cfg', 'feature="allocator"'] 8if get_option('debug_mutex') 9 _qemu_api_cfg += ['--cfg', 'feature="debug_cell"'] 10endif 11 12_qemu_api_rs = static_library( 13 'qemu_api', 14 structured_sources( 15 [ 16 'src/lib.rs', 17 'src/assertions.rs', 18 'src/bindings.rs', 19 'src/bitops.rs', 20 'src/callbacks.rs', 21 'src/cell.rs', 22 'src/chardev.rs', 23 'src/c_str.rs', 24 'src/errno.rs', 25 'src/irq.rs', 26 'src/memory.rs', 27 'src/module.rs', 28 'src/prelude.rs', 29 'src/qdev.rs', 30 'src/qom.rs', 31 'src/sysbus.rs', 32 'src/timer.rs', 33 'src/vmstate.rs', 34 'src/zeroable.rs', 35 ], 36 {'.' : bindings_rs}, 37 ), 38 override_options: ['rust_std=2021', 'build.rust_std=2021'], 39 rust_abi: 'rust', 40 rust_args: _qemu_api_cfg, 41 dependencies: [libc_dep, qemu_api_macros], 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 49# Rust executables do not support objects, so add an intermediate step. 50rust_qemu_api_objs = static_library( 51 'rust_qemu_api_objs', 52 objects: [libqom.extract_all_objects(recursive: false), 53 libhwcore.extract_all_objects(recursive: false), 54 libchardev.extract_all_objects(recursive: false), 55 libcrypto.extract_all_objects(recursive: false), 56 libauthz.extract_all_objects(recursive: false), 57 libio.extract_all_objects(recursive: false), 58 libmigration.extract_all_objects(recursive: false)]) 59rust_qemu_api_deps = declare_dependency( 60 dependencies: [ 61 qom_ss.dependencies(), 62 chardev_ss.dependencies(), 63 crypto_ss.dependencies(), 64 authz_ss.dependencies(), 65 io_ss.dependencies()], 66 link_whole: [rust_qemu_api_objs, libqemuutil]) 67 68test('rust-qemu-api-integration', 69 executable( 70 'rust-qemu-api-integration', 71 files('tests/tests.rs', 'tests/vmstate_tests.rs'), 72 override_options: ['rust_std=2021', 'build.rust_std=2021'], 73 rust_args: ['--test'], 74 install: false, 75 dependencies: [qemu_api, qemu_api_macros, rust_qemu_api_deps]), 76 args: [ 77 '--test', '--test-threads', '1', 78 '--format', 'pretty', 79 ], 80 protocol: 'rust', 81 suite: ['unit', 'rust']) 82