meson: Fix automagic dependency checks in gstvulkan

Windowing, in particular, was getting silently disabled.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7091>
This commit is contained in:
Nirbheek Chauhan 2024-06-23 03:46:39 +05:30
parent 6073257bd8
commit 54a6643986
2 changed files with 94 additions and 91 deletions

View File

@ -1,7 +1,9 @@
gstvulkan_dep = dependency('', required: false) gstvulkan_dep = dependency('', required: false)
gstvulkanxcb_dep = dependency('', required: false) gstvulkanxcb_dep = dependency('', required: false)
gstvulkanwyland_dep = dependency('', required: false) gstvulkanwyland_dep = dependency('', required: false)
if get_option('vulkan').disabled() vulkan_windowing_opt = get_option('vulkan-windowing')
vulkan_opt = get_option('vulkan')
if vulkan_opt.disabled()
subdir_done() subdir_done()
endif endif
@ -115,7 +117,7 @@ if ['ios', 'darwin'].contains(host_system)
# retrieving the metal device from the VkDevice) which is currently waiting # retrieving the metal device from the VkDevice) which is currently waiting
# on implementing a proper Metal extension for Vulkan # on implementing a proper Metal extension for Vulkan
# https://github.com/KhronosGroup/MoltenVK/issues/492 # https://github.com/KhronosGroup/MoltenVK/issues/492
vulkan_dep = cc.find_library('MoltenVK', required : get_option('vulkan')) vulkan_dep = cc.find_library('MoltenVK', required : vulkan_opt)
endif endif
elif host_system == 'windows' elif host_system == 'windows'
vulkan_root = run_command(python3, '-c', 'import os; print(os.environ.get("VK_SDK_PATH"))', check: false).stdout().strip() vulkan_root = run_command(python3, '-c', 'import os; print(os.environ.get("VK_SDK_PATH"))', check: false).stdout().strip()
@ -128,11 +130,12 @@ elif host_system == 'windows'
endif endif
vulkan_lib = cc.find_library('vulkan-1', dirs: vulkan_lib_dir, vulkan_lib = cc.find_library('vulkan-1', dirs: vulkan_lib_dir,
required : get_option('vulkan')) required : vulkan_opt)
vulkan_inc_dir = join_paths(vulkan_root, 'Include') vulkan_inc_dir = join_paths(vulkan_root, 'Include')
has_vulkan_header = cc.has_header('vulkan/vulkan_core.h', has_vulkan_header = cc.has_header('vulkan/vulkan_core.h',
args: '-I' + vulkan_inc_dir) args: '-I' + vulkan_inc_dir,
required: vulkan_opt)
if vulkan_lib.found() and has_vulkan_header if vulkan_lib.found() and has_vulkan_header
vulkan_dep = declare_dependency(include_directories: include_directories(vulkan_inc_dir), vulkan_dep = declare_dependency(include_directories: include_directories(vulkan_inc_dir),
@ -140,85 +143,87 @@ elif host_system == 'windows'
endif endif
endif endif
else else
vulkan_dep = dependency('vulkan', method: 'pkg-config', required : false) vulkan_dep = dependency('vulkan', method: 'pkg-config', required: false)
if not vulkan_dep.found() if not vulkan_dep.found()
vulkan_dep = cc.find_library('vulkan', required : false) vulkan_dep = cc.find_library('vulkan', required: vulkan_opt)
endif endif
endif endif
if host_system != 'windows' if host_system != 'windows'
has_vulkan_header = cc.has_header('vulkan/vulkan_core.h', dependencies: vulkan_dep) has_vulkan_header = cc.has_header('vulkan/vulkan_core.h', dependencies: vulkan_dep, required: vulkan_opt)
endif endif
if not has_vulkan_header and get_option('vulkan').enabled() if 'x11' in vulkan_windowing_opt or 'auto' in vulkan_windowing_opt
error('vulkan plugin enabled, but vulkan.h not found') vulkan_xcb_required = vulkan_opt.enabled() and 'x11' in vulkan_windowing_opt
endif xcb_dep = dependency('xcb', version : '>=1.10', required: vulkan_xcb_required)
if not vulkan_dep.found() and get_option('vulkan').enabled() xkbcommon_dep = dependency('xkbcommon', required: vulkan_xcb_required)
error('vulkan plugin enabled, but could not find vulkan library') xkbcommon_x11_dep = dependency('xkbcommon-x11', required: vulkan_xcb_required)
if xcb_dep.found() and xkbcommon_dep.found() and xkbcommon_x11_dep.found() and \
cc.has_header('vulkan/vulkan_xcb.h', dependencies : vulkan_dep, required: vulkan_xcb_required)
vulkan_priv_sources += files(
'xcb/gstvkwindow_xcb.c',
'xcb/xcb_event_source.c',
)
vulkan_xcb_sources += files(
'xcb/gstvkdisplay_xcb.c',
)
vulkan_xcb_headers += files(
'xcb/xcb.h',
'xcb/gstvkdisplay_xcb.h'
)
optional_deps += [xcb_dep, xkbcommon_dep, xkbcommon_x11_dep]
vulkan_windowing = true
vulkan_conf.set('GST_VULKAN_HAVE_WINDOW_XCB', 1)
enabled_vulkan_winsys += ['xcb']
endif
endif endif
xcb_dep = dependency('xcb', version : '>=1.10', required : get_option('x11')) if 'wayland' in vulkan_windowing_opt or 'auto' in vulkan_windowing_opt
xkbcommon_dep = dependency('xkbcommon', required : get_option('x11')) vulkan_wayland_required = vulkan_opt.enabled() and 'wayland' in vulkan_windowing_opt
xkbcommon_x11_dep = dependency('xkbcommon-x11', required : get_option('x11')) wayland_client_dep = dependency('wayland-client', version : '>=1.4', required: vulkan_wayland_required)
wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required: vulkan_wayland_required)
wayland_scanner = find_program('wayland-scanner', required: vulkan_wayland_required)
if xcb_dep.found() and xkbcommon_dep.found() and xkbcommon_x11_dep.found() and cc.has_header('vulkan/vulkan_xcb.h', dependencies : vulkan_dep) if wayland_client_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found() and \
vulkan_priv_sources += files( cc.has_header('vulkan/vulkan_wayland.h', dependencies: vulkan_dep, required: vulkan_wayland_required)
'xcb/gstvkwindow_xcb.c', # Generate the XDG shell interface
'xcb/xcb_event_source.c', wayland_protocols_basedir = wayland_protocols_dep.get_variable('pkgdatadir')
) xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
vulkan_xcb_sources += files( xdg_shell_header = custom_target('xdg-shell-client-header',
'xcb/gstvkdisplay_xcb.c', command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
) input: xdg_shell_xml_spec,
vulkan_xcb_headers += files( output: 'xdg-shell-client-protocol.h',
'xcb/xcb.h', )
'xcb/gstvkdisplay_xcb.h' xdg_shell_code = custom_target('xdg-shell-client-code',
) command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
input: xdg_shell_xml_spec,
output: 'xdg-shell-client-protocol.c',
)
optional_deps += [xcb_dep, xkbcommon_dep, xkbcommon_x11_dep] vulkan_priv_sources += files(
vulkan_windowing = true 'wayland/gstvkdisplay_wayland.c',
vulkan_conf.set('GST_VULKAN_HAVE_WINDOW_XCB', 1) 'wayland/gstvkwindow_wayland.c',
enabled_vulkan_winsys += ['xcb'] 'wayland/wayland_event_source.c',
endif )
vulkan_priv_sources += [
xdg_shell_header,
xdg_shell_code,
]
vulkan_wayland_sources += files(
'wayland/gstvkdisplay_wayland.c',
)
vulkan_wayland_headers += files(
'wayland/wayland.h',
'wayland/gstvkdisplay_wayland.h'
)
wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland')) optional_deps += wayland_client_dep
wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : get_option('wayland')) vulkan_windowing = true
wayland_scanner = find_program('wayland-scanner', required: get_option('wayland')) vulkan_conf.set('GST_VULKAN_HAVE_WINDOW_WAYLAND', 1)
if wayland_client_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found() and cc.has_header('vulkan/vulkan_wayland.h', dependencies : vulkan_dep) enabled_vulkan_winsys += ['wayland']
# Generate the XDG shell interface endif
wayland_protocols_basedir = wayland_protocols_dep.get_variable('pkgdatadir')
xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
xdg_shell_header = custom_target('xdg-shell-client-header',
command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
input: xdg_shell_xml_spec,
output: 'xdg-shell-client-protocol.h',
)
xdg_shell_code = custom_target('xdg-shell-client-code',
command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
input: xdg_shell_xml_spec,
output: 'xdg-shell-client-protocol.c',
)
vulkan_priv_sources += files(
'wayland/gstvkdisplay_wayland.c',
'wayland/gstvkwindow_wayland.c',
'wayland/wayland_event_source.c',
)
vulkan_priv_sources += [
xdg_shell_header,
xdg_shell_code,
]
vulkan_wayland_sources += files(
'wayland/gstvkdisplay_wayland.c',
)
vulkan_wayland_headers += files(
'wayland/wayland.h',
'wayland/gstvkdisplay_wayland.h'
)
optional_deps += wayland_client_dep
vulkan_windowing = true
vulkan_conf.set('GST_VULKAN_HAVE_WINDOW_WAYLAND', 1)
enabled_vulkan_winsys += ['wayland']
endif endif
if ['darwin', 'ios'].contains(host_system) if ['darwin', 'ios'].contains(host_system)
@ -229,18 +234,18 @@ if ['darwin', 'ios'].contains(host_system)
vulkan_objc_args += ['-fobjc-arc'] vulkan_objc_args += ['-fobjc-arc']
foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : get_option('vulkan')) foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : vulkan_opt)
quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : get_option('vulkan')) quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : vulkan_opt)
corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : get_option('vulkan')) corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : vulkan_opt)
if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found() if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
optional_deps += [foundation_dep, corefoundation_dep, quartzcore_dep] optional_deps += [foundation_dep, corefoundation_dep, quartzcore_dep]
endif endif
endif endif
if host_system == 'darwin' if host_system == 'darwin'
cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan')) cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : vulkan_opt)
if cocoa_dep.found() and cc.has_header('vulkan/vulkan_macos.h', dependencies : vulkan_dep) if cocoa_dep.found() and cc.has_header('vulkan/vulkan_macos.h', dependencies: vulkan_dep, required: vulkan_opt)
vulkan_priv_sources += files( vulkan_priv_sources += files(
'cocoa/gstvkdisplay_cocoa.m', 'cocoa/gstvkdisplay_cocoa.m',
'cocoa/gstvkwindow_cocoa.m', 'cocoa/gstvkwindow_cocoa.m',
@ -253,9 +258,9 @@ if host_system == 'darwin'
endif endif
if host_system == 'ios' if host_system == 'ios'
uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan')) uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : vulkan_opt)
if uikit_dep.found() and cc.has_header('vulkan/vulkan_ios.h', dependencies : vulkan_dep) if uikit_dep.found() and cc.has_header('vulkan/vulkan_ios.h', dependencies : vulkan_dep, required: vulkan_opt)
vulkan_priv_sources += files( vulkan_priv_sources += files(
'ios/gstvkdisplay_ios.m', 'ios/gstvkdisplay_ios.m',
'ios/gstvkwindow_ios.m', 'ios/gstvkwindow_ios.m',
@ -268,10 +273,10 @@ if host_system == 'ios'
endif endif
if host_system == 'windows' if host_system == 'windows'
gdi_dep = cc.find_library('gdi32', required : get_option('vulkan')) gdi_dep = cc.find_library('gdi32', required : vulkan_opt)
# Cannot use internal dependency object with cc.has_header() # Cannot use internal dependency object with cc.has_header()
if gdi_dep.found() and cc.has_header('vulkan/vulkan_win32.h', args: '-I' + vulkan_inc_dir) if gdi_dep.found() and cc.has_header('vulkan/vulkan_win32.h', args: '-I' + vulkan_inc_dir, required: vulkan_opt)
vulkan_priv_sources += ['win32/gstvkwindow_win32.c'] vulkan_priv_sources += ['win32/gstvkwindow_win32.c']
optional_deps += [gdi_dep] optional_deps += [gdi_dep]
vulkan_windowing = true vulkan_windowing = true
@ -281,7 +286,7 @@ if host_system == 'windows'
endif endif
if host_system == 'android' if host_system == 'android'
if cc.has_header('vulkan/vulkan_android.h', dependencies : vulkan_dep) if cc.has_header('vulkan/vulkan_android.h', dependencies : vulkan_dep, required: vulkan_opt)
vulkan_priv_sources += files( vulkan_priv_sources += files(
'android/gstvkdisplay_android.c', 'android/gstvkdisplay_android.c',
'android/gstvkwindow_android.c', 'android/gstvkwindow_android.c',
@ -293,7 +298,7 @@ if host_system == 'android'
endif endif
if not vulkan_windowing if not vulkan_windowing
if get_option('vulkan').enabled() if vulkan_opt.enabled()
error('No Windowing system found. vulkansink will not work') error('No Windowing system found. vulkansink will not work')
else else
message('No Windowing system found. vulkansink will not work') message('No Windowing system found. vulkansink will not work')
@ -301,11 +306,7 @@ if not vulkan_windowing
endif endif
if not vulkan_dep.found() or not has_vulkan_header if not vulkan_dep.found() or not has_vulkan_header
if get_option('vulkan').enabled() subdir_done()
error('GStreamer Vulkan integration required via options, but needed dependencies not found.')
else
subdir_done()
endif
endif endif
if get_option('vulkan-video').allowed() if get_option('vulkan-video').allowed()

View File

@ -179,7 +179,6 @@ option('uvch264', type : 'feature', value : 'auto', description : 'UVC compliant
option('va', type : 'feature', value : 'auto', description: 'VA-API new plugin') option('va', type : 'feature', value : 'auto', description: 'VA-API new plugin')
option('voaacenc', type : 'feature', value : 'auto', description : 'AAC audio encoder plugin') option('voaacenc', type : 'feature', value : 'auto', description : 'AAC audio encoder plugin')
option('voamrwbenc', type : 'feature', value : 'auto', description : 'AMR-WB audio encoder plugin') option('voamrwbenc', type : 'feature', value : 'auto', description : 'AMR-WB audio encoder plugin')
option('vulkan', type : 'feature', value : 'auto', description : 'Vulkan video sink plugin')
option('wasapi', type : 'feature', value : 'auto', description : 'Windows Audio Session API source/sink plugin') option('wasapi', type : 'feature', value : 'auto', description : 'Windows Audio Session API source/sink plugin')
option('wasapi2', type : 'feature', value : 'auto', description : 'Windows Audio Session API source/sink plugin with WinRT API') option('wasapi2', type : 'feature', value : 'auto', description : 'Windows Audio Session API source/sink plugin with WinRT API')
option('webview2', type : 'feature', value : 'auto', description : 'WebView2 plugin') option('webview2', type : 'feature', value : 'auto', description : 'WebView2 plugin')
@ -250,9 +249,12 @@ option('nvcomp-sdk-path', type: 'string', value : '',
option('mfx-modules-dir', type: 'string', value : '', option('mfx-modules-dir', type: 'string', value : '',
description : 'libmfx runtime module dir, linux only') description : 'libmfx runtime module dir, linux only')
# Vulkan plugin options # Vulkan integration library and plugin options
option('vulkan-video', type: 'feature', value: 'auto', option('vulkan', type: 'feature', value: 'auto', description: 'Vulkan integration library and video sink plugin')
description: 'Whether to use Vulkan Video Extensions') option('vulkan-video', type: 'feature', value: 'auto', description: 'Whether to use Vulkan Video Extensions for encoding/decoding')
option('vulkan-windowing', type : 'array',
choices : ['x11', 'wayland', 'auto'], value : ['auto'],
description : 'A comma separated list of Vulkan windowing systems to enable. Non-Linux platforms are auto-detected.')
# License-related feature options # License-related feature options
option('gpl', type: 'feature', value: 'disabled', yield: true, option('gpl', type: 'feature', value: 'disabled', yield: true,