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