meson.build 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. if not get_option('plugins')
  2. subdir_done()
  3. endif
  4. qemu_plugin_symbols = configure_file(
  5. input: files('../include/qemu/qemu-plugin.h'),
  6. output: 'qemu-plugin.symbols',
  7. capture: true,
  8. command: [files('../scripts/qemu-plugin-symbols.py'), '@INPUT@'])
  9. # Modules need more symbols than just those in plugins/qemu-plugins.symbols
  10. if not enable_modules
  11. if host_os == 'darwin'
  12. configure_file(
  13. input: qemu_plugin_symbols,
  14. output: 'qemu-plugins-ld64.symbols',
  15. capture: true,
  16. command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', '@INPUT@'])
  17. emulator_link_args += ['-Wl,-exported_symbols_list,plugins/qemu-plugins-ld64.symbols']
  18. elif host_os == 'windows' and meson.get_compiler('c').get_id() == 'clang'
  19. # LLVM/lld does not support exporting specific symbols. However, it works
  20. # out of the box with dllexport/dllimport attribute we set in the code.
  21. else
  22. emulator_link_args += ['-Xlinker', '--dynamic-list=' + qemu_plugin_symbols.full_path()]
  23. endif
  24. endif
  25. if host_os == 'windows'
  26. # Generate a .lib file for plugins to link against.
  27. # First, create a .def file listing all the symbols a plugin should expect to have
  28. # available in qemu
  29. win32_plugin_def = configure_file(
  30. input: qemu_plugin_symbols,
  31. output: 'qemu_plugin_api.def',
  32. capture: true,
  33. command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@'])
  34. # then use dlltool to assemble a delaylib.
  35. # The delaylib will have an "imaginary" name (qemu.exe), that is used by the
  36. # linker file we add with plugins (win32_linker.c) to identify that we want
  37. # to find missing symbols in current program.
  38. win32_qemu_plugin_api_link_flags = ['-Lplugins', '-lqemu_plugin_api']
  39. if meson.get_compiler('c').get_id() == 'clang'
  40. # With LLVM/lld, delaylib is specified at link time (-delayload)
  41. dlltool = find_program('llvm-dlltool', required: true)
  42. dlltool_cmd = [dlltool, '-d', '@INPUT@', '-l', '@OUTPUT@', '-D', 'qemu.exe']
  43. win32_qemu_plugin_api_link_flags += ['-Wl,-delayload=qemu.exe']
  44. else
  45. # With gcc/ld, delay lib is built with a specific delay parameter.
  46. dlltool = find_program('dlltool', required: true)
  47. dlltool_cmd = [dlltool, '--input-def', '@INPUT@',
  48. '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe']
  49. endif
  50. win32_qemu_plugin_api_lib = configure_file(
  51. input: win32_plugin_def,
  52. output: 'libqemu_plugin_api.a',
  53. command: dlltool_cmd
  54. )
  55. endif
  56. user_ss.add(files('user.c', 'api-user.c'))
  57. system_ss.add(files('system.c', 'api-system.c'))
  58. common_ss.add(files('loader.c', 'api.c', 'core.c'))