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