OSDN Git Service

meson: document why we don't generate trace events for tests/ and qga/
[qmiga/qemu.git] / qga / meson.build
1 qga_qapi_outputs = [
2   'qga-qapi-commands.c',
3   'qga-qapi-commands.h',
4   'qga-qapi-emit-events.c',
5   'qga-qapi-emit-events.h',
6   'qga-qapi-events.c',
7   'qga-qapi-events.h',
8   'qga-qapi-init-commands.c',
9   'qga-qapi-init-commands.h',
10   'qga-qapi-introspect.c',
11   'qga-qapi-introspect.h',
12   'qga-qapi-types.c',
13   'qga-qapi-types.h',
14   'qga-qapi-visit.c',
15   'qga-qapi-visit.h',
16 ]
17
18 # Problem: to generate trace events, we'd have to add the .trace-events
19 # file to qapi_trace_events like we do in qapi/meson.build.  Since
20 # qapi_trace_events is used by trace/meson.build, we'd have to move
21 # subdir('qga') above subdir('trace') in the top-level meson.build.
22 # Can't, because it would break the dependency of qga on qemuutil (which
23 # depends on trace_ss).  Not worth solving now; simply suppress trace
24 # event generation instead.
25 qga_qapi_files = custom_target('QGA QAPI files',
26                                output: qga_qapi_outputs,
27                                input: 'qapi-schema.json',
28                                command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', '@INPUT0@' ],
29                                depend_files: qapi_gen_depends)
30
31 qga_ss = ss.source_set()
32 qga_ss.add(qga_qapi_files.to_list())
33 qga_ss.add(files(
34   'commands.c',
35   'guest-agent-command-state.c',
36   'main.c',
37 ))
38 qga_ss.add(when: 'CONFIG_POSIX', if_true: files(
39   'channel-posix.c',
40   'commands-posix.c',
41   'commands-posix-ssh.c',
42 ))
43 qga_ss.add(when: 'CONFIG_WIN32', if_true: files(
44   'channel-win32.c',
45   'commands-win32.c',
46   'service-win32.c',
47   'vss-win32.c'
48 ))
49
50 qga_ss = qga_ss.apply(config_host, strict: false)
51
52 qga = executable('qemu-ga', qga_ss.sources(),
53                  link_args: config_host['LIBS_QGA'].split(),
54                  dependencies: [qemuutil, libudev],
55                  install: true)
56 all_qga = [qga]
57
58 if targetos == 'windows'
59   if 'CONFIG_QGA_VSS' in config_host
60     subdir('vss-win32')
61   else
62     gen_tlb = []
63   endif
64
65   qemu_ga_msi_arch = {
66     'x86': ['-D', 'Arch=32'],
67     'x86_64': ['-a', 'x64', '-D', 'Arch=64']
68   }
69   wixl = not_found
70   if cpu in qemu_ga_msi_arch
71     wixl = find_program('wixl', required: get_option('guest_agent_msi'))
72   elif get_option('guest_agent_msi').enabled()
73     error('CPU not supported for building guest agent installation package')
74   endif
75
76   if wixl.found()
77     deps = [gen_tlb, qga]
78     qemu_ga_msi_vss = []
79     if 'CONFIG_QGA_VSS' in config_host
80       qemu_ga_msi_vss = ['-D', 'InstallVss']
81       deps += qga_vss
82     endif
83     qga_msi = custom_target('QGA MSI',
84                             input: files('installer/qemu-ga.wxs'),
85                             output: 'qemu-ga-@0@.msi'.format(config_host['ARCH']),
86                             depends: deps,
87                             command: [
88                               find_program('env'),
89                               'QEMU_GA_VERSION=' + config_host['QEMU_GA_VERSION'],
90                               'QEMU_GA_MANUFACTURER=' + config_host['QEMU_GA_MANUFACTURER'],
91                               'QEMU_GA_DISTRO=' + config_host['QEMU_GA_DISTRO'],
92                               'BUILD_DIR=' + meson.build_root(),
93                               wixl, '-o', '@OUTPUT0@', '@INPUT0@',
94                               qemu_ga_msi_arch[cpu],
95                               qemu_ga_msi_vss,
96                               '-D', 'Mingw_dlls=' + config_host['QEMU_GA_MSI_MINGW_DLL_PATH'],
97                             ])
98     all_qga += [qga_msi]
99     alias_target('msi', qga_msi)
100   endif
101 else
102   if get_option('guest_agent_msi').enabled()
103     error('MSI guest agent package is available only for MinGW Windows cross-compilation')
104   endif
105   install_subdir('run', install_dir: get_option('localstatedir'))
106 endif
107
108 alias_target('qemu-ga', all_qga)
109
110 test_env = environment()
111 test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
112 test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
113
114 # disable qga-ssh-test for now. glib's G_TEST_OPTION_ISOLATE_DIRS triggers
115 # the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable
116 # this when an alternative is implemented or when the underlying glib
117 # issue is identified/fix
118 #if 'CONFIG_POSIX' in config_host
119 if false
120   srcs = [files('commands-posix-ssh.c')]
121   i = 0
122   foreach output: qga_qapi_outputs
123     if output.startswith('qga-qapi-types') or output.startswith('qga-qapi-visit')
124       srcs += qga_qapi_files[i]
125     endif
126     i = i + 1
127   endforeach
128   qga_ssh_test = executable('qga-ssh-test', srcs,
129                             dependencies: [qemuutil],
130                             c_args: ['-DQGA_BUILD_UNIT_TEST'])
131
132   test('qga-ssh-test',
133        qga_ssh_test,
134        env: test_env,
135        suite: ['unit', 'qga'])
136 endif