xref: /openbmc/qemu/qga/meson.build (revision 8a29c20597f98e20c7390300b63fa6ac7d3ad6dd)
120cf5cb4SPaolo Bonziniif not have_ga
220cf5cb4SPaolo Bonzini  if get_option('guest_agent_msi').enabled()
320cf5cb4SPaolo Bonzini    error('Guest agent MSI requested, but the guest agent is not being built')
420cf5cb4SPaolo Bonzini  endif
58821a389SMarc-André Lureau  have_qga_vss = false
620cf5cb4SPaolo Bonzini  subdir_done()
720cf5cb4SPaolo Bonziniendif
820cf5cb4SPaolo Bonzini
98821a389SMarc-André Lureauhave_qga_vss = get_option('qga_vss') \
108821a389SMarc-André Lureau  .require(targetos == 'windows',
118821a389SMarc-André Lureau           error_message: 'VSS support requires Windows') \
128821a389SMarc-André Lureau  .require(link_language == 'cpp',
138821a389SMarc-André Lureau           error_message: 'VSS support requires a C++ compiler') \
148821a389SMarc-André Lureau  .require(have_vss, error_message: '''VSS support requires VSS headers.
158821a389SMarc-André Lureau    If your Visual Studio installation doesn't have the VSS headers,
168821a389SMarc-André Lureau    Please download and install Microsoft VSS SDK:
178821a389SMarc-André Lureau    http://www.microsoft.com/en-us/download/details.aspx?id=23490
18b770f6ceSMarc-André Lureau    On POSIX-systems, MinGW should provide headers in >=10.0 releases.
198821a389SMarc-André Lureau    you can extract the SDK headers by:
208821a389SMarc-André Lureau    $ scripts/extract-vsssdk-headers setup.exe
218821a389SMarc-André Lureau    The headers are extracted in the directory 'inc/win2003'.
228821a389SMarc-André Lureau    Then run configure with: --extra-cxxflags="-isystem /path/to/vss/inc/win2003"''') \
2323011f44SMarc-André Lureau  .require(midl.found() or widl.found(),
2423011f44SMarc-André Lureau           error_message: 'VSS support requires midl or widl') \
25e23460ceSMarc-André Lureau  .require(not enable_static,
26e23460ceSMarc-André Lureau           error_message: 'VSS support requires dynamic linking with GLib') \
278821a389SMarc-André Lureau  .allowed()
288821a389SMarc-André Lureau
2987263685SPaolo Bonziniall_qga = []
3087263685SPaolo Bonzini
31f15bff25SPaolo Bonziniqga_qapi_outputs = [
32f15bff25SPaolo Bonzini  'qga-qapi-commands.c',
33f15bff25SPaolo Bonzini  'qga-qapi-commands.h',
34f15bff25SPaolo Bonzini  'qga-qapi-emit-events.c',
35f15bff25SPaolo Bonzini  'qga-qapi-emit-events.h',
36f15bff25SPaolo Bonzini  'qga-qapi-events.c',
37f15bff25SPaolo Bonzini  'qga-qapi-events.h',
38f15bff25SPaolo Bonzini  'qga-qapi-init-commands.c',
39f15bff25SPaolo Bonzini  'qga-qapi-init-commands.h',
40f15bff25SPaolo Bonzini  'qga-qapi-introspect.c',
41f15bff25SPaolo Bonzini  'qga-qapi-introspect.h',
42f15bff25SPaolo Bonzini  'qga-qapi-types.c',
43f15bff25SPaolo Bonzini  'qga-qapi-types.h',
44f15bff25SPaolo Bonzini  'qga-qapi-visit.c',
45f15bff25SPaolo Bonzini  'qga-qapi-visit.h',
46f15bff25SPaolo Bonzini]
47f15bff25SPaolo Bonzini
48378dfa48SVladimir Sementsov-Ogievskiy# Problem: to generate trace events, we'd have to add the .trace-events
49378dfa48SVladimir Sementsov-Ogievskiy# file to qapi_trace_events like we do in qapi/meson.build.  Since
50378dfa48SVladimir Sementsov-Ogievskiy# qapi_trace_events is used by trace/meson.build, we'd have to move
51378dfa48SVladimir Sementsov-Ogievskiy# subdir('qga') above subdir('trace') in the top-level meson.build.
52378dfa48SVladimir Sementsov-Ogievskiy# Can't, because it would break the dependency of qga on qemuutil (which
53378dfa48SVladimir Sementsov-Ogievskiy# depends on trace_ss).  Not worth solving now; simply suppress trace
54378dfa48SVladimir Sementsov-Ogievskiy# event generation instead.
55f15bff25SPaolo Bonziniqga_qapi_files = custom_target('QGA QAPI files',
56db16115fSPeter Maydell                               output: qga_qapi_outputs,
57f15bff25SPaolo Bonzini                               input: 'qapi-schema.json',
58761a1a48SVladimir Sementsov-Ogievskiy                               command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', '@INPUT0@',
59761a1a48SVladimir Sementsov-Ogievskiy                                          '--suppress-tracing' ],
60f15bff25SPaolo Bonzini                               depend_files: qapi_gen_depends)
61acfdaac5SPaolo Bonzini
62f15bff25SPaolo Bonziniqga_ss = ss.source_set()
632a127f96SMarc-André Lureauqga_ss.add(qga_qapi_files.to_list())
64f15bff25SPaolo Bonziniqga_ss.add(files(
65f15bff25SPaolo Bonzini  'commands.c',
66f15bff25SPaolo Bonzini  'guest-agent-command-state.c',
67f15bff25SPaolo Bonzini  'main.c',
680edbfbe3SMarc-André Lureau  'cutils.c',
69f15bff25SPaolo Bonzini))
70f15bff25SPaolo Bonziniqga_ss.add(when: 'CONFIG_POSIX', if_true: files(
71f15bff25SPaolo Bonzini  'channel-posix.c',
728d769ec7SMarc-André Lureau  'commands-posix.c',
738d769ec7SMarc-André Lureau  'commands-posix-ssh.c',
748d769ec7SMarc-André Lureau))
75f15bff25SPaolo Bonziniqga_ss.add(when: 'CONFIG_WIN32', if_true: files(
76f15bff25SPaolo Bonzini  'channel-win32.c',
77f15bff25SPaolo Bonzini  'commands-win32.c',
78f15bff25SPaolo Bonzini  'service-win32.c',
79f15bff25SPaolo Bonzini  'vss-win32.c'
80f15bff25SPaolo Bonzini))
81f15bff25SPaolo Bonzini
82f15bff25SPaolo Bonziniqga_ss = qga_ss.apply(config_host, strict: false)
83f15bff25SPaolo Bonzini
84328ec32dSMarc-André Lureaugen_tlb = []
8587263685SPaolo Bonziniqga_libs = []
8687263685SPaolo Bonziniif targetos == 'windows'
873015321dSMarc-André Lureau  qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32',
883015321dSMarc-André Lureau               '-lsetupapi', '-lcfgmgr32']
898821a389SMarc-André Lureau  if have_qga_vss
9087263685SPaolo Bonzini    qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup']
9187263685SPaolo Bonzini    subdir('vss-win32')
9287263685SPaolo Bonzini  endif
93328ec32dSMarc-André Lureauendif
94328ec32dSMarc-André Lureau
9587263685SPaolo Bonziniqga = executable('qemu-ga', qga_ss.sources(),
9687263685SPaolo Bonzini                 link_args: qga_libs,
9787263685SPaolo Bonzini                 dependencies: [qemuutil, libudev],
9887263685SPaolo Bonzini                 install: true)
9987263685SPaolo Bonziniall_qga += qga
10087263685SPaolo Bonzini
10187263685SPaolo Bonziniif targetos == 'windows'
102b846ab7cSPaolo Bonzini  qemu_ga_msi_arch = {
103b846ab7cSPaolo Bonzini    'x86': ['-D', 'Arch=32'],
104b846ab7cSPaolo Bonzini    'x86_64': ['-a', 'x64', '-D', 'Arch=64']
105b846ab7cSPaolo Bonzini  }
106b846ab7cSPaolo Bonzini  wixl = not_found
107b846ab7cSPaolo Bonzini  if cpu in qemu_ga_msi_arch
108b846ab7cSPaolo Bonzini    wixl = find_program('wixl', required: get_option('guest_agent_msi'))
109b846ab7cSPaolo Bonzini  elif get_option('guest_agent_msi').enabled()
110b846ab7cSPaolo Bonzini    error('CPU not supported for building guest agent installation package')
111b846ab7cSPaolo Bonzini  endif
112b846ab7cSPaolo Bonzini
113328ec32dSMarc-André Lureau  if wixl.found()
114328ec32dSMarc-André Lureau    deps = [gen_tlb, qga]
115b846ab7cSPaolo Bonzini    qemu_ga_msi_vss = []
1168821a389SMarc-André Lureau    if have_qga_vss
117b846ab7cSPaolo Bonzini      qemu_ga_msi_vss = ['-D', 'InstallVss']
118328ec32dSMarc-André Lureau      deps += qga_vss
119328ec32dSMarc-André Lureau    endif
120328ec32dSMarc-André Lureau    qga_msi = custom_target('QGA MSI',
121328ec32dSMarc-André Lureau                            input: files('installer/qemu-ga.wxs'),
1226bee0960SMarc-André Lureau                            output: 'qemu-ga-@0@.msi'.format(host_arch),
123328ec32dSMarc-André Lureau                            depends: deps,
124328ec32dSMarc-André Lureau                            command: [
125328ec32dSMarc-André Lureau                              wixl, '-o', '@OUTPUT0@', '@INPUT0@',
126b846ab7cSPaolo Bonzini                              qemu_ga_msi_arch[cpu],
127b846ab7cSPaolo Bonzini                              qemu_ga_msi_vss,
128ca5765c8SPaolo Bonzini                              '-D', 'BUILD_DIR=' + meson.project_build_root(),
1295b9e7d05SMarc-André Lureau                              '-D', 'BIN_DIR=' + glib.get_variable('bindir'),
1304f3c5778SMarc-André Lureau                              '-D', 'QEMU_GA_VERSION=' + config_host['QEMU_GA_VERSION'],
1314f3c5778SMarc-André Lureau                              '-D', 'QEMU_GA_MANUFACTURER=' + config_host['QEMU_GA_MANUFACTURER'],
1324f3c5778SMarc-André Lureau                              '-D', 'QEMU_GA_DISTRO=' + config_host['QEMU_GA_DISTRO'],
133328ec32dSMarc-André Lureau                            ])
134588a19faSPaolo Bonzini    all_qga += [qga_msi]
135328ec32dSMarc-André Lureau    alias_target('msi', qga_msi)
1367272fc72SMarc-André Lureau  endif
1378ab1aabcSMarc-André Lureauelse
138b846ab7cSPaolo Bonzini  if get_option('guest_agent_msi').enabled()
139b846ab7cSPaolo Bonzini    error('MSI guest agent package is available only for MinGW Windows cross-compilation')
140b846ab7cSPaolo Bonzini  endif
141*8a29c205SPaolo Bonzini  install_emptydir(get_option('localstatedir') / 'run')
1427272fc72SMarc-André Lureauendif
143588a19faSPaolo Bonzini
144588a19faSPaolo Bonzinialias_target('qemu-ga', all_qga)
1458d769ec7SMarc-André Lureau
1468d769ec7SMarc-André Lureautest_env = environment()
1478d769ec7SMarc-André Lureautest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
1488d769ec7SMarc-André Lureautest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
1498d769ec7SMarc-André Lureau
1508d769ec7SMarc-André Lureau# disable qga-ssh-test for now. glib's G_TEST_OPTION_ISOLATE_DIRS triggers
1518d769ec7SMarc-André Lureau# the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable
1528d769ec7SMarc-André Lureau# this when an alternative is implemented or when the underlying glib
1538d769ec7SMarc-André Lureau# issue is identified/fix
1548d769ec7SMarc-André Lureau#if 'CONFIG_POSIX' in config_host
1558d769ec7SMarc-André Lureauif false
156cad97c08SMarc-André Lureau  srcs = [files('commands-posix-ssh.c')]
157cad97c08SMarc-André Lureau  i = 0
158cad97c08SMarc-André Lureau  foreach output: qga_qapi_outputs
159cad97c08SMarc-André Lureau    if output.startswith('qga-qapi-types') or output.startswith('qga-qapi-visit')
160cad97c08SMarc-André Lureau      srcs += qga_qapi_files[i]
161cad97c08SMarc-André Lureau    endif
162cad97c08SMarc-André Lureau    i = i + 1
163cad97c08SMarc-André Lureau  endforeach
164cad97c08SMarc-André Lureau  qga_ssh_test = executable('qga-ssh-test', srcs,
1658d769ec7SMarc-André Lureau                            dependencies: [qemuutil],
1668d769ec7SMarc-André Lureau                            c_args: ['-DQGA_BUILD_UNIT_TEST'])
1678d769ec7SMarc-André Lureau
1688d769ec7SMarc-André Lureau  test('qga-ssh-test',
1698d769ec7SMarc-André Lureau       qga_ssh_test,
1708d769ec7SMarc-André Lureau       env: test_env,
1718d769ec7SMarc-André Lureau       suite: ['unit', 'qga'])
1728d769ec7SMarc-André Lureauendif
173