meson.build 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. util_ss.add(files(
  2. 'opts-visitor.c',
  3. 'qapi-clone-visitor.c',
  4. 'qapi-dealloc-visitor.c',
  5. 'qapi-forward-visitor.c',
  6. 'qapi-util.c',
  7. 'qapi-visit-core.c',
  8. 'qobject-input-visitor.c',
  9. 'qobject-output-visitor.c',
  10. 'string-input-visitor.c',
  11. 'string-output-visitor.c',
  12. ))
  13. if have_system
  14. util_ss.add(files('qapi-type-helpers.c'))
  15. endif
  16. if have_system or have_tools or have_ga
  17. util_ss.add(files(
  18. 'qmp-dispatch.c',
  19. 'qmp-event.c',
  20. 'qmp-registry.c',
  21. ))
  22. endif
  23. qapi_all_modules = [
  24. 'authz',
  25. 'block',
  26. 'block-core',
  27. 'block-export',
  28. 'char',
  29. 'common',
  30. 'compat',
  31. 'control',
  32. 'crypto',
  33. 'cxl',
  34. 'dump',
  35. 'ebpf',
  36. 'error',
  37. 'introspect',
  38. 'job',
  39. 'machine-common',
  40. 'machine',
  41. 'machine-target',
  42. 'migration',
  43. 'misc',
  44. 'misc-target',
  45. 'net',
  46. 'pragma',
  47. 'qom',
  48. 'replay',
  49. 'run-state',
  50. 'sockets',
  51. 'stats',
  52. 'trace',
  53. 'transaction',
  54. 'vfio',
  55. 'virtio',
  56. 'yank',
  57. ]
  58. if have_system
  59. qapi_all_modules += [
  60. 'acpi',
  61. 'audio',
  62. 'cryptodev',
  63. 'qdev',
  64. 'pci',
  65. 'rocker',
  66. 'tpm',
  67. 'uefi',
  68. ]
  69. endif
  70. if have_system or have_tools
  71. qapi_all_modules += [
  72. 'ui',
  73. ]
  74. endif
  75. qapi_nonmodule_outputs = [
  76. 'qapi-introspect.c', 'qapi-introspect.h',
  77. 'qapi-types.c', 'qapi-types.h',
  78. 'qapi-visit.h', 'qapi-visit.c',
  79. 'qapi-commands.h', 'qapi-commands.c',
  80. 'qapi-init-commands.h', 'qapi-init-commands.c',
  81. 'qapi-events.h', 'qapi-events.c',
  82. 'qapi-emit-events.c', 'qapi-emit-events.h',
  83. ]
  84. # First build all sources
  85. qapi_util_outputs = [
  86. 'qapi-builtin-types.c', 'qapi-builtin-visit.c',
  87. 'qapi-builtin-types.h', 'qapi-builtin-visit.h',
  88. ]
  89. qapi_inputs = []
  90. qapi_specific_outputs = []
  91. foreach module : qapi_all_modules
  92. qapi_inputs += [ files(module + '.json') ]
  93. qapi_module_outputs = [
  94. 'qapi-types-@0@.c'.format(module),
  95. 'qapi-types-@0@.h'.format(module),
  96. 'qapi-visit-@0@.c'.format(module),
  97. 'qapi-visit-@0@.h'.format(module),
  98. ]
  99. if have_system or have_tools
  100. qapi_module_outputs += [
  101. 'qapi-events-@0@.c'.format(module),
  102. 'qapi-events-@0@.h'.format(module),
  103. 'qapi-commands-@0@.c'.format(module),
  104. 'qapi-commands-@0@.h'.format(module),
  105. 'qapi-commands-@0@.trace-events'.format(module),
  106. ]
  107. endif
  108. if module.endswith('-target')
  109. qapi_specific_outputs += qapi_module_outputs
  110. else
  111. qapi_util_outputs += qapi_module_outputs
  112. endif
  113. endforeach
  114. qapi_files = custom_target('shared QAPI source files',
  115. output: qapi_util_outputs + qapi_specific_outputs + qapi_nonmodule_outputs,
  116. input: [ files('qapi-schema.json') ],
  117. command: [ qapi_gen, '-o', 'qapi', '-b', '@INPUT0@' ],
  118. depend_files: [ qapi_inputs, qapi_gen_depends ])
  119. # Now go through all the outputs and add them to the right sourceset.
  120. # These loops must be synchronized with the output of the above custom target.
  121. i = 0
  122. foreach output : qapi_util_outputs
  123. if output.endswith('.h')
  124. genh += qapi_files[i]
  125. endif
  126. if output.endswith('.trace-events')
  127. qapi_trace_events += qapi_files[i]
  128. endif
  129. util_ss.add(qapi_files[i])
  130. i = i + 1
  131. endforeach
  132. foreach output : qapi_specific_outputs + qapi_nonmodule_outputs
  133. if output.endswith('.h')
  134. genh += qapi_files[i]
  135. endif
  136. if output.endswith('.trace-events')
  137. qapi_trace_events += qapi_files[i]
  138. endif
  139. specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: qapi_files[i])
  140. i = i + 1
  141. endforeach