OSDN Git Service

qga/vss-win32: require widl/midl, remove pre-built TLB file
[qmiga/qemu.git] / qga / meson.build
1 if 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
5   have_qga_vss = false
6   subdir_done()
7 endif
8
9 have_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
18     On POSIX-systems, MinGW doesn't yet provide working headers.
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"''') \
23   .require(midl.found() or widl.found(),
24            error_message: 'VSS support requires midl or widl') \
25   .allowed()
26
27 all_qga = []
28
29 qga_qapi_outputs = [
30   'qga-qapi-commands.c',
31   'qga-qapi-commands.h',
32   'qga-qapi-emit-events.c',
33   'qga-qapi-emit-events.h',
34   'qga-qapi-events.c',
35   'qga-qapi-events.h',
36   'qga-qapi-init-commands.c',
37   'qga-qapi-init-commands.h',
38   'qga-qapi-introspect.c',
39   'qga-qapi-introspect.h',
40   'qga-qapi-types.c',
41   'qga-qapi-types.h',
42   'qga-qapi-visit.c',
43   'qga-qapi-visit.h',
44 ]
45
46 # Problem: to generate trace events, we'd have to add the .trace-events
47 # file to qapi_trace_events like we do in qapi/meson.build.  Since
48 # qapi_trace_events is used by trace/meson.build, we'd have to move
49 # subdir('qga') above subdir('trace') in the top-level meson.build.
50 # Can't, because it would break the dependency of qga on qemuutil (which
51 # depends on trace_ss).  Not worth solving now; simply suppress trace
52 # event generation instead.
53 qga_qapi_files = custom_target('QGA QAPI files',
54                                output: qga_qapi_outputs,
55                                input: 'qapi-schema.json',
56                                command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', '@INPUT0@',
57                                           '--suppress-tracing' ],
58                                depend_files: qapi_gen_depends)
59
60 qga_ss = ss.source_set()
61 qga_ss.add(qga_qapi_files.to_list())
62 qga_ss.add(files(
63   'commands.c',
64   'guest-agent-command-state.c',
65   'main.c',
66 ))
67 qga_ss.add(when: 'CONFIG_POSIX', if_true: files(
68   'channel-posix.c',
69   'commands-posix.c',
70   'commands-posix-ssh.c',
71 ))
72 qga_ss.add(when: 'CONFIG_WIN32', if_true: files(
73   'channel-win32.c',
74   'commands-win32.c',
75   'service-win32.c',
76   'vss-win32.c'
77 ))
78
79 qga_ss = qga_ss.apply(config_host, strict: false)
80
81 gen_tlb = []
82 qga_libs = []
83 if targetos == 'windows'
84   qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32']
85   if have_qga_vss
86     qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup']
87     subdir('vss-win32')
88   endif
89   if 'CONFIG_QGA_NTDDSCSI' in config_host
90     qga_libs += ['-lsetupapi', '-lcfgmgr32']
91   endif
92 endif
93
94 qga = executable('qemu-ga', qga_ss.sources(),
95                  link_args: qga_libs,
96                  dependencies: [qemuutil, libudev],
97                  install: true)
98 all_qga += qga
99
100 if targetos == 'windows'
101   qemu_ga_msi_arch = {
102     'x86': ['-D', 'Arch=32'],
103     'x86_64': ['-a', 'x64', '-D', 'Arch=64']
104   }
105   wixl = not_found
106   if cpu in qemu_ga_msi_arch
107     wixl = find_program('wixl', required: get_option('guest_agent_msi'))
108   elif get_option('guest_agent_msi').enabled()
109     error('CPU not supported for building guest agent installation package')
110   endif
111
112   if wixl.found()
113     deps = [gen_tlb, qga]
114     qemu_ga_msi_vss = []
115     if have_qga_vss
116       qemu_ga_msi_vss = ['-D', 'InstallVss']
117       deps += qga_vss
118     endif
119     qga_msi = custom_target('QGA MSI',
120                             input: files('installer/qemu-ga.wxs'),
121                             output: 'qemu-ga-@0@.msi'.format(host_arch),
122                             depends: deps,
123                             command: [
124                               find_program('env'),
125                               'QEMU_GA_VERSION=' + config_host['QEMU_GA_VERSION'],
126                               'QEMU_GA_MANUFACTURER=' + config_host['QEMU_GA_MANUFACTURER'],
127                               'QEMU_GA_DISTRO=' + config_host['QEMU_GA_DISTRO'],
128                               'BUILD_DIR=' + meson.build_root(),
129                               wixl, '-o', '@OUTPUT0@', '@INPUT0@',
130                               qemu_ga_msi_arch[cpu],
131                               qemu_ga_msi_vss,
132                               '-D', 'Mingw_dlls=' + config_host['QEMU_GA_MSI_MINGW_DLL_PATH'],
133                             ])
134     all_qga += [qga_msi]
135     alias_target('msi', qga_msi)
136   endif
137 else
138   if get_option('guest_agent_msi').enabled()
139     error('MSI guest agent package is available only for MinGW Windows cross-compilation')
140   endif
141   install_subdir('run', install_dir: get_option('localstatedir'))
142 endif
143
144 alias_target('qemu-ga', all_qga)
145
146 test_env = environment()
147 test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
148 test_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
155 if false
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,
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'])
172 endif