瀏覽代碼

net/vmnet: add vmnet dependency and customizable option

vmnet.framework dependency is added with 'vmnet' option
to enable or disable it. Default value is 'auto'.

used vmnet features are available since macOS 11.0,
but new backend can be built and work properly with
subset of them on 10.15 too.

Signed-off-by: Vladislav Yaroshchuk <Vladislav.Yaroshchuk@jetbrains.com>
Message-Id: <20220317172839.28984-2-Vladislav.Yaroshchuk@jetbrains.com>
Vladislav Yaroshchuk 3 年之前
父節點
當前提交
d1792ff228
共有 3 個文件被更改,包括 18 次插入1 次删除
  1. 15 1
      meson.build
  2. 2 0
      meson_options.txt
  3. 1 0
      scripts/meson-buildoptions.sh

+ 15 - 1
meson.build

@@ -525,6 +525,18 @@ if cocoa.found() and get_option('gtk').enabled()
   error('Cocoa and GTK+ cannot be enabled at the same time')
   error('Cocoa and GTK+ cannot be enabled at the same time')
 endif
 endif
 
 
+vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet'))
+if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h',
+                                              'VMNET_BRIDGED_MODE',
+                                              dependencies: vmnet)
+  vmnet = not_found
+  if get_option('vmnet').enabled()
+    error('vmnet.framework API is outdated')
+  else
+    warning('vmnet.framework API is outdated, disabling')
+  endif
+endif
+
 seccomp = not_found
 seccomp = not_found
 if not get_option('seccomp').auto() or have_system or have_tools
 if not get_option('seccomp').auto() or have_system or have_tools
   seccomp = dependency('libseccomp', version: '>=2.3.0',
   seccomp = dependency('libseccomp', version: '>=2.3.0',
@@ -1553,6 +1565,7 @@ config_host_data.set('CONFIG_SNAPPY', snappy.found())
 config_host_data.set('CONFIG_TPM', have_tpm)
 config_host_data.set('CONFIG_TPM', have_tpm)
 config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
 config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
 config_host_data.set('CONFIG_VDE', vde.found())
 config_host_data.set('CONFIG_VDE', vde.found())
+config_host_data.set('CONFIG_VMNET', vmnet.found())
 config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
 config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
 config_host_data.set('CONFIG_VNC', vnc.found())
 config_host_data.set('CONFIG_VNC', vnc.found())
 config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
 config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
@@ -3604,7 +3617,8 @@ summary(summary_info, bool_yn: true, section: 'Crypto')
 # Libraries
 # Libraries
 summary_info = {}
 summary_info = {}
 if targetos == 'darwin'
 if targetos == 'darwin'
-  summary_info += {'Cocoa support':   cocoa}
+  summary_info += {'Cocoa support':           cocoa}
+  summary_info += {'vmnet.framework support': vmnet}
 endif
 endif
 summary_info += {'SDL support':       sdl}
 summary_info += {'SDL support':       sdl}
 summary_info += {'SDL image support': sdl_image}
 summary_info += {'SDL image support': sdl_image}

+ 2 - 0
meson_options.txt

@@ -175,6 +175,8 @@ option('netmap', type : 'feature', value : 'auto',
        description: 'netmap network backend support')
        description: 'netmap network backend support')
 option('vde', type : 'feature', value : 'auto',
 option('vde', type : 'feature', value : 'auto',
        description: 'vde network backend support')
        description: 'vde network backend support')
+option('vmnet', type : 'feature', value : 'auto',
+       description: 'vmnet.framework network backend support')
 option('virglrenderer', type : 'feature', value : 'auto',
 option('virglrenderer', type : 'feature', value : 'auto',
        description: 'virgl rendering support')
        description: 'virgl rendering support')
 option('vnc', type : 'feature', value : 'auto',
 option('vnc', type : 'feature', value : 'auto',

+ 1 - 0
scripts/meson-buildoptions.sh

@@ -116,6 +116,7 @@ meson_options_help() {
   printf "%s\n" '  usb-redir       libusbredir support'
   printf "%s\n" '  usb-redir       libusbredir support'
   printf "%s\n" '  vde             vde network backend support'
   printf "%s\n" '  vde             vde network backend support'
   printf "%s\n" '  vdi             vdi image format support'
   printf "%s\n" '  vdi             vdi image format support'
+  printf "%s\n" '  vmnet           vmnet.framework network backend support'
   printf "%s\n" '  vhost-user-blk-server'
   printf "%s\n" '  vhost-user-blk-server'
   printf "%s\n" '                  build vhost-user-blk server'
   printf "%s\n" '                  build vhost-user-blk server'
   printf "%s\n" '  virglrenderer   virgl rendering support'
   printf "%s\n" '  virglrenderer   virgl rendering support'