mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-13 02:45:35 +00:00
Meson: Use library() to build both static and shared libs
Meson supports building both static and shared libraries in a single library() call. It has the advantage of reusing the same .o objects and thus avoid double compilation. https://bugzilla.gnome.org/show_bug.cgi?id=794627
This commit is contained in:
parent
ca3698b9c1
commit
b00b1d5361
7 changed files with 119 additions and 190 deletions
|
@ -223,65 +223,46 @@ if disable_tracer_hooks
|
|||
libgst_c_args += ['-DGST_DISABLE_GST_TRACER_HOOKS']
|
||||
endif
|
||||
|
||||
# Make it possible to build both static and shared versions
|
||||
# at the same time. By default use shared for unit tests etc.
|
||||
# This choice is arbitrary.
|
||||
if libtype != 'shared'
|
||||
libgst_static = static_library('gstreamer-1.0', gst_sources,
|
||||
gstenum_h, gstenum_c, grammar, parser, gst_registry,
|
||||
c_args : [libgst_c_args],
|
||||
include_directories : [configinc,
|
||||
# HACK, change include paths in .y and .l in final version.
|
||||
include_directories('parse')],
|
||||
install : true,
|
||||
link_with : printf_lib,
|
||||
dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib] + backtrace_deps + platform_deps,
|
||||
)
|
||||
libgst = libgst_static
|
||||
endif
|
||||
|
||||
# Make sure that subproject building gir files work
|
||||
gst_incdirs = [configinc]
|
||||
gst_gen_sources = [gstenum_h]
|
||||
if libtype != 'static'
|
||||
libgst_shared = shared_library('gstreamer-1.0', gst_sources,
|
||||
gstenum_h, gstenum_c, grammar, parser, gst_registry,
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
c_args : libgst_c_args,
|
||||
include_directories : [configinc,
|
||||
# HACK, change include paths in .y and .l in final version.
|
||||
include_directories('parse')],
|
||||
link_with : printf_lib,
|
||||
install : true,
|
||||
dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib, dl_dep] + backtrace_deps
|
||||
+ platform_deps,
|
||||
)
|
||||
libgst = libgst_shared
|
||||
if build_gir
|
||||
gst_gir_extra_args = gir_init_section + [ '--c-include=gst/gst.h' ]
|
||||
if meson.is_subproject()
|
||||
# FIXME: There must be a better way to do this
|
||||
# Need to pass the include path to find gst/gst.h and gst/gstenumtypes.h (built)
|
||||
gst_gir_extra_args += ['--cflags-begin',
|
||||
'-I' + meson.current_source_dir() + '/..',
|
||||
'-I' + meson.current_build_dir() + '/..',
|
||||
'--cflags-end']
|
||||
endif
|
||||
libgst = library('gstreamer-1.0', gst_sources,
|
||||
gstenum_h, gstenum_c, grammar, parser, gst_registry,
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
c_args : libgst_c_args,
|
||||
include_directories : [configinc,
|
||||
# HACK, change include paths in .y and .l in final version.
|
||||
include_directories('parse')],
|
||||
link_with : printf_lib,
|
||||
install : true,
|
||||
dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib, dl_dep] + backtrace_deps
|
||||
+ platform_deps,
|
||||
)
|
||||
|
||||
gst_incdirs += [configinc]
|
||||
gst_gen_sources += [gnome.generate_gir(libgst_shared,
|
||||
sources : gst_sources + gst_headers + gst_enums + [gst_version_h],
|
||||
namespace : 'Gst',
|
||||
nsversion : apiversion,
|
||||
identifier_prefix : 'Gst',
|
||||
symbol_prefix : 'gst',
|
||||
export_packages : 'gstreamer-1.0',
|
||||
includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0' ],
|
||||
install : true,
|
||||
extra_args : gst_gir_extra_args,
|
||||
)]
|
||||
if build_gir
|
||||
gst_gir_extra_args = gir_init_section + [ '--c-include=gst/gst.h' ]
|
||||
if meson.is_subproject()
|
||||
# FIXME: There must be a better way to do this
|
||||
# Need to pass the include path to find gst/gst.h and gst/gstenumtypes.h (built)
|
||||
gst_gir_extra_args += ['--cflags-begin',
|
||||
'-I' + meson.current_source_dir() + '/..',
|
||||
'-I' + meson.current_build_dir() + '/..',
|
||||
'--cflags-end']
|
||||
endif
|
||||
|
||||
gst_incdirs += [configinc]
|
||||
gst_gen_sources += [gnome.generate_gir(libgst,
|
||||
sources : gst_sources + gst_headers + gst_enums + [gst_version_h],
|
||||
namespace : 'Gst',
|
||||
nsversion : apiversion,
|
||||
identifier_prefix : 'Gst',
|
||||
symbol_prefix : 'gst',
|
||||
export_packages : 'gstreamer-1.0',
|
||||
includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0' ],
|
||||
install : true,
|
||||
extra_args : gst_gir_extra_args,
|
||||
)]
|
||||
endif
|
||||
|
||||
gst_dep = declare_dependency(link_with : libgst,
|
||||
|
|
|
@ -36,46 +36,33 @@ gst_base_headers = [
|
|||
'gsttypefindhelper.h',
|
||||
]
|
||||
|
||||
if libtype != 'shared'
|
||||
gst_base_static = static_library('gstbase-@0@'.format(apiversion),
|
||||
gst_base_sources,
|
||||
c_args : gst_c_args,
|
||||
install : true,
|
||||
include_directories : [configinc, libsinc],
|
||||
dependencies : [gobject_dep, glib_dep, gst_dep],
|
||||
)
|
||||
gst_base = gst_base_static
|
||||
endif
|
||||
|
||||
gst_base_gen_sources = []
|
||||
|
||||
if libtype != 'static'
|
||||
gst_base_shared = shared_library('gstbase-@0@'.format(apiversion),
|
||||
gst_base_sources,
|
||||
c_args : gst_c_args,
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
gst_base = library('gstbase-@0@'.format(apiversion),
|
||||
gst_base_sources,
|
||||
c_args : gst_c_args,
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
install : true,
|
||||
include_directories : [configinc, libsinc],
|
||||
dependencies : [gobject_dep, glib_dep, gst_dep],
|
||||
)
|
||||
|
||||
if build_gir
|
||||
gst_gir_extra_args = gir_init_section + [ '--c-include=gst/base/base.h' ]
|
||||
gst_base_gen_sources += [gnome.generate_gir(gst_base,
|
||||
sources : gst_base_sources + gst_base_headers,
|
||||
namespace : 'GstBase',
|
||||
nsversion : apiversion,
|
||||
identifier_prefix : 'Gst',
|
||||
symbol_prefix : 'gst',
|
||||
export_packages : 'gstreamer-base-1.0',
|
||||
dependencies : [gst_dep],
|
||||
include_directories : [configinc, libsinc, privinc],
|
||||
includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0', 'Gst-1.0'],
|
||||
install : true,
|
||||
include_directories : [configinc, libsinc],
|
||||
dependencies : [gobject_dep, glib_dep, gst_dep],
|
||||
)
|
||||
gst_base = gst_base_shared
|
||||
if build_gir
|
||||
gst_gir_extra_args = gir_init_section + [ '--c-include=gst/base/base.h' ]
|
||||
gst_base_gen_sources += [gnome.generate_gir(gst_base_shared,
|
||||
sources : gst_base_sources + gst_base_headers,
|
||||
namespace : 'GstBase',
|
||||
nsversion : apiversion,
|
||||
identifier_prefix : 'Gst',
|
||||
symbol_prefix : 'gst',
|
||||
export_packages : 'gstreamer-base-1.0',
|
||||
dependencies : [gst_dep],
|
||||
include_directories : [configinc, libsinc, privinc],
|
||||
includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0', 'Gst-1.0'],
|
||||
install : true,
|
||||
extra_args : gst_gir_extra_args,
|
||||
)]
|
||||
endif
|
||||
extra_args : gst_gir_extra_args,
|
||||
)]
|
||||
endif
|
||||
|
||||
gst_base_dep = declare_dependency(link_with : gst_base,
|
||||
|
|
|
@ -35,47 +35,33 @@ controller_enums = gnome.mkenums_simple('controller-enumtypes',
|
|||
gstcontroller_c = controller_enums[0]
|
||||
gstcontroller_h = controller_enums[1]
|
||||
|
||||
if libtype != 'shared'
|
||||
gst_controller_static = static_library('gstcontroller-@0@'.format(apiversion),
|
||||
gst_controller_sources, gstcontroller_h, gstcontroller_c,
|
||||
c_args : gst_c_args,
|
||||
install : true,
|
||||
include_directories : [configinc, libsinc],
|
||||
dependencies : [gobject_dep, glib_dep, mathlib, gst_dep],
|
||||
)
|
||||
gst_controller = gst_controller_static
|
||||
endif
|
||||
|
||||
|
||||
gst_controller_gen_sources = [gstcontroller_h]
|
||||
if libtype != 'static'
|
||||
gst_controller_shared = shared_library('gstcontroller-@0@'.format(apiversion),
|
||||
gst_controller_sources, gstcontroller_h, gstcontroller_c,
|
||||
c_args : gst_c_args,
|
||||
gst_controller = library('gstcontroller-@0@'.format(apiversion),
|
||||
gst_controller_sources, gstcontroller_h, gstcontroller_c,
|
||||
c_args : gst_c_args,
|
||||
install : true,
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
include_directories : [configinc, libsinc],
|
||||
dependencies : [gobject_dep, glib_dep, mathlib, gst_dep],
|
||||
)
|
||||
|
||||
if build_gir
|
||||
gst_gir_extra_args = gir_init_section + [ '--c-include=gst/controller/controller.h' ]
|
||||
gst_controller_gir = gnome.generate_gir(gst_controller,
|
||||
sources : gst_controller_sources + gst_controller_headers + [gstcontroller_h] + [gstcontroller_c],
|
||||
namespace : 'GstController',
|
||||
nsversion : apiversion,
|
||||
identifier_prefix : 'Gst',
|
||||
symbol_prefix : 'gst',
|
||||
export_packages : 'gstreamer-controller-1.0',
|
||||
dependencies : [gst_dep],
|
||||
include_directories : [configinc, libsinc, privinc],
|
||||
includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0', 'Gst-1.0'],
|
||||
install : true,
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
include_directories : [configinc, libsinc],
|
||||
dependencies : [gobject_dep, glib_dep, mathlib, gst_dep],
|
||||
extra_args : gst_gir_extra_args,
|
||||
)
|
||||
gst_controller = gst_controller_shared
|
||||
if build_gir
|
||||
gst_gir_extra_args = gir_init_section + [ '--c-include=gst/controller/controller.h' ]
|
||||
gst_controller_gir = gnome.generate_gir(gst_controller_shared,
|
||||
sources : gst_controller_sources + gst_controller_headers + [gstcontroller_h] + [gstcontroller_c],
|
||||
namespace : 'GstController',
|
||||
nsversion : apiversion,
|
||||
identifier_prefix : 'Gst',
|
||||
symbol_prefix : 'gst',
|
||||
export_packages : 'gstreamer-controller-1.0',
|
||||
dependencies : [gst_dep],
|
||||
include_directories : [configinc, libsinc, privinc],
|
||||
includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0', 'Gst-1.0'],
|
||||
install : true,
|
||||
extra_args : gst_gir_extra_args,
|
||||
)
|
||||
gst_controller_gen_sources += [gst_controller_gir]
|
||||
endif
|
||||
gst_controller_gen_sources += [gst_controller_gir]
|
||||
endif
|
||||
|
||||
gst_controller_dep = declare_dependency(link_with : gst_controller,
|
||||
|
|
|
@ -22,46 +22,33 @@ gst_net_headers = [
|
|||
]
|
||||
install_headers(gst_net_headers, subdir : 'gstreamer-1.0/gst/net/')
|
||||
|
||||
if libtype != 'shared'
|
||||
gst_net_static = static_library('gstnet-@0@'.format(apiversion),
|
||||
gst_net_sources,
|
||||
c_args : gst_c_args,
|
||||
include_directories : [configinc, libsinc],
|
||||
install : true,
|
||||
dependencies : [gio_dep, gst_base_dep],
|
||||
)
|
||||
gst_net = gst_net_static
|
||||
endif
|
||||
|
||||
gst_net_gen_sources = []
|
||||
if libtype != 'static'
|
||||
gst_net_shared = shared_library('gstnet-@0@'.format(apiversion),
|
||||
gst_net_sources,
|
||||
c_args : gst_c_args,
|
||||
gst_net = library('gstnet-@0@'.format(apiversion),
|
||||
gst_net_sources,
|
||||
c_args : gst_c_args,
|
||||
include_directories : [configinc, libsinc],
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
install : true,
|
||||
dependencies : [gio_dep, gst_base_dep],
|
||||
)
|
||||
|
||||
if build_gir
|
||||
gst_gir_extra_args = gir_init_section + [ '--c-include=gst/net/net.h' ]
|
||||
gst_net_gir = gnome.generate_gir(gst_net,
|
||||
sources : gst_net_sources + gst_net_headers,
|
||||
namespace : 'GstNet',
|
||||
nsversion : apiversion,
|
||||
identifier_prefix : 'Gst',
|
||||
symbol_prefix : 'gst',
|
||||
export_packages : 'gstreamer-net-1.0',
|
||||
dependencies : [gst_base_dep],
|
||||
include_directories : [configinc, libsinc],
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0', 'Gio-2.0', 'Gst-1.0'],
|
||||
install : true,
|
||||
dependencies : [gio_dep, gst_base_dep],
|
||||
extra_args : gst_gir_extra_args,
|
||||
)
|
||||
gst_net = gst_net_shared
|
||||
if build_gir
|
||||
gst_gir_extra_args = gir_init_section + [ '--c-include=gst/net/net.h' ]
|
||||
gst_net_gir = gnome.generate_gir(gst_net_shared,
|
||||
sources : gst_net_sources + gst_net_headers,
|
||||
namespace : 'GstNet',
|
||||
nsversion : apiversion,
|
||||
identifier_prefix : 'Gst',
|
||||
symbol_prefix : 'gst',
|
||||
export_packages : 'gstreamer-net-1.0',
|
||||
dependencies : [gst_base_dep],
|
||||
include_directories : [configinc, libsinc],
|
||||
includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0', 'Gio-2.0', 'Gst-1.0'],
|
||||
install : true,
|
||||
extra_args : gst_gir_extra_args,
|
||||
)
|
||||
gst_net_gen_sources += [gst_net_gir]
|
||||
endif
|
||||
gst_net_gen_sources += [gst_net_gir]
|
||||
endif
|
||||
|
||||
gst_net_dep = declare_dependency(link_with : gst_net,
|
||||
|
|
|
@ -24,7 +24,7 @@ soversion = 0
|
|||
libversion = '@0@.@1@.0'.format(soversion, gst_version_minor * 100 + gst_version_micro)
|
||||
|
||||
prefix = get_option('prefix')
|
||||
libtype = get_option('library_format')
|
||||
libtype = get_option('default_library')
|
||||
|
||||
libexecdir = get_option('libexecdir')
|
||||
helpers_install_dir = join_paths(libexecdir, 'gstreamer-1.0')
|
||||
|
@ -418,6 +418,10 @@ gir_init_section = [ '--add-init-section=extern void gst_init(gint*,gchar**);' +
|
|||
'gst_init(NULL,NULL);' ]
|
||||
|
||||
gst_c_args = ['-DHAVE_CONFIG_H']
|
||||
|
||||
# FIXME: This is only needed on windows and probably breaks when
|
||||
# libtype=='both'. We should add this flag to static_c_args instead when Meson
|
||||
# supports it: https://github.com/mesonbuild/meson/issues/3304
|
||||
if libtype == 'static'
|
||||
gst_c_args += ['-DGST_STATIC_COMPILATION']
|
||||
endif
|
||||
|
|
|
@ -5,7 +5,6 @@ option('disable_examples', type : 'boolean', value : false)
|
|||
option('disable_gst_debug', type : 'boolean', value : false)
|
||||
option('disable_registry', type : 'boolean', value : false)
|
||||
option('disable_tracer_hooks', type : 'boolean', value : false)
|
||||
option('library_format', type : 'combo', choices : ['shared', 'static', 'both'], value : 'shared')
|
||||
option('disable_introspection',
|
||||
type : 'boolean', value : false,
|
||||
description : 'Whether to disable the introspection generation')
|
||||
|
|
|
@ -25,26 +25,11 @@ gst_elements_sources = [
|
|||
'gstvalve.c',
|
||||
]
|
||||
|
||||
if libtype != 'shared'
|
||||
gst_elements_static = static_library('gstcoreelements',
|
||||
gst_elements_sources,
|
||||
c_args : gst_c_args,
|
||||
include_directories : [configinc],
|
||||
dependencies : [gobject_dep, glib_dep, gst_dep, gst_base_dep],
|
||||
install : true,
|
||||
install_dir : join_paths(get_option('libdir'), 'gstreamer-1.0'),
|
||||
)
|
||||
gst_elements = gst_elements_static
|
||||
endif
|
||||
|
||||
if libtype != 'static'
|
||||
gst_elements_shared = shared_library('gstcoreelements',
|
||||
gst_elements_sources,
|
||||
c_args : gst_c_args,
|
||||
include_directories : [configinc],
|
||||
dependencies : [gobject_dep, glib_dep, gst_dep, gst_base_dep],
|
||||
install : true,
|
||||
install_dir : join_paths(get_option('libdir'), 'gstreamer-1.0'),
|
||||
)
|
||||
gst_elements = gst_elements_shared
|
||||
endif
|
||||
gst_elements = library('gstcoreelements',
|
||||
gst_elements_sources,
|
||||
c_args : gst_c_args,
|
||||
include_directories : [configinc],
|
||||
dependencies : [gobject_dep, glib_dep, gst_dep, gst_base_dep],
|
||||
install : true,
|
||||
install_dir : join_paths(get_option('libdir'), 'gstreamer-1.0'),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue