1 project('gstreamer-full', 'c',
3 meson_version : '>= 0.59',
4 default_options : ['buildtype=debugoptimized',
5 # Needed due to https://github.com/mesonbuild/meson/issues/1889,
6 # but this can cause problems in the future. Remove it
7 # when it's no longer necessary.
10 gst_version = '>= @0@'.format(meson.project_version())
12 build_system = build_machine.system()
13 cc = meson.get_compiler('c')
16 gnome = import('gnome')
17 pkgconfig = import('pkgconfig')
18 python3 = import('python').find_installation()
19 # Ensure that we're not being run from inside the gst-uninstalled env
20 # because that will confuse meson, and it might find the already-built
21 # gstreamer. It's fine if people run `ninja` as long as it doesn't run
22 # reconfigure because ninja doesn't care about the env.
23 ensure_not_uninstalled = '''
25 assert('GST_ENV' not in os.environ)
27 cmdres = run_command(python3, '-c', ensure_not_uninstalled, check: false)
28 if cmdres.returncode() != 0
29 error('Do not run `ninja` or `meson` for gst-build inside the uninstalled environment, you will run into problems')
32 # Install gst-indent pre-commit hook
33 run_command(python3, '-c', 'import shutil; shutil.copy("scripts/git-hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")', check: false)
35 # Ensure that the user does not have Strawberry Perl in PATH, since it ships
36 # with a pkg-config.bat and broken pkgconfig files for libffi and zlib. Will
37 # cause a build error, such as in
38 # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/41
39 ensure_no_strawberry_perl = '''
41 assert(r'Strawberry\perl\bin' not in os.environ['PATH'])
43 if build_system == 'windows' and meson.version().version_compare('<0.60.0')
44 cmdres = run_command(python3, '-c', ensure_no_strawberry_perl, check: false)
45 if cmdres.returncode() != 0
46 error('You have Strawberry Perl in PATH which is known to cause build issues with Meson < 0.60.0. Please remove it from PATH, uninstall it, or upgrade Meson.')
50 documented_projects = ''
51 # Make it possible to use msys2 built zlib which fails
52 # when not using the mingw toolchain as it uses unistd.h
53 if not meson.is_subproject() and cc.get_id() == 'msvc'
54 uname = find_program('uname', required: false)
56 ret = run_command(uname, '-o', check: false)
57 if ret.returncode() == 0 and ret.stdout().to_lower() == 'msys'
58 ret = run_command(uname, '-r', check: false)
59 # The kernel version returned by uname is actually the msys version
60 if ret.returncode() == 0 and ret.stdout().startswith('2')
61 # If a system zlib is found, disable UNIX features in zlib.h and zconf.h
62 if cc.find_library('z').found()
63 add_global_arguments('-DZ_SOLO', language: 'c')
70 # Ensure that MSVC interprets all source code as UTF-8. Only do this when we're
71 # not a subproject, because subprojects are not allowed to call
72 # add_global_arguments().
73 if not meson.is_subproject() and cc.get_id() == 'msvc'
75 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
76 language: ['c', 'cpp'])
79 # Ordered list of subprojects (dict has no ordering guarantees)
81 ['gstreamer', {'build-hotdoc': true}],
82 ['gst-plugins-base', {'option': get_option('base'), 'build-hotdoc': true}],
83 ['gst-plugins-good', {'option': get_option('good'), 'build-hotdoc': true}],
84 ['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
85 ['gst-plugins-bad', { 'option': get_option('bad'), 'build-hotdoc': true}],
86 ['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true}],
87 ['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true}],
88 ['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true}],
89 ['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true }],
90 ['gst-integration-testsuites', { 'option': get_option('devtools') }],
91 ['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true}],
92 ['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true}],
93 ['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true}],
94 ['gstreamer-sharp', { 'option': get_option('sharp') }],
95 ['pygobject', { 'option': get_option('python'), 'match_gst_version': false, 'sysdep': 'pygobject-3.0', 'sysdep_version': '>= 3.8' }],
96 ['gst-python', { 'option': get_option('python')}],
97 ['gst-examples', { 'option': get_option('gst-examples'), 'match_gst_versions': false}],
98 ['gst-plugins-rs', { 'option': get_option('rs'), 'match_gst_version': false}],
104 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
105 os.path.join('@1@', '@0@'))
108 if build_system == 'windows'
109 subproject('win-flex-bison-binaries')
110 subproject('win-nasm')
111 elif build_system == 'darwin'
112 subproject('macos-bison-binary')
115 orc_subproject = subproject('orc', required: get_option('orc'))
117 foreach custom_subproj: get_option('custom_subprojects').split(',')
118 if custom_subproj != ''
119 message ('Adding custom subproject ' + custom_subproj)
120 subprojects += [[custom_subproj, {'match_gst_version': false}]]
125 subprojects_names = []
126 plugins_doc_caches = []
127 orc_update_targets = []
129 # Using a list and not a dict to keep the ordering to build the chain of `gir`
132 foreach sp : subprojects
135 is_required = build_infos.get('option', true)
136 sysdep = build_infos.get('sysdep', '')
137 sysdep_version = build_infos.get('sysdep_version', '')
138 match_gst_version = build_infos.get('match_gst_version', true)
141 subproj = subproject(project_name, version: gst_version, required: is_required)
143 sysdep_dep = dependency(sysdep, version: sysdep_version, required: false)
144 if not sysdep_dep.found()
145 subproj = subproject(project_name, required: is_required)
148 subproj = subproject(project_name, required: is_required)
152 plugins = subproj.get_variable('plugins', [])
153 all_plugins += plugins
154 all_libraries += subproj.get_variable('libraries', [])
156 orc_update_targets += subproj.get_variable('orc_update_targets', [])
158 subprojects_names += [project_name]
160 if not meson.is_cross_build() and build_infos.get('build-hotdoc', false)
161 if plugins.length() > 0
162 plugins_doc_caches += [subproj.get_variable('plugins_doc_dep', [])]
164 if documented_projects != ''
165 documented_projects += ','
167 documented_projects += project_name
172 # Check if we need to also build glib-networking for TLS modules
173 glib_dep = dependency('glib-2.0')
174 if glib_dep.type_name() == 'internal'
175 subproject('glib-networking', required : get_option('tls'),
176 default_options: ['gnutls=auto', 'openssl=auto'])
179 plugins_doc_dep = custom_target('plugins-doc-cache',
180 command: [python3, '-c', 'print("Built all doc caches")'],
181 input: plugins_doc_caches,
182 output: 'plugins_doc_caches',
186 if meson.is_cross_build() or build_machine.system() == 'windows'
187 if get_option('doc').enabled()
188 error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
191 documented_projects = ''
192 message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
194 hotdoc_p = find_program('hotdoc', required : get_option('doc'))
195 if not hotdoc_p.found()
196 documented_projects = ''
197 message('Not building documentation as hotdoc was not found')
201 write_file_contents = '''
205 assert len(sys.argv) >= 3
207 contents = sys.argv[2]
209 with open(fname, 'w') as f:
214 output : 'GstDocumentedSubprojects',
216 '-c', write_file_contents,
221 if documented_projects != ''
222 subproject('gst-docs', required: get_option('doc').enabled())
223 message('Gst docs subprojects: ' + documented_projects)
226 all_plugins_paths = []
227 all_plugins_dirs = []
228 foreach plugin: all_plugins
229 all_plugins_paths += plugin.full_path()
230 all_plugins_dirs += fs.parent(plugin.full_path())
232 # Work around meson bug: https://github.com/mesonbuild/meson/pull/6770
233 pathsep = host_machine.system() == 'windows' ? ';' : ':'
234 all_plugins_paths = pathsep.join(all_plugins_paths)
236 devenv = environment()
237 devenv.set('GST_PLUGIN_PATH', all_plugins_dirs)
238 devenv.set('CURRENT_GST', meson.current_source_dir())
239 devenv.set('GST_VERSION', meson.project_version())
240 devenv.set('GST_ENV', 'gst-' + meson.project_version())
241 devenv.set('GST_REGISTRY', meson.current_build_dir() / 'registry.dat')
242 devenv.set('GST_PLUGIN_SYSTEM_PATH', '')
243 meson.add_devenv(devenv)
245 generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
247 output : 'GstPluginsPath.json',
248 command : [generate_plugins_paths,
253 if get_option('default_library') == 'static'
254 # Generate a .c file which declare and register all built plugins
256 foreach plugin: all_plugins
257 plugins_names += plugin.full_path()
259 all_plugin_names = ';'.join(plugins_names)
261 static_plugins = get_option('gst-full-plugins')
262 if static_plugins == '*'
263 static_plugins = all_plugin_names
265 generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
266 init_static_plugins_c = configure_file(
267 output: 'gstinitstaticplugins.c',
268 command : [generate_init_static_plugins,
270 '-p ' + static_plugins,
271 '-e ' + get_option('gst-full-elements'),
272 '-t ' + get_option('gst-full-typefind-functions'),
273 '-d ' + get_option('gst-full-device-providers'),
274 '-T ' + get_option('gst-full-dynamic-types')
278 gstfull_link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions'])
280 # Get a list of libraries that needs to be exposed in the ABI.
284 wanted_libs = ['gstreamer-1.0'] + get_option('gst-full-libraries')
285 all_libs = '*' in wanted_libs
287 foreach pkgname_library : all_libraries
288 pkg_name = pkgname_library[0]
289 lib_def = pkgname_library[1]
291 if pkg_name in wanted_libs or all_libs
292 if lib_def.has_key('lib')
293 incdir_deps += dependency(pkg_name).partial_dependency(includes: true, sources: true)
294 exposed_libs += [lib_def['lib']]
297 if lib_def.has_key('gir')
298 exposed_girs += lib_def['gir']
303 # glib and gobject are part of our public API. If we are using glib from the
304 # system then our pkg-config file must require it. If we built it as
305 # subproject then we need to link_whole it.
307 glib_dep = dependency('glib-2.0')
308 gobject_dep = dependency('gobject-2.0')
309 if gobject_dep.type_name() == 'internal'
310 glib_subproject = subproject('glib')
311 exposed_libs += glib_subproject.get_variable('libglib')
312 exposed_libs += glib_subproject.get_variable('libgobject')
314 glib_dep.partial_dependency(includes: true),
315 gobject_dep.partial_dependency(includes: true),
318 glib_deps = [glib_dep, gobject_dep]
322 if get_option('gst-full-version-script') != ''
323 symbol_map = meson.current_source_dir() / get_option('gst-full-version-script')
324 link_arg = '-Wl,--version-script=' + symbol_map
325 if cc.has_link_argument(link_arg)
326 gstfull_link_args += link_arg
327 link_deps += symbol_map
328 elif cc.get_id() == 'msvc'
329 warning('FIXME: Provide a def file to publish the public symbols')
331 error('Failed to link with version script (' + symbol_map + '), check logs for details')
335 # Build both shared and static library
336 gstfull = both_libraries('gstreamer-full-1.0',
337 init_static_plugins_c,
338 link_with : all_plugins,
339 link_args: gstfull_link_args,
340 link_whole : exposed_libs,
341 dependencies : incdir_deps + glib_deps,
342 link_depends : link_deps,
346 gst_full_dep = declare_dependency(link_with: gstfull.get_shared_lib(),
347 dependencies : incdir_deps + glib_deps,
348 include_directories: include_directories('.')
351 gst_full_libs_private = cc.get_supported_link_arguments(['-Wl,--undefined=gst_init_static_plugins'])
352 if gst_full_libs_private == []
353 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.')
356 if not get_option('introspection').disabled()
358 foreach gir: exposed_girs
360 foreach include: gir.get('includes', [])
361 includes += [built_girs.get(include, include)]
365 'includes': includes,
366 'extra_args': gir.get('extra_args', []) + ['--add-include-path=' + meson.current_build_dir()],
369 built_girs += {gir.get('namespace') + '-' + gir.get('nsversion'): gnome.generate_gir(gstfull, kwargs: gir)[0]}
373 pkgconfig.generate(gstfull,
375 libraries_private: gst_full_libs_private,
376 subdirs : 'gstreamer-1.0')
377 meson.override_dependency('gstreamer-full-1.0', gst_full_dep)
380 message('Building subprojects: ' + ', '.join(subprojects_names))
382 setenv = find_program('gst-env.py')
383 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.project_build_root()),
384 '--gstbuilddir=@0@'.format(meson.current_build_dir()),
385 '--srcdir=@0@'.format(meson.project_source_root())]
388 if meson.can_run_host_binaries() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
389 # FIXME: Ideally we could get the wrapper directly from meson
390 devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
391 sysroot = meson.get_cross_property('sys_root')
394 devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
398 run_target('uninstalled', command : devenv_cmd)
399 run_target('devenv', command : devenv_cmd)
401 if orc_subproject.found() and orc_update_targets.length() > 0
402 alias_target('update-orc-dist', orc_update_targets)
406 'gstreamer-full': get_option('default_library') == 'static',
407 }, section: 'Build options', bool_yn: true, list_sep: ' ')