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