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