OSDN Git Service

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