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