1_qemu_api_cfg = [] 2# _qemu_api_cfg += ['--cfg', 'feature="allocator"'] 3if rustc.version().version_compare('>=1.77.0') 4 _qemu_api_cfg += ['--cfg', 'has_offset_of'] 5endif 6 7_qemu_api_rs = static_library( 8 'qemu_api', 9 structured_sources( 10 [ 11 'src/lib.rs', 12 'src/bindings.rs', 13 'src/c_str.rs', 14 'src/definitions.rs', 15 'src/device_class.rs', 16 'src/offset_of.rs', 17 'src/vmstate.rs', 18 'src/zeroable.rs', 19 ], 20 {'.' : bindings_rs}, 21 ), 22 override_options: ['rust_std=2021', 'build.rust_std=2021'], 23 rust_abi: 'rust', 24 rust_args: _qemu_api_cfg, 25) 26 27rust.test('rust-qemu-api-tests', _qemu_api_rs, 28 suite: ['unit', 'rust']) 29 30qemu_api = declare_dependency( 31 link_with: _qemu_api_rs, 32 dependencies: qemu_api_macros, 33) 34 35# Rust executables do not support objects, so add an intermediate step. 36rust_qemu_api_objs = static_library( 37 'rust_qemu_api_objs', 38 objects: [libqom.extract_all_objects(recursive: false), 39 libhwcore.extract_all_objects(recursive: false)]) 40 41test('rust-qemu-api-integration', 42 executable( 43 'rust-qemu-api-integration', 44 'tests/tests.rs', 45 override_options: ['rust_std=2021', 'build.rust_std=2021'], 46 rust_args: ['--test'], 47 install: false, 48 dependencies: [qemu_api, qemu_api_macros], 49 link_whole: [rust_qemu_api_objs, libqemuutil]), 50 args: [ 51 '--test', 52 '--format', 'pretty', 53 ], 54 protocol: 'rust', 55 suite: ['unit', 'rust']) 56