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