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