build/vulkan: split vulkan gir

also add to docs

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1506>
This commit is contained in:
Matthew Waters 2020-08-11 21:56:39 +10:00 committed by GStreamer Merge Bot
parent 314a8c023f
commit bc95b5d99a
19 changed files with 290 additions and 24 deletions

View file

@ -0,0 +1,6 @@
# Vulkan Wayland Library
This library should be linked to by getting cflags and libs from
gstreamer-vulkan-wayland-{{ gst_api_version.md }}
> NOTE: This library API is considered *unstable*

View file

@ -0,0 +1 @@
gi-index

View file

@ -0,0 +1,6 @@
# Vulkan XCB Library
This library should be linked to by getting cflags and libs from
gstreamer-vulkan-{{ gst_api_version.md }}
> NOTE: This library API is considered *unstable*

View file

@ -0,0 +1 @@
gi-index

View file

@ -0,0 +1,6 @@
# Vulkan Library
This library should be linked to by getting cflags and libs from
gstreamer-vulkan-{{ gst_api_version.md }}
> NOTE: This library API is considered *unstable*

View file

@ -0,0 +1 @@
gi-index

View file

@ -100,7 +100,8 @@ foreach f: [
'ext/*/*.h',
'sys/*/*.h',
'gst/*/*.h',
'gst-libs/gst/*/*-prelude.h'
'gst-libs/gst/*/*-prelude.h',
'gst-libs/gst/vulkan/vulkan_fwd.h'
]
excludes += [join_paths(meson.current_source_dir(), root_rel, f)]
endforeach
@ -119,7 +120,27 @@ if build_gir
{'name': 'audio', 'gir': audio_gir, 'lib': gstbadaudio_dep, 'prefix': 'bad-'},
{'name': 'transcoder', 'gir': transcoder_gir, 'lib': gst_transcoder_dep},
{'name': 'codecs', 'gir': codecs_gir, 'lib': gstcodecs_dep},
]
]
if gstvulkan_dep.found()
libs += [
{'name': 'vulkan', 'gir': vulkan_gir, 'lib': gstvulkan_dep, 'suffix': 'lib'},
]
if enabled_vulkan_winsys.contains('xcb')
libs += [
{'name': 'vulkan-xcb', 'gir': vulkan_xcb_gir, 'lib': gstvulkanxcb_dep, 'extra_sources' : [
join_paths(root_rel, 'gst-libs/gst/vulkan/xcb/gstvkdisplay_xcb.[ch]'),
]},
]
endif
if enabled_vulkan_winsys.contains('wayland')
libs += [
{'name': 'vulkan-wayland', 'gir': vulkan_wayland_gir, 'lib': gstvulkanwayland_dep, 'extra_sources' : [
join_paths(root_rel, 'gst-libs/gst/vulkan/wayland/gstvkdisplay_wayland.[ch]'),
]},
]
endif
endif
endif
has_gi_extension = hotdoc.has_extensions('gi-extension')
@ -128,12 +149,14 @@ libs_doc = []
foreach lib_def: libs
name = lib_def['name']
lib = lib_def['lib']
extra_sources = lib_def.get('extra_sources', [])
c_source_patterns = lib_def.get('c_source_patterns', ['*.[hc]'])
c_sources = []
foreach pattern: c_source_patterns
c_sources += join_paths(root_rel, 'gst-libs/gst', name, pattern)
endforeach
c_sources += extra_sources
if lib_def.has_key('gir')
if has_gi_extension

View file

