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/c_str.rs', 24 'src/irq.rs', 25 'src/module.rs', 26 'src/offset_of.rs', 27 'src/prelude.rs', 28 'src/qdev.rs', 29 'src/qom.rs', 30 'src/sysbus.rs', 31 'src/vmstate.rs', 32 'src/zeroable.rs', 33 ], 34 {'.' : bindings_rs}, 35 ), 36 override_options: ['rust_std=2021', 'build.rust_std=2021'], 37 rust_abi: 'rust', 38 rust_args: _qemu_api_cfg, 39) 40 41rust.test('rust-qemu-api-tests', _qemu_api_rs, 42 suite: ['unit', 'rust']) 43 44qemu_api = declare_dependency( 45 link_with: _qemu_api_rs, 46 dependencies: qemu_api_macros, 47) 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 55test('rust-qemu-api-integration', 56 executable( 57 'rust-qemu-api-integration', 58 'tests/tests.rs', 59 override_options: ['rust_std=2021', 'build.rust_std=2021'], 60 rust_args: ['--test'], 61 install: false, 62 dependencies: [qemu_api, qemu_api_macros], 63 link_whole: [rust_qemu_api_objs, libqemuutil]), 64 args: [ 65 '--test', '--test-threads', '1', 66 '--format', 'pretty', 67 ], 68 protocol: 'rust', 69 suite: ['unit', 'rust']) 70