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