xref: /openbmc/qemu/qapi/meson.build (revision 86e372ad)
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  'virtio',
56  'yank',
57]
58if have_system
59  qapi_all_modules += [
60    'acpi',
61    'audio',
62    'cryptodev',
63    'qdev',
64    'pci',
65    'rdma',
66    'rocker',
67    'tpm',
68  ]
69endif
70if have_system or have_tools
71  qapi_all_modules += [
72    'ui',
73  ]
74endif
75
76qapi_nonmodule_outputs = [
77  'qapi-introspect.c', 'qapi-introspect.h',
78  'qapi-types.c', 'qapi-types.h',
79  'qapi-visit.h', 'qapi-visit.c',
80  'qapi-commands.h', 'qapi-commands.c',
81  'qapi-init-commands.h', 'qapi-init-commands.c',
82  'qapi-events.h', 'qapi-events.c',
83  'qapi-emit-events.c', 'qapi-emit-events.h',
84]
85
86# First build all sources
87qapi_util_outputs = [
88  'qapi-builtin-types.c', 'qapi-builtin-visit.c',
89  'qapi-builtin-types.h', 'qapi-builtin-visit.h',
90]
91
92qapi_inputs = []
93qapi_specific_outputs = []
94foreach module : qapi_all_modules
95  qapi_inputs += [ files(module + '.json') ]
96  qapi_module_outputs = [
97    'qapi-types-@0@.c'.format(module),
98    'qapi-types-@0@.h'.format(module),
99    'qapi-visit-@0@.c'.format(module),
100    'qapi-visit-@0@.h'.format(module),
101  ]
102  if have_system or have_tools
103    qapi_module_outputs += [
104      'qapi-events-@0@.c'.format(module),
105      'qapi-events-@0@.h'.format(module),
106      'qapi-commands-@0@.c'.format(module),
107      'qapi-commands-@0@.h'.format(module),
108      'qapi-commands-@0@.trace-events'.format(module),
109    ]
110  endif
111  if module.endswith('-target')
112    qapi_specific_outputs += qapi_module_outputs
113  else
114    qapi_util_outputs += qapi_module_outputs
115  endif
116endforeach
117
118qapi_files = custom_target('shared QAPI source files',
119  output: qapi_util_outputs + qapi_specific_outputs + qapi_nonmodule_outputs,
120  input: [ files('qapi-schema.json') ],
121  command: [ qapi_gen, '-o', 'qapi', '-b', '@INPUT0@' ],
122  depend_files: [ qapi_inputs, qapi_gen_depends ])
123
124# Now go through all the outputs and add them to the right sourceset.
125# These loops must be synchronized with the output of the above custom target.
126
127i = 0
128foreach output : qapi_util_outputs
129  if output.endswith('.h')
130    genh += qapi_files[i]
131  endif
132  if output.endswith('.trace-events')
133    qapi_trace_events += qapi_files[i]
134  endif
135  util_ss.add(qapi_files[i])
136  i = i + 1
137endforeach
138
139foreach output : qapi_specific_outputs + qapi_nonmodule_outputs
140  if output.endswith('.h')
141    genh += qapi_files[i]
142  endif
143  if output.endswith('.trace-events')
144    qapi_trace_events += qapi_files[i]
145  endif
146  specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: qapi_files[i])
147  i = i + 1
148endforeach
149