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') \ 12785abf0dSThomas Huth .require('cpp' in all_languages, 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') \ 25a0cbd2e8SPaolo Bonzini .require(not get_option('prefer_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)) 70*dc495494SPaolo Bonziniif targetos == 'windows' 71*dc495494SPaolo Bonzini qga_ss.add(files( 72*dc495494SPaolo Bonzini 'channel-win32.c', 73*dc495494SPaolo Bonzini 'commands-win32.c', 74*dc495494SPaolo Bonzini 'service-win32.c', 75*dc495494SPaolo Bonzini 'vss-win32.c' 76*dc495494SPaolo Bonzini )) 77*dc495494SPaolo Bonzinielse 78*dc495494SPaolo Bonzini qga_ss.add(files( 79f15bff25SPaolo Bonzini 'channel-posix.c', 808d769ec7SMarc-André Lureau 'commands-posix.c', 818d769ec7SMarc-André Lureau 'commands-posix-ssh.c', 828d769ec7SMarc-André Lureau )) 8353e8868dSPaolo Bonzini if targetos == 'linux' 8453e8868dSPaolo Bonzini qga_ss.add(files('commands-linux.c')) 8553e8868dSPaolo Bonzini elif targetos in bsd_oses 8653e8868dSPaolo Bonzini qga_ss.add(files('commands-bsd.c')) 8753e8868dSPaolo Bonzini endif 88*dc495494SPaolo Bonziniendif 89f15bff25SPaolo Bonzini 901f2146f7SPaolo Bonziniqga_ss = qga_ss.apply(config_targetos, strict: false) 91f15bff25SPaolo Bonzini 92328ec32dSMarc-André Lureaugen_tlb = [] 9387263685SPaolo Bonziniqga_libs = [] 9487263685SPaolo Bonziniif targetos == 'windows' 953015321dSMarc-André Lureau qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32', 963015321dSMarc-André Lureau '-lsetupapi', '-lcfgmgr32'] 978821a389SMarc-André Lureau if have_qga_vss 9887263685SPaolo Bonzini qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup'] 9987263685SPaolo Bonzini subdir('vss-win32') 10087263685SPaolo Bonzini endif 101328ec32dSMarc-André Lureauendif 102328ec32dSMarc-André Lureau 103f9f0e617SAndrey Drobyshevqga_objs = [] 104f9f0e617SAndrey Drobyshevif targetos == 'windows' 105f9f0e617SAndrey Drobyshev windmc = find_program('windmc', required: true) 106f9f0e617SAndrey Drobyshev windres = find_program('windres', required: true) 107f9f0e617SAndrey Drobyshev 108f9f0e617SAndrey Drobyshev msgrc = custom_target('messages-win32.rc', 109f9f0e617SAndrey Drobyshev input: 'messages-win32.mc', 110f9f0e617SAndrey Drobyshev output: ['messages-win32.rc', 'MSG00409.bin', 'messages-win32.h'], 111f9f0e617SAndrey Drobyshev command: [windmc, '-h', '@OUTDIR@', '-r', '@OUTDIR@', '@INPUT@']) 112f9f0e617SAndrey Drobyshev msgobj = custom_target('messages-win32.o', 113f9f0e617SAndrey Drobyshev input: msgrc[0], 114f9f0e617SAndrey Drobyshev output: 'messages-win32.o', 115f9f0e617SAndrey Drobyshev command: [windres, '-I', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@']) 116f9f0e617SAndrey Drobyshev 117f9f0e617SAndrey Drobyshev qga_objs = [msgobj] 118f9f0e617SAndrey Drobyshevendif 119f9f0e617SAndrey Drobyshev 120f9f0e617SAndrey Drobyshevqga = executable('qemu-ga', qga_ss.sources() + qga_objs, 12187263685SPaolo Bonzini link_args: qga_libs, 12287263685SPaolo Bonzini dependencies: [qemuutil, libudev], 12387263685SPaolo Bonzini install: true) 12487263685SPaolo Bonziniall_qga += qga 12587263685SPaolo Bonzini 12687263685SPaolo Bonziniif targetos == 'windows' 127b846ab7cSPaolo Bonzini qemu_ga_msi_arch = { 128b846ab7cSPaolo Bonzini 'x86': ['-D', 'Arch=32'], 129b846ab7cSPaolo Bonzini 'x86_64': ['-a', 'x64', '-D', 'Arch=64'] 130b846ab7cSPaolo Bonzini } 131b846ab7cSPaolo Bonzini wixl = not_found 132b846ab7cSPaolo Bonzini if cpu in qemu_ga_msi_arch 133b846ab7cSPaolo Bonzini wixl = find_program('wixl', required: get_option('guest_agent_msi')) 134b846ab7cSPaolo Bonzini elif get_option('guest_agent_msi').enabled() 135b846ab7cSPaolo Bonzini error('CPU not supported for building guest agent installation package') 136b846ab7cSPaolo Bonzini endif 137b846ab7cSPaolo Bonzini 138328ec32dSMarc-André Lureau if wixl.found() 139328ec32dSMarc-André Lureau deps = [gen_tlb, qga] 140b846ab7cSPaolo Bonzini qemu_ga_msi_vss = [] 1418821a389SMarc-André Lureau if have_qga_vss 142b846ab7cSPaolo Bonzini qemu_ga_msi_vss = ['-D', 'InstallVss'] 143328ec32dSMarc-André Lureau deps += qga_vss 144328ec32dSMarc-André Lureau endif 1457b47b13eSPaolo Bonzini if glib.version().version_compare('<2.73.2') 1469ca180bcSAndrey Drobyshev libpcre = 'libpcre1' 1479ca180bcSAndrey Drobyshev else 1489ca180bcSAndrey Drobyshev libpcre = 'libpcre2' 1499ca180bcSAndrey Drobyshev endif 150e20d68aaSPaolo Bonzini qga_msi_version = get_option('qemu_ga_version') == '' \ 1517e5b1979SMarc-André Lureau ? meson.project_version() \ 152e20d68aaSPaolo Bonzini : get_option('qemu_ga_version') 153328ec32dSMarc-André Lureau qga_msi = custom_target('QGA MSI', 154328ec32dSMarc-André Lureau input: files('installer/qemu-ga.wxs'), 1556bee0960SMarc-André Lureau output: 'qemu-ga-@0@.msi'.format(host_arch), 156328ec32dSMarc-André Lureau depends: deps, 157328ec32dSMarc-André Lureau command: [ 158328ec32dSMarc-André Lureau wixl, '-o', '@OUTPUT0@', '@INPUT0@', 159b846ab7cSPaolo Bonzini qemu_ga_msi_arch[cpu], 160b846ab7cSPaolo Bonzini qemu_ga_msi_vss, 161ca5765c8SPaolo Bonzini '-D', 'BUILD_DIR=' + meson.project_build_root(), 16291a2e688SPaolo Bonzini '-D', 'BIN_DIR=' + glib_pc.get_variable('bindir'), 163e20d68aaSPaolo Bonzini '-D', 'QEMU_GA_VERSION=' + qga_msi_version, 164e20d68aaSPaolo Bonzini '-D', 'QEMU_GA_MANUFACTURER=' + get_option('qemu_ga_manufacturer'), 165e20d68aaSPaolo Bonzini '-D', 'QEMU_GA_DISTRO=' + get_option('qemu_ga_distro'), 1669ca180bcSAndrey Drobyshev '-D', 'LIBPCRE=' + libpcre, 167328ec32dSMarc-André Lureau ]) 168588a19faSPaolo Bonzini all_qga += [qga_msi] 169328ec32dSMarc-André Lureau alias_target('msi', qga_msi) 1707272fc72SMarc-André Lureau endif 1718ab1aabcSMarc-André Lureauelse 172b846ab7cSPaolo Bonzini if get_option('guest_agent_msi').enabled() 173b846ab7cSPaolo Bonzini error('MSI guest agent package is available only for MinGW Windows cross-compilation') 174b846ab7cSPaolo Bonzini endif 1758a29c205SPaolo Bonzini install_emptydir(get_option('localstatedir') / 'run') 1767272fc72SMarc-André Lureauendif 177588a19faSPaolo Bonzini 178588a19faSPaolo Bonzinialias_target('qemu-ga', all_qga) 1798d769ec7SMarc-André Lureau 1808d769ec7SMarc-André Lureautest_env = environment() 1818d769ec7SMarc-André Lureautest_env.set('G_TEST_SRCDIR', meson.current_source_dir()) 1828d769ec7SMarc-André Lureautest_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) 1838d769ec7SMarc-André Lureau 1848d769ec7SMarc-André Lureau# disable qga-ssh-test for now. glib's G_TEST_OPTION_ISOLATE_DIRS triggers 1858d769ec7SMarc-André Lureau# the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable 1868d769ec7SMarc-André Lureau# this when an alternative is implemented or when the underlying glib 1878d769ec7SMarc-André Lureau# issue is identified/fix 1881f2146f7SPaolo Bonzini#if targetos != 'windows' 1898d769ec7SMarc-André Lureauif false 190cad97c08SMarc-André Lureau srcs = [files('commands-posix-ssh.c')] 191cad97c08SMarc-André Lureau i = 0 192cad97c08SMarc-André Lureau foreach output: qga_qapi_outputs 193cad97c08SMarc-André Lureau if output.startswith('qga-qapi-types') or output.startswith('qga-qapi-visit') 194cad97c08SMarc-André Lureau srcs += qga_qapi_files[i] 195cad97c08SMarc-André Lureau endif 196cad97c08SMarc-André Lureau i = i + 1 197cad97c08SMarc-André Lureau endforeach 198cad97c08SMarc-André Lureau qga_ssh_test = executable('qga-ssh-test', srcs, 1998d769ec7SMarc-André Lureau dependencies: [qemuutil], 2008d769ec7SMarc-André Lureau c_args: ['-DQGA_BUILD_UNIT_TEST']) 2018d769ec7SMarc-André Lureau 2028d769ec7SMarc-André Lureau test('qga-ssh-test', 2038d769ec7SMarc-André Lureau qga_ssh_test, 2048d769ec7SMarc-André Lureau env: test_env, 2058d769ec7SMarc-André Lureau suite: ['unit', 'qga']) 2068d769ec7SMarc-André Lureauendif 207