1_qemu_api_cfg = run_command(rustc_args, 2 '--config-headers', config_host_h, files('Cargo.toml'), 3 capture: true, check: true).stdout().strip().split() 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 9 10_qemu_api_rs = static_library( 11 'qemu_api', 12 structured_sources( 13 [ 14 'src/lib.rs', 15 'src/bindings.rs', 16 'src/c_str.rs', 17 'src/definitions.rs', 18 'src/device_class.rs', 19 'src/offset_of.rs', 20 'src/vmstate.rs', 21 'src/zeroable.rs', 22 ], 23 {'.' : bindings_rs}, 24 ), 25 override_options: ['rust_std=2021', 'build.rust_std=2021'], 26 rust_abi: 'rust', 27 rust_args: _qemu_api_cfg, 28) 29 30rust.test('rust-qemu-api-tests', _qemu_api_rs, 31 suite: ['unit', 'rust']) 32 33qemu_api = declare_dependency( 34 link_with: _qemu_api_rs, 35 dependencies: qemu_api_macros, 36) 37 38# Rust executables do not support objects, so add an intermediate step. 39rust_qemu_api_objs = static_library( 40 'rust_qemu_api_objs', 41 objects: [libqom.extract_all_objects(recursive: false), 42 libhwcore.extract_all_objects(recursive: false)]) 43 44test('rust-qemu-api-integration', 45 executable( 46 'rust-qemu-api-integration', 47 'tests/tests.rs', 48 override_options: ['rust_std=2021', 'build.rust_std=2021'], 49 rust_args: ['--test'], 50 install: false, 51 dependencies: [qemu_api, qemu_api_macros], 52 link_whole: [rust_qemu_api_objs, libqemuutil]), 53 args: [ 54 '--test', 55 '--format', 'pretty', 56 ], 57 protocol: 'rust', 58 suite: ['unit', 'rust']) 59