2
0

meson.build 1.9 KB

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