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