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