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