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