]> git.proxmox.com Git - mirror_qemu.git/blame - qga/meson.build
Merge tag 'pull-tcg-20221004' of https://gitlab.com/rth7680/qemu into staging
[mirror_qemu.git] / qga / meson.build
CommitLineData
20cf5cb4
PB
1if not have_ga
2 if get_option('guest_agent_msi').enabled()
3 error('Guest agent MSI requested, but the guest agent is not being built')
4 endif
8821a389 5 have_qga_vss = false
20cf5cb4
PB
6 subdir_done()
7endif
8
8821a389
MAL
9have_qga_vss = get_option('qga_vss') \
10 .require(targetos == 'windows',
11 error_message: 'VSS support requires Windows') \
12 .require(link_language == 'cpp',
13 error_message: 'VSS support requires a C++ compiler') \
14 .require(have_vss, error_message: '''VSS support requires VSS headers.
15 If your Visual Studio installation doesn't have the VSS headers,
16 Please download and install Microsoft VSS SDK:
17 http://www.microsoft.com/en-us/download/details.aspx?id=23490
b770f6ce 18 On POSIX-systems, MinGW should provide headers in >=10.0 releases.
8821a389
MAL
19 you can extract the SDK headers by:
20 $ scripts/extract-vsssdk-headers setup.exe
21 The headers are extracted in the directory 'inc/win2003'.
22 Then run configure with: --extra-cxxflags="-isystem /path/to/vss/inc/win2003"''') \
23011f44
MAL
23 .require(midl.found() or widl.found(),
24 error_message: 'VSS support requires midl or widl') \
e23460ce
MAL
25 .require(not enable_static,
26 error_message: 'VSS support requires dynamic linking with GLib') \
8821a389
MAL
27 .allowed()
28
87263685
PB
29all_qga = []
30
f15bff25
PB
31qga_qapi_outputs = [
32 'qga-qapi-commands.c',
33 'qga-qapi-commands.h',
f15bff25
PB
34 'qga-qapi-emit-events.c',
35 'qga-qapi-emit-events.h',
36 'qga-qapi-events.c',
37 'qga-qapi-events.h',
38 'qga-qapi-init-commands.c',
39 'qga-qapi-init-commands.h',
40 'qga-qapi-introspect.c',
41 'qga-qapi-introspect.h',
42 'qga-qapi-types.c',
43 'qga-qapi-types.h',
44 'qga-qapi-visit.c',
45 'qga-qapi-visit.h',
46]
47
378dfa48
VSO
48# Problem: to generate trace events, we'd have to add the .trace-events
49# file to qapi_trace_events like we do in qapi/meson.build. Since
50# qapi_trace_events is used by trace/meson.build, we'd have to move
51# subdir('qga') above subdir('trace') in the top-level meson.build.
52# Can't, because it would break the dependency of qga on qemuutil (which
53# depends on trace_ss). Not worth solving now; simply suppress trace
54# event generation instead.
f15bff25 55qga_qapi_files = custom_target('QGA QAPI files',
db16115f 56 output: qga_qapi_outputs,
f15bff25 57 input: 'qapi-schema.json',
761a1a48
VSO
58 command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', '@INPUT0@',
59 '--suppress-tracing' ],
f15bff25 60 depend_files: qapi_gen_depends)
acfdaac5 61
f15bff25 62qga_ss = ss.source_set()
2a127f96 63qga_ss.add(qga_qapi_files.to_list())
f15bff25
PB
64qga_ss.add(files(
65 'commands.c',
66 'guest-agent-command-state.c',
67 'main.c',
0edbfbe3 68 'cutils.c',
f15bff25
PB
69))
70qga_ss.add(when: 'CONFIG_POSIX', if_true: files(
71 'channel-posix.c',
8d769ec7
MAL
72 'commands-posix.c',
73 'commands-posix-ssh.c',
74))
f15bff25
PB
75qga_ss.add(when: 'CONFIG_WIN32', if_true: files(
76 'channel-win32.c',
77 'commands-win32.c',
78 'service-win32.c',
79 'vss-win32.c'
80))
81
82qga_ss = qga_ss.apply(config_host, strict: false)
83
87263685
PB
84gen_tlb = []
85qga_libs = []
7272fc72 86if targetos == 'windows'
3015321d
MAL
87 qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32',
88 '-lsetupapi', '-lcfgmgr32']
8821a389 89 if have_qga_vss
87263685 90 qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup']
7272fc72 91 subdir('vss-win32')
328ec32d 92 endif
87263685 93endif
328ec32d 94
87263685
PB
95qga = executable('qemu-ga', qga_ss.sources(),
96 link_args: qga_libs,
97 dependencies: [qemuutil, libudev],
98 install: true)
99all_qga += qga
100
101if targetos == 'windows'
b846ab7c
PB
102 qemu_ga_msi_arch = {
103 'x86': ['-D', 'Arch=32'],
104 'x86_64': ['-a', 'x64', '-D', 'Arch=64']
105 }
106 wixl = not_found
107 if cpu in qemu_ga_msi_arch
108 wixl = find_program('wixl', required: get_option('guest_agent_msi'))
109 elif get_option('guest_agent_msi').enabled()
110 error('CPU not supported for building guest agent installation package')
111 endif
112
328ec32d
MAL
113 if wixl.found()
114 deps = [gen_tlb, qga]
b846ab7c 115 qemu_ga_msi_vss = []
8821a389 116 if have_qga_vss
b846ab7c 117 qemu_ga_msi_vss = ['-D', 'InstallVss']
328ec32d
MAL
118 deps += qga_vss
119 endif
b846ab7c
PB
120 qga_msi = custom_target('QGA MSI',
121 input: files('installer/qemu-ga.wxs'),
6bee0960 122 output: 'qemu-ga-@0@.msi'.format(host_arch),
b846ab7c
PB
123 depends: deps,
124 command: [
b846ab7c
PB
125 wixl, '-o', '@OUTPUT0@', '@INPUT0@',
126 qemu_ga_msi_arch[cpu],
127 qemu_ga_msi_vss,
ca5765c8 128 '-D', 'BUILD_DIR=' + meson.project_build_root(),
5b9e7d05 129 '-D', 'BIN_DIR=' + glib.get_variable('bindir'),
4f3c5778
MAL
130 '-D', 'QEMU_GA_VERSION=' + config_host['QEMU_GA_VERSION'],
131 '-D', 'QEMU_GA_MANUFACTURER=' + config_host['QEMU_GA_MANUFACTURER'],
132 '-D', 'QEMU_GA_DISTRO=' + config_host['QEMU_GA_DISTRO'],
b846ab7c
PB
133 ])
134 all_qga += [qga_msi]
135 alias_target('msi', qga_msi)
7272fc72 136 endif
8ab1aabc 137else
b846ab7c
PB
138 if get_option('guest_agent_msi').enabled()
139 error('MSI guest agent package is available only for MinGW Windows cross-compilation')
140 endif
8a29c205 141 install_emptydir(get_option('localstatedir') / 'run')
7272fc72 142endif
588a19fa
PB
143
144alias_target('qemu-ga', all_qga)
8d769ec7
MAL
145
146test_env = environment()
147test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
148test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
149
150# disable qga-ssh-test for now. glib's G_TEST_OPTION_ISOLATE_DIRS triggers
151# the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable
152# this when an alternative is implemented or when the underlying glib
153# issue is identified/fix
154#if 'CONFIG_POSIX' in config_host
155if false
cad97c08
MAL
156 srcs = [files('commands-posix-ssh.c')]
157 i = 0
158 foreach output: qga_qapi_outputs
159 if output.startswith('qga-qapi-types') or output.startswith('qga-qapi-visit')
160 srcs += qga_qapi_files[i]
161 endif
162 i = i + 1
163 endforeach
164 qga_ssh_test = executable('qga-ssh-test', srcs,
8d769ec7
MAL
165 dependencies: [qemuutil],
166 c_args: ['-DQGA_BUILD_UNIT_TEST'])
167
168 test('qga-ssh-test',
169 qga_ssh_test,
170 env: test_env,
171 suite: ['unit', 'qga'])
172endif