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