1*f3518400SJunjie Mao_qemu_api_cfg = ['--cfg', 'MESON'] 2*f3518400SJunjie Mao# _qemu_api_cfg += ['--cfg', 'feature="allocator"'] 3*f3518400SJunjie Maoif rustc.version().version_compare('>=1.77.0') 4*f3518400SJunjie Mao _qemu_api_cfg += ['--cfg', 'has_offset_of'] 5*f3518400SJunjie Maoendif 6*f3518400SJunjie Mao 75a5110d2SManos Pitsidianakis_qemu_api_rs = static_library( 85a5110d2SManos Pitsidianakis 'qemu_api', 95a5110d2SManos Pitsidianakis structured_sources( 105a5110d2SManos Pitsidianakis [ 115a5110d2SManos Pitsidianakis 'src/lib.rs', 12718e255fSPaolo Bonzini 'src/c_str.rs', 135a5110d2SManos Pitsidianakis 'src/definitions.rs', 145a5110d2SManos Pitsidianakis 'src/device_class.rs', 15*f3518400SJunjie Mao 'src/offset_of.rs', 160a65e412SManos Pitsidianakis 'src/vmstate.rs', 176e50bde1SPaolo Bonzini 'src/zeroable.rs', 185a5110d2SManos Pitsidianakis ], 195a5110d2SManos Pitsidianakis {'.' : bindings_rs}, 205a5110d2SManos Pitsidianakis ), 215a5110d2SManos Pitsidianakis override_options: ['rust_std=2021', 'build.rust_std=2021'], 225a5110d2SManos Pitsidianakis rust_abi: 'rust', 23*f3518400SJunjie Mao rust_args: _qemu_api_cfg, 245a5110d2SManos Pitsidianakis) 255a5110d2SManos Pitsidianakis 26718e255fSPaolo Bonzinirust.test('rust-qemu-api-tests', _qemu_api_rs, 27718e255fSPaolo Bonzini suite: ['unit', 'rust']) 28718e255fSPaolo Bonzini 295a5110d2SManos Pitsidianakisqemu_api = declare_dependency( 305a5110d2SManos Pitsidianakis link_with: _qemu_api_rs, 31cde3c425SPaolo Bonzini dependencies: qemu_api_macros, 325a5110d2SManos Pitsidianakis) 33cde3c425SPaolo Bonzini 34cde3c425SPaolo Bonzini# Rust executables do not support objects, so add an intermediate step. 35cde3c425SPaolo Bonzinirust_qemu_api_objs = static_library( 36cde3c425SPaolo Bonzini 'rust_qemu_api_objs', 37cde3c425SPaolo Bonzini objects: [libqom.extract_all_objects(recursive: false), 38cde3c425SPaolo Bonzini libhwcore.extract_all_objects(recursive: false)]) 39cde3c425SPaolo Bonzini 40cde3c425SPaolo Bonzinitest('rust-qemu-api-integration', 41cde3c425SPaolo Bonzini executable( 42cde3c425SPaolo Bonzini 'rust-qemu-api-integration', 43cde3c425SPaolo Bonzini 'tests/tests.rs', 44cde3c425SPaolo Bonzini override_options: ['rust_std=2021', 'build.rust_std=2021'], 45cde3c425SPaolo Bonzini rust_args: ['--test'], 46cde3c425SPaolo Bonzini install: false, 47cde3c425SPaolo Bonzini dependencies: [qemu_api, qemu_api_macros], 48cde3c425SPaolo Bonzini link_whole: [rust_qemu_api_objs, libqemuutil]), 49cde3c425SPaolo Bonzini args: [ 50cde3c425SPaolo Bonzini '--test', 51cde3c425SPaolo Bonzini '--format', 'pretty', 52cde3c425SPaolo Bonzini ], 53cde3c425SPaolo Bonzini protocol: 'rust', 54cde3c425SPaolo Bonzini suite: ['unit', 'rust']) 55