xref: /openbmc/qemu/qapi/meson.build (revision 64c9a921)
1util_ss.add(files(
2  'opts-visitor.c',
3  'qapi-clone-visitor.c',
4  'qapi-dealloc-visitor.c',
5  'qapi-util.c',
6  'qapi-visit-core.c',
7  'qmp-dispatch.c',
8  'qmp-event.c',
9  'qmp-registry.c',
10  'qobject-input-visitor.c',
11  'qobject-output-visitor.c',
12  'string-input-visitor.c',
13  'string-output-visitor.c',
14))
15
16qapi_all_modules = [
17  'acpi',
18  'audio',
19  'authz',
20  'block',
21  'block-core',
22  'block-export',
23  'char',
24  'common',
25  'control',
26  'crypto',
27  'dump',
28  'error',
29  'introspect',
30  'job',
31  'machine',
32  'machine-target',
33  'migration',
34  'misc',
35  'misc-target',
36  'net',
37  'pragma',
38  'qdev',
39  'pci',
40  'qom',
41  'rdma',
42  'replay',
43  'rocker',
44  'run-state',
45  'sockets',
46  'tpm',
47  'trace',
48  'transaction',
49  'ui',
50  'yank',
51]
52
53qapi_storage_daemon_modules = [
54  'block-core',
55  'block-export',
56  'char',
57  'common',
58  'control',
59  'crypto',
60  'introspect',
61  'job',
62  'qom',
63  'sockets',
64  'pragma',
65  'transaction',
66]
67
68qapi_nonmodule_outputs = [
69  'qapi-introspect.c', 'qapi-introspect.h',
70  'qapi-types.c', 'qapi-types.h',
71  'qapi-visit.h', 'qapi-visit.c',
72  'qapi-commands.h', 'qapi-commands.c',
73  'qapi-init-commands.h', 'qapi-init-commands.c',
74  'qapi-events.h', 'qapi-events.c',
75  'qapi-emit-events.c', 'qapi-emit-events.h',
76]
77
78# First build all sources
79qapi_util_outputs = [
80  'qapi-builtin-types.c', 'qapi-builtin-visit.c',
81  'qapi-builtin-types.h', 'qapi-builtin-visit.h',
82]
83
84qapi_inputs = []
85qapi_specific_outputs = []
86foreach module : qapi_all_modules
87  qapi_inputs += [ files(module + '.json') ]
88  qapi_module_outputs = [
89    'qapi-types-@0@.c'.format(module),
90    'qapi-types-@0@.h'.format(module),
91    'qapi-visit-@0@.c'.format(module),
92    'qapi-visit-@0@.h'.format(module),
93    'qapi-events-@0@.c'.format(module),
94    'qapi-events-@0@.h'.format(module),
95    'qapi-commands-@0@.c'.format(module),
96    'qapi-commands-@0@.h'.format(module),
97  ]
98  if module.endswith('-target')
99    qapi_specific_outputs += qapi_module_outputs
100  else
101    qapi_util_outputs += qapi_module_outputs
102  endif
103endforeach
104
105qapi_files = custom_target('shared QAPI source files',
106  output: qapi_util_outputs + qapi_specific_outputs + qapi_nonmodule_outputs,
107  input: [ files('qapi-schema.json') ],
108  command: [ qapi_gen, '-o', 'qapi', '-b', '@INPUT0@' ],
109  depend_files: [ qapi_inputs, qapi_gen_depends ])
110
111# Now go through all the outputs and add them to the right sourceset.
112# These loops must be synchronized with the output of the above custom target.
113
114i = 0
115foreach output : qapi_util_outputs
116  if output.endswith('.h')
117    genh += qapi_files[i]
118  endif
119  util_ss.add(qapi_files[i])
120  i = i + 1
121endforeach
122
123foreach output : qapi_specific_outputs + qapi_nonmodule_outputs
124  if output.endswith('.h')
125    genh += qapi_files[i]
126  endif
127  specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: qapi_files[i])
128  i = i + 1
129endforeach
130