meson.build 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. 'error',
  36. 'introspect',
  37. 'job',
  38. 'machine',
  39. 'machine-target',
  40. 'migration',
  41. 'misc',
  42. 'misc-target',
  43. 'net',
  44. 'pragma',
  45. 'qom',
  46. 'replay',
  47. 'run-state',
  48. 'sockets',
  49. 'stats',
  50. 'trace',
  51. 'transaction',
  52. 'virtio',
  53. 'yank',
  54. ]
  55. if have_system
  56. qapi_all_modules += [
  57. 'acpi',
  58. 'audio',
  59. 'cryptodev',
  60. 'qdev',
  61. 'pci',
  62. 'rdma',
  63. 'rocker',
  64. 'tpm',
  65. ]
  66. endif
  67. if have_system or have_tools
  68. qapi_all_modules += [
  69. 'ui',
  70. ]
  71. endif
  72. qapi_nonmodule_outputs = [
  73. 'qapi-introspect.c', 'qapi-introspect.h',
  74. 'qapi-types.c', 'qapi-types.h',
  75. 'qapi-visit.h', 'qapi-visit.c',
  76. 'qapi-commands.h', 'qapi-commands.c',
  77. 'qapi-init-commands.h', 'qapi-init-commands.c',
  78. 'qapi-events.h', 'qapi-events.c',
  79. 'qapi-emit-events.c', 'qapi-emit-events.h',
  80. ]
  81. # First build all sources
  82. qapi_util_outputs = [
  83. 'qapi-builtin-types.c', 'qapi-builtin-visit.c',
  84. 'qapi-builtin-types.h', 'qapi-builtin-visit.h',
  85. ]
  86. qapi_inputs = []
  87. qapi_specific_outputs = []
  88. foreach module : qapi_all_modules
  89. qapi_inputs += [ files(module + '.json') ]
  90. qapi_module_outputs = [
  91. 'qapi-types-@0@.c'.format(module),
  92. 'qapi-types-@0@.h'.format(module),
  93. 'qapi-visit-@0@.c'.format(module),
  94. 'qapi-visit-@0@.h'.format(module),
  95. ]
  96. if have_system or have_tools
  97. qapi_module_outputs += [
  98. 'qapi-events-@0@.c'.format(module),
  99. 'qapi-events-@0@.h'.format(module),
  100. 'qapi-commands-@0@.c'.format(module),
  101. 'qapi-commands-@0@.h'.format(module),
  102. 'qapi-commands-@0@.trace-events'.format(module),
  103. ]
  104. endif
  105. if module.endswith('-target')
  106. qapi_specific_outputs += qapi_module_outputs
  107. else
  108. qapi_util_outputs += qapi_module_outputs
  109. endif
  110. endforeach
  111. qapi_files = custom_target('shared QAPI source files',
  112. output: qapi_util_outputs + qapi_specific_outputs + qapi_nonmodule_outputs,
  113. input: [ files('qapi-schema.json') ],
  114. command: [ qapi_gen, '-o', 'qapi', '-b', '@INPUT0@' ],
  115. depend_files: [ qapi_inputs, qapi_gen_depends ])
  116. # Now go through all the outputs and add them to the right sourceset.
  117. # These loops must be synchronized with the output of the above custom target.
  118. i = 0
  119. foreach output : qapi_util_outputs
  120. if output.endswith('.h')
  121. genh += qapi_files[i]
  122. endif
  123. if output.endswith('.trace-events')
  124. qapi_trace_events += qapi_files[i]
  125. endif
  126. util_ss.add(qapi_files[i])
  127. i = i + 1
  128. endforeach
  129. foreach output : qapi_specific_outputs + qapi_nonmodule_outputs
  130. if output.endswith('.h')
  131. genh += qapi_files[i]
  132. endif
  133. if output.endswith('.trace-events')
  134. qapi_trace_events += qapi_files[i]
  135. endif
  136. specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: qapi_files[i])
  137. i = i + 1
  138. endforeach