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