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