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/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) 42 43rust.test('rust-qemu-api-tests', _qemu_api_rs, 44 suite: ['unit', 'rust']) 45 46qemu_api = declare_dependency( 47 link_with: _qemu_api_rs, 48 dependencies: qemu_api_macros, 49) 50 51# Rust executables do not support objects, so add an intermediate step. 52rust_qemu_api_objs = static_library( 53 'rust_qemu_api_objs', 54 objects: [libqom.extract_all_objects(recursive: false), 55 libhwcore.extract_all_objects(recursive: false)]) 56 57test('rust-qemu-api-integration', 58 executable( 59 'rust-qemu-api-integration', 60 'tests/tests.rs', 61 override_options: ['rust_std=2021', 'build.rust_std=2021'], 62 rust_args: ['--test'], 63 install: false, 64 dependencies: [qemu_api, qemu_api_macros], 65 link_whole: [rust_qemu_api_objs, libqemuutil]), 66 args: [ 67 '--test', '--test-threads', '1', 68 '--format', 'pretty', 69 ], 70 protocol: 'rust', 71 suite: ['unit', 'rust']) 72