meson.build 2.6 KB

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