meson.build 1.9 KB

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