qemu/qga/meson.build
<<
>>
Prefs
   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
   5  have_qga_vss = false
   6  subdir_done()
   7endif
   8
   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
  18    On POSIX-systems, MinGW should provide headers in >=10.0 releases.
  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  .require(not enable_static,
  26           error_message: 'VSS support requires dynamic linking with GLib') \
  27  .allowed()
  28
  29all_qga = []
  30
  31qga_qapi_outputs = [
  32  'qga-qapi-commands.c',
  33  'qga-qapi-commands.h',
  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
  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.
  55qga_qapi_files = custom_target('QGA QAPI files',
  56                               output: qga_qapi_outputs,
  57                               input: 'qapi-schema.json',
  58                               command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', '@INPUT0@',
  59                                          '--suppress-tracing' ],
  60                               depend_files: qapi_gen_depends)
  61
  62qga_ss = ss.source_set()
  63qga_ss.add(qga_qapi_files.to_list())
  64qga_ss.add(files(
  65  'commands.c',
  66  'guest-agent-command-state.c',
  67  'main.c',
  68))
  69qga_ss.add(when: 'CONFIG_POSIX', if_true: files(
  70  'channel-posix.c',
  71  'commands-posix.c',
  72  'commands-posix-ssh.c',
  73))
  74qga_ss.add(when: 'CONFIG_WIN32', if_true: files(
  75  'channel-win32.c',
  76  'commands-win32.c',
  77  'service-win32.c',
  78  'vss-win32.c'
  79))
  80
  81qga_ss = qga_ss.apply(config_host, strict: false)
  82
  83gen_tlb = []
  84qga_libs = []
  85if targetos == 'windows'
  86  qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32']
  87  if have_qga_vss
  88    qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup']
  89    subdir('vss-win32')
  90  endif
  91  if have_ntddscsi
  92    qga_libs += ['-lsetupapi', '-lcfgmgr32']
  93  endif
  94endif
  95
  96qga = executable('qemu-ga', qga_ss.sources(),
  97                 link_args: qga_libs,
  98                 dependencies: [qemuutil, libudev],
  99                 install: true)
 100all_qga += qga
 101
 102if targetos == 'windows'
 103  qemu_ga_msi_arch = {
 104    'x86': ['-D', 'Arch=32'],
 105    'x86_64': ['-a', 'x64', '-D', 'Arch=64']
 106  }
 107  wixl = not_found
 108  if cpu in qemu_ga_msi_arch
 109    wixl = find_program('wixl', required: get_option('guest_agent_msi'))
 110  elif get_option('guest_agent_msi').enabled()
 111    error('CPU not supported for building guest agent installation package')
 112  endif
 113
 114  if wixl.found()
 115    deps = [gen_tlb, qga]
 116    qemu_ga_msi_vss = []
 117    if have_qga_vss
 118      qemu_ga_msi_vss = ['-D', 'InstallVss']
 119      deps += qga_vss
 120    endif
 121    qga_msi = custom_target('QGA MSI',
 122                            input: files('installer/qemu-ga.wxs'),
 123                            output: 'qemu-ga-@0@.msi'.format(host_arch),
 124                            depends: deps,
 125                            command: [
 126                              find_program('env'),
 127                              'QEMU_GA_VERSION=' + config_host['QEMU_GA_VERSION'],
 128                              'QEMU_GA_MANUFACTURER=' + config_host['QEMU_GA_MANUFACTURER'],
 129                              'QEMU_GA_DISTRO=' + config_host['QEMU_GA_DISTRO'],
 130                              'BUILD_DIR=' + meson.build_root(),
 131                              wixl, '-o', '@OUTPUT0@', '@INPUT0@',
 132                              qemu_ga_msi_arch[cpu],
 133                              qemu_ga_msi_vss,
 134                              '-D', 'Mingw_dlls=' + config_host['QEMU_GA_MSI_MINGW_DLL_PATH'],
 135                            ])
 136    all_qga += [qga_msi]
 137    alias_target('msi', qga_msi)
 138  endif
 139else
 140  if get_option('guest_agent_msi').enabled()
 141    error('MSI guest agent package is available only for MinGW Windows cross-compilation')
 142  endif
 143  install_subdir('run', install_dir: get_option('localstatedir'))
 144endif
 145
 146alias_target('qemu-ga', all_qga)
 147
 148test_env = environment()
 149test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
 150test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
 151
 152# disable qga-ssh-test for now. glib's G_TEST_OPTION_ISOLATE_DIRS triggers
 153# the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable
 154# this when an alternative is implemented or when the underlying glib
 155# issue is identified/fix
 156#if 'CONFIG_POSIX' in config_host
 157if false
 158  srcs = [files('commands-posix-ssh.c')]
 159  i = 0
 160  foreach output: qga_qapi_outputs
 161    if output.startswith('qga-qapi-types') or output.startswith('qga-qapi-visit')
 162      srcs += qga_qapi_files[i]
 163    endif
 164    i = i + 1
 165  endforeach
 166  qga_ssh_test = executable('qga-ssh-test', srcs,
 167                            dependencies: [qemuutil],
 168                            c_args: ['-DQGA_BUILD_UNIT_TEST'])
 169
 170  test('qga-ssh-test',
 171       qga_ssh_test,
 172       env: test_env,
 173       suite: ['unit', 'qga'])
 174endif
 175