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/errno.rs', 24 'src/irq.rs', 25 'src/memory.rs', 26 'src/module.rs', 27 'src/prelude.rs', 28 'src/qdev.rs', 29 'src/qom.rs', 30 'src/sysbus.rs', 31 'src/timer.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: [libc_dep, qemu_api_macros], 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 48# Rust executables do not support objects, so add an intermediate step. 49rust_qemu_api_objs = static_library( 50 'rust_qemu_api_objs', 51 objects: [libqom.extract_all_objects(recursive: false), 52 libhwcore.extract_all_objects(recursive: false), 53 libchardev.extract_all_objects(recursive: false), 54 libcrypto.extract_all_objects(recursive: false), 55 libauthz.extract_all_objects(recursive: false), 56 libio.extract_all_objects(recursive: false), 57 libmigration.extract_all_objects(recursive: false)]) 58rust_qemu_api_deps = declare_dependency( 59 dependencies: [ 60 qom_ss.dependencies(), 61 chardev_ss.dependencies(), 62 crypto_ss.dependencies(), 63 authz_ss.dependencies(), 64 io_ss.dependencies()], 65 link_whole: [rust_qemu_api_objs, libqemuutil]) 66 67test('rust-qemu-api-integration', 68 executable( 69 'rust-qemu-api-integration', 70 files('tests/tests.rs', 'tests/vmstate_tests.rs'), 71 override_options: ['rust_std=2021', 'build.rust_std=2021'], 72 rust_args: ['--test'], 73 install: false, 74 dependencies: [qemu_api, qemu_api_macros, rust_qemu_api_deps]), 75 args: [ 76 '--test', '--test-threads', '1', 77 '--format', 'pretty', 78 ], 79 protocol: 'rust', 80 suite: ['unit', 'rust']) 81