master
build 88 lines 3.58 KB
Raw
1 if not get_option('plugins')
2 subdir_done()
3 endif
4
5 qemu_plugin_symbols = configure_file(
6 input: files('../include/plugins/qemu-plugin.h'),
7 output: 'qemu-plugin.symbols',
8 capture: true,
9 command: [files('../scripts/qemu-plugin-symbols.py'), '@INPUT@'])
10
11 # Modules need more symbols than just those in plugins/qemu-plugins.symbols
12 if not enable_modules
13 if host_os == 'darwin'
14 configure_file(
15 input: qemu_plugin_symbols,
16 output: 'qemu-plugins-ld64.symbols',
17 capture: true,
18 command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', '@INPUT@'])
19 emulator_link_args += ['-Wl,-exported_symbols_list,plugins/qemu-plugins-ld64.symbols']
20 elif host_os == 'windows' and meson.get_compiler('c').get_id() == 'clang'
21 # LLVM/lld does not support exporting specific symbols. However, it works
22 # out of the box with dllexport/dllimport attribute we set in the code.
23 else
24 emulator_link_args += ['-Xlinker', '--dynamic-list=' + qemu_plugin_symbols.full_path()]
25 endif
26 endif
27
28 if host_os == 'windows'
29 # Generate a .lib file for plugins to link against.
30 # First, create a .def file listing all the symbols a plugin should expect to have
31 # available in qemu
32 win32_plugin_def = configure_file(
33 input: qemu_plugin_symbols,
34 output: 'qemu_plugin_api.def',
35 capture: true,
36 command: [python, '-c', 'import fileinput, re; print("EXPORTS", end=""); [print(re.sub(r"[{};]", "", line), end="") for line in fileinput.input()]', '@INPUT@'])
37
38 # then use dlltool to assemble a delaylib.
39 # The delaylib will have an "imaginary" name (qemu.exe), that is used by the
40 # linker file we add with plugins (win32_linker.c) to identify that we want
41 # to find missing symbols in current program.
42 win32_qemu_plugin_api_link_flags = ['-Lplugins', '-lqemu_plugin_api']
43 if meson.get_compiler('c').get_id() == 'clang'
44 if host_machine.cpu() == 'x86_64'
45 dlltool_target = 'i386:x86-64'
46 elif host_machine.cpu() == 'aarch64'
47 dlltool_target = 'arm64'
48 else
49 error('Unknown machine')
50 endif
51 # With LLVM/lld, delaylib is specified at link time (-delayload)
52 dlltool = find_program('llvm-dlltool', required: true)
53 dlltool_cmd = [dlltool, '-m', dlltool_target,'-d', '@INPUT@', '-l', '@OUTPUT@', '-D', 'qemu.exe']
54 win32_qemu_plugin_api_link_flags += ['-Wl,-delayload=qemu.exe']
55 else
56 # With gcc/ld, delay lib is built with a specific delay parameter.
57 dlltool = find_program('dlltool', required: true)
58 dlltool_cmd = [dlltool, '--input-def', '@INPUT@',
59 '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe']
60 endif
61 win32_qemu_plugin_api = configure_file(
62 input: win32_plugin_def,
63 output: 'libqemu_plugin_api.a',
64 command: dlltool_cmd
65 )
66 win32_qemu_plugin_api_lib = static_library('win32_qemu_plugin_api',
67 link_depends: win32_qemu_plugin_api)
68 endif
69
70 if host_os == 'windows'
71 plugins_deps = declare_dependency(sources: [files('win32_linker.c')],
72 include_directories: '../include/plugins',
73 link_with: win32_qemu_plugin_api_lib,
74 link_args: win32_qemu_plugin_api_link_flags,
75 dependencies: glib)
76 else
77 plugins_deps = declare_dependency(include_directories: '../include/plugins',
78 dependencies: glib)
79 endif
80
81 user_ss.add(files('user.c', 'api-user.c'))
82 system_ss.add(files('system.c', 'api-system.c'))
83
84 user_ss.add(files('api.c', 'core.c'))
85 system_ss.add(files('api.c', 'core.c'))
86
87 common_ss.add(files('loader.c'))
88