@ -1,5 +1,7 @@
gstvulkan_dep = dependency('', required: false)
gstvulkanxcb_dep = dependency('', required: false)
gstvulkanwyland_dep = dependency('', required: false)
if get_option('vulkan').disabled()
gstvulkan_dep = dependency('', required: false)
subdir_done()
endif
@ -70,7 +72,10 @@ vulkan_headers = [
'vulkan.h',
]
vulkan_priv_sources = []
vulkan_xcb_sources = []
vulkan_xcb_headers = []
vulkan_wayland_sources = []
vulkan_wayland_headers = []
vulkan_windowing = false
@ -80,6 +85,7 @@ optional_deps = []
has_vulkan_header = false
vulkan_dep = dependency('', required: false)
vulkan_inc_dir = ''
enabled_vulkan_winsys = []
vulkan_conf = configuration_data()
vulkan_conf_options = [
@ -148,34 +154,43 @@ xkbcommon_dep = dependency('xkbcommon', required : get_option('x11'))
xkbcommon_x11_dep = dependency('xkbcommon-x11', required : get_option('x11'))
if xcb_dep.found() and xkbcommon_dep.found() and xkbcommon_x11_dep.found() and cc.has_header('vulkan/vulkan_xcb.h', dependencies : vulkan_dep)
vulkan_sources += [
'xcb/gstvkdisplay_xcb.c',
vulkan_priv_sources += [
'xcb/gstvkwindow_xcb.c',
'xcb/xcb_event_source.c',
]
vulkan_xcb_sources += [
'xcb/gstvkdisplay_xcb.c',
]
vulkan_xcb_headers += [
'xcb/xcb.h',
'xcb/gstvkdisplay_xcb.h'
]
optional_deps += [xcb_dep, xkbcommon_dep, xkbcommon_x11_dep]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_XCB', 1)
enabled_vulkan_winsys += ['xcb']
endif
wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland'))
if wayland_client_dep.found() and cc.has_header('vulkan/vulkan_wayland.h', dependencies : vulkan_dep)
vulkan_sources += [
vulkan_priv_sources += [
'wayland/gstvkdisplay_wayland.c',
'wayland/gstvkwindow_wayland.c',
'wayland/wayland_event_source.c',
]
vulkan_wayland_sources += [
'wayland/gstvkdisplay_wayland.c',
]
vulkan_wayland_headers += [
'wayland/wayland.h',
'wayland/gstvkdisplay_wayland.h'
]
optional_deps += wayland_client_dep
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WAYLAND', 1)
enabled_vulkan_winsys += ['wayland']
endif
if ['darwin', 'ios'].contains(host_system)
@ -198,13 +213,14 @@ if host_system == 'darwin'
cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan'))
if cocoa_dep.found() and cc.has_header('vulkan/vulkan_macos.h', dependencies : vulkan_dep)
vulkan_sources += [
vulkan_priv_sources += [
'cocoa/gstvkdisplay_cocoa.m',
'cocoa/gstvkwindow_cocoa.m',
]
optional_deps += [cocoa_dep]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_COCOA', 1)
enabled_vulkan_winsys += ['cocoa']
endif
endif
@ -212,13 +228,14 @@ if host_system == 'ios'
uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan'))
if uikit_dep.found() and cc.has_header('vulkan/vulkan_ios.h', dependencies : vulkan_dep)
vulkan_sources += [
vulkan_priv_sources += [
'ios/gstvkdisplay_ios.m',
'ios/gstvkwindow_ios.m',
]
optional_deps += [uikit_dep]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_IOS', 1)
enabled_vulkan_winsys += ['ios']
endif
endif
@ -227,21 +244,23 @@ if host_system == 'windows'
# 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)
vulkan_sources += ['win32/gstvkwindow_win32.c']
vulkan_priv_sources += ['win32/gstvkwindow_win32.c']
optional_deps += [gdi_dep]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WIN32', 1)
enabled_vulkan_winsys += ['win32']
endif
endif
if host_system == 'android'
if cc.has_header('vulkan/vulkan_android.h', dependencies : vulkan_dep)
vulkan_sources += [
vulkan_priv_sources += [
'android/gstvkdisplay_android.c',
'android/gstvkwindow_android.c',
]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_ANDROID', 1)
enabled_vulkan_winsys += ['android']
endif
endif
@ -257,7 +276,6 @@ if not vulkan_dep.found() or not has_vulkan_header or not glslc.found()
if get_option('vulkan').enabled()
error('GStreamer Vulkan integration required via options, but needed dependencies not found.')
else
gstvulkan_dep = dependency('', required : false)
subdir_done()
endif
endif
@ -265,27 +283,30 @@ endif
gen_sources = []
install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan')
install_headers(vulkan_xcb_headers, subdir : 'gstreamer-1.0/gst/vulkan/xcb')
install_headers(vulkan_wayland_headers, subdir : 'gstreamer-1.0/gst/vulkan/wayland')
configure_file(input : 'gstvkconfig.h.meson',
output : 'gstvkconfig.h',
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'),
configuration : vulkan_conf)
vulkan_enums = gnome.mkenums_simple('vulkan-enumtypes',
sources : vulkan_headers,
body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
header_prefix : '#include <gst/vulkan/vulkan-prelude.h>',
decorator : 'GST_VULKAN_API',
install_header: true,
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'))
vulkan_enumtypes_c = vulkan_enums[0]
vulkan_enumtypes_h = vulkan_enums[1]
glib_mkenums = find_program('glib-mkenums')
mkenums = find_program('vulkan_mkenum.py')
vulkan_enumtypes_h = custom_target('gstvulkanenum_h',
output : 'vulkan-enumtypes.h',
input : vulkan_headers,
install : true,
install_dir : join_paths(get_option('includedir'), 'include/gstreamer-1.0/gst/vulkan/'),
command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
vulkan_enumtypes_c = custom_target('gstvulkanenum_c',
output : 'vulkan-enumtypes.c',
input : vulkan_headers,
depends : [vulkan_enumtypes_h],
command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
gen_sources += [vulkan_enumtypes_h]
gstvulkan = library('gstvulkan-' + api_version,
vulkan_sources, vulkan_enumtypes_c, vulkan_enumtypes_h,
vulkan_sources, vulkan_priv_sources, vulkan_wayland_sources, vulkan_xcb_sources, vulkan_enumtypes_c, vulkan_enumtypes_h,
c_args : gst_plugins_bad_args + vulkan_defines + ['-DBUILDING_GST_VULKAN'],
objc_args : gst_plugins_bad_args + vulkan_defines + vulkan_objc_args + ['-DBUILDING_GST_VULKAN'],
include_directories : [configinc, libsinc],
@ -293,7 +314,9 @@ gstvulkan = library('gstvulkan-' + api_version,
soversion : soversion,
darwin_versions : osxversion,
install : true,
dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps)
dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps,
# don't confuse gst/vulkan/xcb/xcb.h with xcb/xcb.h
implicit_include_directories : false)
if build_gir
extra_gir_includes = []
@ -322,3 +345,45 @@ gstvulkan_dep = declare_dependency(link_with : gstvulkan,
include_directories : [libsinc],
sources: gen_sources,
dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps)
if enabled_vulkan_winsys.contains('xcb')
install_headers(vulkan_xcb_headers, subdir : 'gstreamer-1.0/gst/vulkan/xcb')
vulkan_xcb_gir = []
if build_gir
vulkan_xcb_gir = gnome.generate_gir(gstvulkan,
sources : vulkan_xcb_sources + vulkan_xcb_headers,
namespace : 'GstVulkanXCB',
nsversion : api_version,
identifier_prefix : 'Gst',
symbol_prefix : 'gst',
export_packages : 'gstreamer-vulkan-xcb-1.0',
includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', vulkan_gir[0]] + extra_gir_includes,
install : true,
extra_args : gir_init_section + ['--c-include=gst/vulkan/xcb/xcb.h'],
dependencies : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
)
endif
gstvulkanxcb_dep = declare_dependency(dependencies : [gstvulkan_dep],
sources : vulkan_xcb_gir)
endif
if enabled_vulkan_winsys.contains('wayland')
install_headers(vulkan_wayland_headers, subdir : 'gstreamer-1.0/gst/vulkan/wayland')
vulkan_wayland_gir = []
if build_gir
vulkan_wayland_gir = gnome.generate_gir(gstvulkan,
sources : vulkan_wayland_sources + vulkan_wayland_headers,
namespace : 'GstVulkanWayland',
nsversion : api_version,
identifier_prefix : 'Gst',
symbol_prefix : 'gst',
export_packages : 'gstreamer-vulkan-wayland-1.0',
includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', vulkan_gir[0]] + extra_gir_includes,
install : true,
extra_args : gir_init_section + ['--c-include=gst/vulkan/wayland/wayland.h'],
dependencies : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
)
endif
gstvulkanwayland_dep = declare_dependency(dependencies : [gstvulkan_dep],
sources : vulkan_wayland_gir)
endif

View file

@ -22,6 +22,7 @@
#define __GST_VULKAN_FWD_H__
#include <gst/gst.h>
#include <gst/vulkan/vulkan-prelude.h>
G_BEGIN_DECLS

View file

@ -0,0 +1,55 @@
#!/usr/bin/env python3
# This is in its own file rather than inside meson.build
# because a) mixing the two is ugly and b) trying to
# make special characters such as \n go through all
# backends is a fool's errand.
import sys, subprocess
h_array = ['--fhead',
"#pragma once\n\n#include <gst/gst.h>\n#include <gst/vulkan/vulkan_fwd.h>\nG_BEGIN_DECLS\n",
'--fprod',
"\n/* enumerations from \"@basename@\" */\n",
'--vhead',
"GST_VULKAN_API\nGType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n",
'--ftail',
"G_END_DECLS"
]
c_array = ['--fhead',
"#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#include \"vulkan-enumtypes.h\"\n\n#include <gst/vulkan/vulkan.h>\n\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)",
'--fprod',
"\n/* enumerations from \"@basename@\" */",
'--vhead',
"GType\n@enum_name@_get_type (void)\n{\n static volatile gsize g_define_type_id__volatile = 0;\n if (g_once_init_enter (&g_define_type_id__volatile)) {\n static const G@Type@Value values[] = {",
'--vprod',
" { C_@TYPE@ (@VALUENAME@), \"@VALUENAME@\", \"@valuenick@\" },",
'--vtail',
" { 0, NULL, NULL }\n };\n GType g_define_type_id = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);\n }\n return g_define_type_id__volatile;\n}\n"
]
cmd = []
argn = 1
# Find the full command needed to run glib-mkenums
# On UNIX-like, this is just the full path to glib-mkenums
# On Windows, this is the full path to interpreter + full path to glib-mkenums
for arg in sys.argv[1:]:
cmd.append(arg)
argn += 1
if arg.endswith('glib-mkenums'):
break
ofilename = sys.argv[argn]
headers = sys.argv[argn + 1:]
if ofilename.endswith('.h'):
arg_array = h_array
else:
arg_array = c_array
cmd_array = cmd + arg_array + headers
pc = subprocess.Popen(cmd_array, stdout=subprocess.PIPE)
(stdo, _) = pc.communicate()
if pc.returncode != 0:
sys.exit(pc.returncode)
open(ofilename, 'wb').write(stdo)

View file

@ -0,0 +1,27 @@
/*
* GStreamer
* Copyright (C) 2020 Matthew Waters <matthew@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_VULKAN_WAYLAND_H__
#define __GST_VULKAN_WAYLAND_H__
#include <gst/vulkan/vulkan.h>
#include <gst/vulkan/wayland/gstvkdisplay_wayland.h>
#endif /* __GST_VULKAN_WAYLAND_H__ */

View file

@ -0,0 +1,27 @@
/*
* GStreamer
* Copyright (C) 2020 Matthew Waters <matthew@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_VULKAN_XCB_H__
#define __GST_VULKAN_XCB_H__
#include <gst/vulkan/vulkan.h>
#include <gst/vulkan/xcb/gstvkdisplay_xcb.h>
#endif /* __GST_VULKAN_XCB_H__ */

View file

@ -2,6 +2,8 @@ prefix=
exec_prefix=
libdir=@vulkanlibdir@
includedir=@abs_top_srcdir@/gst-libs
vulkan_winsys=@VULKAN_WINSYS@
Name: GStreamer Vulkan, Uninstalled
Description: GStreamer Vulkan support, uninstalled

View file

@ -0,0 +1,9 @@
prefix=
exec_prefix=
libdir=@vulkanlibdir@
includedir=@abs_top_srcdir@/gst-libs
Name: GStreamer Vulkan (Wayland Specifics), Uninstalled
Description: GStreamer Vulkan support (Wayland Specifics), uninstalled
Requires: gstreamer-vulkan-@GST_API_VERSION@ wayland-client
Version: @VERSION@

View file

@ -0,0 +1,9 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/gstreamer-@GST_API_VERSION@
Name: GStreamer Vulkan (Wayland Specifics)
Description: GStreamer Vulkan support (Wayland Specifics)
Requires: gstreamer-vulkan-@GST_API_VERSION@ wayland-client
Version: @VERSION@

View file

@ -0,0 +1,9 @@
prefix=
exec_prefix=
libdir=@vulkanlibdir@
includedir=@abs_top_srcdir@/gst-libs
Name: GStreamer Vulkan (XCB Specifics), Uninstalled
Description: GStreamer Vulkan support (XCB Specifics), uninstalled
Requires: gstreamer-vulkan-@GST_API_VERSION@ xcb
Version: @VERSION@

View file

@ -0,0 +1,9 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/gstreamer-@GST_API_VERSION@
Name: GStreamer Vulkan (XCB Specifics)
Description: GStreamer Vulkan support (XCB Specifics)
Requires: gstreamer-vulkan-@GST_API_VERSION@ xcb
Version: @VERSION@

View file

@ -2,6 +2,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/gstreamer-@GST_API_VERSION@
vulkan_winsys=@VULKAN_WINSYS@
Name: GStreamer Vulkan
Description: GStreamer Vulkan support

View file

@ -42,7 +42,15 @@ pkg_libs = [
if gstvulkan_dep.found()
pkgconf.set('vulkanlibdir', join_paths(meson.build_root(), gstvulkan.outdir()))
pkgconf.set('VULKAN_WINSYS', ' '.join(enabled_vulkan_winsys))
pkg_libs += 'vulkan'
if enabled_vulkan_winsys.contains('xcb')
pkg_libs += 'vulkan-xcb'
endif
if enabled_vulkan_winsys.contains('wayland')
pkg_libs += 'vulkan-wayland'
endif
endif
foreach p : pkg_libs