xref: /openbmc/qemu/qga/meson.build (revision 8d769ec777dccbff199711aba43aa6297fe4a0e0)
1qga_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
18qga_qapi_files = custom_target('QGA QAPI files',
19                               output: qga_qapi_outputs,
20                               input: 'qapi-schema.json',
21                               command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', '@INPUT0@' ],
22                               depend_files: qapi_gen_depends)
23
24qga_ss = ss.source_set()
25i = 0
26foreach output: qga_qapi_outputs
27  qga_ss.add(qga_qapi_files[i])
28  i = i + 1
29endforeach
30
31qga_ss.add(files(
32  'commands.c',
33  'guest-agent-command-state.c',
34  'main.c',
35))
36qga_ss.add(when: 'CONFIG_POSIX', if_true: files(
37  'channel-posix.c',
38  'commands-posix.c',
39  'commands-posix-ssh.c',
40))
41qga_ss.add(when: 'CONFIG_WIN32', if_true: files(
42  'channel-win32.c',
43  'commands-win32.c',
44  'service-win32.c',
45  'vss-win32.c'
46))
47
48qga_ss = qga_ss.apply(config_host, strict: false)
49
50qga = executable('qemu-ga', qga_ss.sources(),
51                 link_args: config_host['LIBS_QGA'].split(),
52                 dependencies: [qemuutil, libudev],
53                 install: true)
54all_qga = [qga]
55
56if targetos == 'windows'
57  if 'CONFIG_QGA_VSS' in config_host
58    subdir('vss-win32')
59  else
60    gen_tlb = []
61  endif
62
63  wixl = find_program('wixl', required: false)
64  if wixl.found()
65    deps = [gen_tlb, qga]
66    if 'CONFIG_QGA_VSS' in config_host and 'QEMU_GA_MSI_WITH_VSS' in config_host
67      deps += qga_vss
68    endif
69    qga_msi = custom_target('QGA MSI',
70                            input: files('installer/qemu-ga.wxs'),
71                            output: 'qemu-ga-@0@.msi'.format(config_host['ARCH']),
72                            depends: deps,
73                            command: [
74                              find_program('env'),
75                              'QEMU_GA_VERSION=' + config_host['QEMU_GA_VERSION'],
76                              'QEMU_GA_MANUFACTURER=' + config_host['QEMU_GA_MANUFACTURER'],
77                              'QEMU_GA_DISTRO=' + config_host['QEMU_GA_DISTRO'],
78                              'BUILD_DIR=' + meson.build_root(),
79                              wixl, '-o', '@OUTPUT0@', '@INPUT0@',
80                              config_host['QEMU_GA_MSI_ARCH'].split(),
81                              config_host['QEMU_GA_MSI_WITH_VSS'].split(),
82                              config_host['QEMU_GA_MSI_MINGW_DLL_PATH'].split(),
83                            ])
84    all_qga += [qga_msi]
85    alias_target('msi', qga_msi)
86  endif
87else
88  install_subdir('run', install_dir: get_option('localstatedir'))
89endif
90
91alias_target('qemu-ga', all_qga)
92
93test_env = environment()
94test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
95test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
96
97# disable qga-ssh-test for now. glib's G_TEST_OPTION_ISOLATE_DIRS triggers
98# the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable
99# this when an alternative is implemented or when the underlying glib
100# issue is identified/fix
101#if 'CONFIG_POSIX' in config_host
102if false
103  qga_ssh_test = executable('qga-ssh-test',
104                            files('commands-posix-ssh.c'),
105                            dependencies: [qemuutil],
106                            c_args: ['-DQGA_BUILD_UNIT_TEST'])
107
108  test('qga-ssh-test',
109       qga_ssh_test,
110       env: test_env,
111       suite: ['unit', 'qga'])
112endif
113