gstreamer-full: add full static support

Allow a project to use gstreamer-full as a static library
and link to create a binary without dependencies.

Introduce the option 'gst-full-target-type' to
select the build type, dynamic(default) or static.

In gstreamer-full/static build configuration gstreamer (gst.c)
needs the symbol gst_init_static_plugins which is defined
in gstreamer-full.
All the tests and examples are linking with gstreamer but the
symbol gst_init_static_plugins is only defined in the gstreamer-full
library. gstreamer-full can not be built first as it needs to know what plugins
will be built.

One option would be to build all the examples and tests after
gstreamer-full as the tools.

Disable tools build in subprojects too as it will be built at the end of
build process.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4128>
This commit is contained in:
Stéphane Cerveau 2023-03-07 14:05:54 +01:00 committed by GStreamer Marge Bot
parent 98c5ceb73f
commit dd17beb681
28 changed files with 147 additions and 70 deletions

View file

@ -85,15 +85,16 @@ if not meson.is_subproject() and cc.get_id() == 'msvc'
endif
building_full = get_option('default_library') == 'static'
tools_option = []
if building_full and not get_option('tools').disabled()
# Do not build subprojects tools when we build them against gst-full
tools_option = ['tools=disabled']
building_full_static = get_option('gst-full-target-type') == 'static_library'
buildind_full_options = []
if building_full
buildind_full_options = ['gstreamer-full=enabled']
endif
# Ordered list of subprojects (dict has no ordering guarantees)
subprojects = [
['gstreamer', {'build-hotdoc': true, 'subproject_options': tools_option}],
['gstreamer', {'build-hotdoc': true, 'subproject_options': buildind_full_options}],
['gst-plugins-base', {'option': get_option('base'), 'build-hotdoc': true}],
['gst-plugins-good', {'option': get_option('good'), 'build-hotdoc': true}],
['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
@ -101,9 +102,9 @@ subprojects = [
['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true}],
['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true}],
['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true}],
['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true, 'subproject_options': tools_option}],
['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true}],
['gst-integration-testsuites', { 'option': get_option('devtools') }],
['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true, 'subproject_options': tools_option}],
['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true}],
['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true}],
['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true}],
['gstreamer-sharp', { 'option': get_option('sharp') }],
@ -421,17 +422,17 @@ if building_full
giomodules_deps += dependency(module)
endforeach
# Build both shared and static library
gstfull = both_libraries('gstreamer-full-1.0',
# Build shared library
gstfull = build_target('gstreamer-full-1.0',
init_static_plugins_c,
target_type: get_option('gst-full-target-type'),
link_args: gstfull_link_args,
link_whole : exposed_libs,
dependencies : [incdir_deps, glib_deps, all_plugins, giomodules_deps],
link_depends : link_deps,
install : true,
)
gst_full_dep = declare_dependency(link_with: gstfull.get_shared_lib(),
gst_full_dep = declare_dependency(link_with: gstfull,
dependencies : incdir_deps + glib_deps,
include_directories: include_directories('.')
)
@ -441,7 +442,12 @@ if building_full
warning('The compiler does not support `-Wl,--undefined` linker flag. The method `gst_init_static_plugins` might be dropped during the link stage of an application using libgstreamer-full-1.0.a, preventing plugins registration.')
endif
if not get_option('introspection').disabled()
if building_full_static
warning('Introspection is enabled in gst-full static build mode but this is not supported by now. gir generation is now disabled.')
endif
# FIXME: gnome.generate_gir should link with not only gstfull in static gst-full but the whole gstreamer suite.
# tried dependencies without success.
if not get_option('introspection').disabled() and not building_full_static
built_girs = {}
foreach gir: exposed_girs
includes = []
@ -466,10 +472,9 @@ if building_full
if not get_option('tools').disabled()
foreach tool, data: all_tools
gst_full_tools += tool
exe_name = '@0@-@1@'.format(tool, apiversion)
extra_args = data.get('extra_c_args', [])
sources = data.get('files')
install_tag = data.get('install_tag', 'bin')
deps = []
foreach d : data.get('deps', [])
if d not in exposed_deps
@ -477,15 +482,28 @@ if building_full
endif
endforeach
executable(exe_name,
sources,
install: true,
install_tag: install_tag,
include_directories : [configinc],
exe = executable(exe_name,
data.get('files'),
install: data.get('install', true),
install_tag: data.get('install_tag', 'bin'),
install_dir: data.get('install_dir', get_option('bindir')),
include_directories : data.get('include_directories', [configinc]),
dependencies : [gst_full_dep] + deps,
c_args: extra_args + gst_c_args + ['-DG_LOG_DOMAIN="@0@"'.format(exe_name)],
c_args: data.get('extra_c_args', []) + gst_c_args + ['-DG_LOG_DOMAIN="@0@"'.format(exe_name)],
cpp_args: data.get('extra_cpp_args', []),
objc_args: data.get('extra_objc_args', []),
override_options: data.get('override_options', []),
)
if(data.has_key('env'))
env = data.get('env')
value = env[1]
if env[1] == 'exe-full-path'
value = exe.full_path()
endif
meson.add_devenv({env[0]: value})
endif
if data.has_key('man_page')
install_man(data.get('man_page'))
endif
@ -537,13 +555,7 @@ endif
summary({
'gstreamer-full library': building_full,
'gstreamer-full target type': get_option('gst-full-target-type'),
'Tools': gst_full_tools,
'Tests and examples disabled': building_full,
}, section: 'Build options', bool_yn: true, list_sep: ' ')
gst_tools = []
foreach tool, data: all_tools
gst_tools += tool
endforeach
summary({
'Tools': gst_tools,
}, section: 'Build options', list_sep: ', ')

View file

@ -38,6 +38,8 @@ option('gst-full-device-providers', type : 'string', value : '',
description : '''List of device providers to expose in gstreamer-full's ABI with the syntax plugin1:dp1;plugin2:dp1:dp2. By default '' will export all device provider of the enabled plugin.''')
option('gst-full-dynamic-types', type : 'string', value : '',
description : '''List of dynamic types to expose in gstreamer-full's ABI with the syntax plugin:dt1,dt2. By default '' will export all device provider of the enabled plugin.''')
option('gst-full-target-type', type : 'combo', value : 'shared_library', choices: ['static_library', 'shared_library'],
description : '''The type of library of gstreamer-full-1.0.''')
option('orc-source', type: 'combo', choices: ['system', 'subproject', 'auto'], value: 'subproject')
option('build-tools-source', type: 'combo', choices: ['system', 'subproject'], value: 'subproject')

View file

@ -10,6 +10,10 @@ else
endif
gst_plugin_scanner_path = join_paths(gst_plugin_scanner_dir, 'gst-plugin-scanner')
if get_option('tests').disabled() or static_build
subdir_done()
endif
# FIXME: make check work on windows
if host_machine.system() != 'windows' and gst_check_dep.found()
subdir('check')

View file

@ -47,7 +47,7 @@ else
message('Can not build gst-validate-transcoding-' + apiversion)
endif
if not get_option('tools').disabled()
if not get_option('tools').disabled() and not static_build
foreach tool, data: gst_tools
if not data.has_key('config_data')

View file

@ -1 +1,5 @@
if get_option('examples').disabled() or static_build
subdir_done()
endif
subdir('c')

View file

@ -270,9 +270,7 @@ subdir('plugins')
subdir('tools')
subdir('tests')
if not get_option('examples').disabled()
subdir('examples')
endif
subdir('examples')
subdir('docs')
pygi_override_dir = get_option('pygi-overrides-dir')

View file

@ -1,3 +1,7 @@
if get_option('tests').disabled() or static_build
subdir_done()
endif
# FIXME: make check work on windows
if host_machine.system() != 'windows' and gstcheck_dep.found()
subdir('check')

View file

@ -1,5 +1,6 @@
project('gst-examples', 'c', version : '1.23.0.1', license : 'LGPL')
static_build = get_option('default_library') == 'static'
cc = meson.get_compiler('c')
m_dep = cc.find_library('m', required : false)
@ -34,6 +35,10 @@ gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
fallback : ['gst-plugins-base', 'rtp_dep'])
if static_build
subdir_done()
endif
subdir('playback')
subdir('network')
subdir('webrtc')

View file

@ -1,3 +1,7 @@
if not get_option('tests').disabled() and gstcheck_dep.found()
if get_option('tests').disabled() or static_build
subdir_done()
endif
if gstcheck_dep.found()
subdir('check')
endif

View file

@ -1,3 +1,7 @@
if get_option('examples').disabled() or static_build or host_machine.system() == 'windows'
subdir_done()
endif
if gstgl_dep.found()
subdir('egl')
endif

View file

@ -23,6 +23,8 @@ api_version = '1.0'
plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
cc = meson.get_compiler('c')
static_build = get_option('default_library') == 'static'
if cc.get_id() == 'msvc'
msvc_args = [
@ -410,9 +412,8 @@ if not get_option('tools').disabled()
subdir('tools')
endif
if not get_option('tests').disabled() and gstcheck_dep.found()
subdir('tests')
endif
subdir('tests')
subdir('docs')
# Set release date

View file

@ -1,4 +1,8 @@
# FIXME: make check work on windows
if host_machine.system() != 'windows'
subdir('check')
if get_option('tests').disabled() or static_build or host_machine.system() == 'windows'
subdir_done()
endif
if gstcheck_dep.found()
subdir('check')
endif

View file

@ -1,4 +1,8 @@
if not get_option('tests').disabled() and gstcheck_dep.found()
if get_option('tests').disabled() or static_build
subdir_done()
endif
if gstcheck_dep.found()
subdir('check')
subdir('interactive')
subdir('validate')

View file

@ -1,3 +1,7 @@
if get_option('tests').disabled() or static_build
subdir_done()
endif
pluginsdirs = []
if gst_dep.type_name() == 'pkgconfig'
pluginsdirs = [gst_dep.get_variable('pluginsdir')]
@ -7,7 +11,7 @@ else
endif
gst_plugin_scanner_path = join_paths(gst_plugin_scanner_dir, 'gst-plugin-scanner')
if not get_option('tests').disabled() and gst_check_dep.found()
if gst_check_dep.found()
subdir('check')
subdir('interactive')
subdir('validate')

View file

@ -44,7 +44,7 @@ endif
},
}
if not get_option('tools').disabled()
if not get_option('tools').disabled() and not static_build
foreach tool, data: gst_tools
exe_name = '@0@-@1@'.format(tool, api_version)
executable(exe_name,

View file

@ -22,6 +22,10 @@ gstmultifile = library('gstmultifile',
)
plugins += [gstmultifile]
if get_option('tests').disabled() or static_build
subdir_done()
endif
test_splitmuxpartreader_sources = [
'test-splitmuxpartreader.c',
'gstsplitmuxpartreader.c',

View file

@ -1,4 +1,8 @@
if not get_option('tests').disabled() and gstcheck_dep.found()
if get_option('tests').disabled() or static_build
subdir_done()
endif
if gstcheck_dep.found()
subdir('check')
subdir('interactive')
endif

View file

@ -1,3 +1,7 @@
if not get_option('tests').disabled() and gstcheck_dep.found()
if get_option('tests').disabled() or static_build
subdir_done()
endif
if gstcheck_dep.found()
subdir('check')
endif

View file

@ -1,3 +1,7 @@
if get_option('examples').disabled() or static_build
subdir_done()
endif
examples = [
'test-appsrc',
'test-appsrc2',

View file

@ -192,12 +192,10 @@ static_build = get_option('default_library') == 'static'
gst_libraries = []
subdir('gst')
if not get_option('tests').disabled()
subdir('tests')
endif
if not get_option('examples').disabled()
subdir('examples')
endif
subdir('tests')
subdir('examples')
subdir('docs')
# Set release date

View file

@ -1,5 +1,9 @@
# FIXME: make check work on windows
if host_machine.system() != 'windows' and gstcheck_dep.found()
if get_option('tests').disabled() or static_build or host_machine.system() == 'windows'
subdir_done()
endif
if gstcheck_dep.found()
subdir('check')
endif

View file

@ -1,4 +1,8 @@
if not get_option('tests').disabled() and gstcheck_dep.found()
if get_option('tests').disabled() or static_build
subdir_done()
endif
if gstcheck_dep.found()
subdir('check')
endif

View file

@ -119,6 +119,10 @@
#endif
#endif
#ifdef GST_FULL_COMPILATION
void gst_init_static_plugins ();
#endif
#include <glib/gi18n-lib.h>
#include <locale.h> /* for LC_ALL */
@ -621,19 +625,9 @@ gst_register_core_elements (GstPlugin * plugin)
static void
init_static_plugins (void)
{
GModule *module;
/* Call gst_init_static_plugins() defined in libgstreamer-full-1.0 in the case
* libgstreamer is static linked with some plugins. */
module = g_module_open (NULL, G_MODULE_BIND_LOCAL);
if (module) {
void (*func) (void);
if (g_module_symbol (module, "gst_init_static_plugins",
(gpointer *) & func)) {
func ();
}
g_module_close (module);
}
#ifdef GST_FULL_COMPILATION
gst_init_static_plugins ();
#endif
}
/*

View file

@ -252,6 +252,10 @@ if not tracer_hooks
libgst_c_args += ['-DGST_DISABLE_GST_TRACER_HOOKS']
endif
if get_option('gstreamer-full').enabled()
libgst_c_args += ['-DGST_FULL_COMPILATION']
endif
# Make sure that subproject building gir files work
gst_incdirs = [configinc]
gst_gen_sources = [gstenum_h]

View file

@ -32,6 +32,7 @@ helpers_install_dir = join_paths(libexecdir, 'gstreamer-1.0')
cc = meson.get_compiler('c')
host_system = host_machine.system()
static_build = get_option('default_library') == 'static'
if host_system == 'darwin'
ios_test_code = '''#include <TargetConditionals.h>
@ -569,7 +570,8 @@ gst_c_args = ['-DHAVE_CONFIG_H']
# FIXME: This is only needed on windows and probably breaks when
# default_library = 'both'. We should add this flag to static_c_args instead
# when Meson supports it: https://github.com/mesonbuild/meson/issues/3304
if get_option('default_library') == 'static'
if static_build
gst_c_args += ['-DGST_STATIC_COMPILATION']
endif
@ -634,7 +636,7 @@ if host_system == 'darwin'
pkgconfig_libs = ['-Wl,-rpath,${libdir}']
endif
static_build = get_option('default_library') == 'static'
gst_libraries = []
subdir('gst')
subdir('libs')

View file

@ -24,6 +24,7 @@ option('libdw', type : 'feature', value : 'auto', description : 'Use libdw to ge
option('dbghelp', type : 'feature', value : 'auto', description : 'Use dbghelp to generate backtraces')
option('bash-completion', type : 'feature', value : 'auto', description : 'Install bash completion files')
option('coretracers', type : 'feature', value : 'auto', description : 'Build coretracers plugin')
option('gstreamer-full', type : 'feature', value : 'disabled', description : 'Build with gstreamer-full')
# Common feature options
option('examples', type : 'feature', value : 'auto', yield : true)

View file

@ -1,7 +1,11 @@
if get_option('tests').disabled() or static_build
subdir_done()
endif
if not get_option('benchmarks').disabled()
subdir('benchmarks')
endif
if not get_option('tests').disabled() and gst_check_dep.found()
if gst_check_dep.found()
subdir('validate')
subdir('check')
endif

View file

@ -31,7 +31,7 @@ foreach tool : tools
endif
man_page = files('@0@-1.0.1'.format(tool))
if not get_option('tools').disabled()
if not get_option('tools').disabled() and not static_build
executable(exe_name,
src_file,
install: true,