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)
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")')
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'
44 cmdres = run_command(python3, '-c', ensure_no_strawberry_perl)
45 if cmdres.returncode() != 0
46 error('You have Strawberry Perl in PATH which is known to cause build issues with gst-build. Please remove it from PATH or uninstall it.')
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')
57 if ret.returncode() == 0 and ret.stdout().to_lower() == 'msys'
58 ret = run_command(uname, '-r')
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.38.1' }],
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 subprojects_names = []
118 plugins_doc_caches = []
119 orc_update_targets = []
121 # Using a list and not a dict to keep the ordering to build the chain of `gir`
124 foreach sp : subprojects
127 is_required = build_infos.get('option', true)
128 sysdep = build_infos.get('sysdep', '')
129 sysdep_version = build_infos.get('sysdep_version', '')
130 match_gst_version = build_infos.get('match_gst_version', true)
133 subproj = subproject(project_name, version: gst_version, required: is_required)
135 sysdep_dep = dependency(sysdep, version: sysdep_version, required: false)
136 if not sysdep_dep.found()
137 subproj = subproject(project_name, required: is_required)
140 subproj = subproject(project_name, required: is_required)
144 plugins = subproj.get_variable('plugins', [])
145 all_plugins += plugins
146 all_libraries += subproj.get_variable('libraries', [])
148 orc_update_targets += subproj.get_variable('orc_update_targets', [])
150 subprojects_names += [project_name]
151 cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
152 if cmdres.returncode() == 0
153 message('Created symlink to ' + project_name)
156 if not meson.is_cross_build() and build_infos.get('build-hotdoc', false)
157 if plugins.length() > 0
158 plugins_doc_caches += [subproj.get_variable('plugins_doc_dep', [])]
160 if documented_projects != ''
161 documented_projects += ','
163 documented_projects += project_name
168 # Check if we need to also build glib-networking for TLS modules
169 glib_dep = dependency('glib-2.0')
170 if glib_dep.type_name() == 'internal'
171 subproject('glib-networking', required : get_option('tls'),
172 default_options: ['gnutls=auto', 'openssl=auto'])
175 plugins_doc_dep = custom_target('plugins-doc-cache',
176 command: [python3, '-c', 'print("Built all doc caches")'],
177 input: plugins_doc_caches,
178 output: 'plugins_doc_caches',
182 if meson.is_cross_build() or build_machine.system() == 'windows'
183 if get_option('doc').enabled()
184 error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
187 documented_projects = ''
188 message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
190 hotdoc_p = find_program('hotdoc', required : get_option('doc'))
191 if not hotdoc_p.found()
192 documented_projects = ''
193 message('Not building documentation as hotdoc was not found')
197 write_file_contents = '''
201 assert len(sys.argv) >= 3
203 contents = sys.argv[2]
205 with open(fname, 'w') as f:
210 output : 'GstDocumentedSubprojects',
212 '-c', write_file_contents,
217 if documented_projects != ''
218 subproject('gst-docs', required: get_option('doc').enabled())
219 message('Gst docs subprojects: ' + documented_projects)
222 all_plugins_paths = []
223 all_plugins_dirs = []
224 foreach plugin: all_plugins
225 all_plugins_paths += plugin.full_path()
226 all_plugins_dirs += fs.parent(plugin.full_path())
228 # Work around meson bug: https://github.com/mesonbuild/meson/pull/6770
229 pathsep = host_machine.system() == 'windows' ? ';' : ':'
230 all_plugins_paths = pathsep.join(all_plugins_paths)
232 devenv = environment()
233 devenv.set('GST_PLUGIN_PATH', all_plugins_dirs)
234 devenv.set('CURRENT_GST', meson.current_source_dir())
235 devenv.set('GST_VERSION', meson.project_version())
236 devenv.set('GST_ENV', 'gst-' + meson.project_version())
237 devenv.set('GST_REGISTRY', meson.current_build_dir() / 'registry.dat')
238 devenv.set('GST_PLUGIN_SYSTEM_PATH', '')
239 meson.add_devenv(devenv)
241 generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
243 output : 'GstPluginsPath.json',
244 command : [generate_plugins_paths,
249 if get_option('default_library') == 'static'
250 # Generate a .c file which declare and register all built plugins
252 foreach plugin: all_plugins
253 plugins_names += plugin.full_path()
255 all_plugin_names = ';'.join(plugins_names)
257 static_plugins = get_option('gst-full-plugins')
258 if static_plugins == '*'
259 static_plugins = all_plugin_names
261 generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
262 init_static_plugins_c = configure_file(
263 output: 'gstinitstaticplugins.c',
264 command : [generate_init_static_plugins,
266 '-p ' + static_plugins,
267 '-e ' + get_option('gst-full-elements'),
268 '-t ' + get_option('gst-full-typefind-functions'),
269 '-d ' + get_option('gst-full-device-providers'),
270 '-T ' + get_option('gst-full-dynamic-types')
274 gstfull_link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions'])
276 # Get a list of libraries that needs to be exposed in the ABI.
280 wanted_libs = ['gstreamer-1.0'] + get_option('gst-full-libraries')
281 all_libs = '*' in wanted_libs
283 foreach pkgname_library : all_libraries
284 pkg_name = pkgname_library[0]
285 lib_def = pkgname_library[1]
287 if pkg_name in wanted_libs or all_libs
288 if lib_def.has_key('lib')
289 incdir_deps += dependency(pkg_name).partial_dependency(includes: true, sources: true)
290 exposed_libs += [lib_def['lib']]
293 if lib_def.has_key('gir')
294 exposed_girs += lib_def['gir']
299 # glib and gobject are part of our public API. If we are using glib from the
300 # system then our pkg-config file must require it. If we built it as
301 # subproject then we need to link_whole it.
303 glib_dep = dependency('glib-2.0')
304 gobject_dep = dependency('gobject-2.0')
305 if gobject_dep.type_name() == 'internal'
306 glib_subproject = subproject('glib')
307 exposed_libs += glib_subproject.get_variable('libglib')
308 exposed_libs += glib_subproject.get_variable('libgobject')
310 glib_dep.partial_dependency(includes: true),
311 gobject_dep.partial_dependency(includes: true),
314 glib_deps = [glib_dep, gobject_dep]
318 if get_option('gst-full-version-script') != ''
319 symbol_map = meson.current_source_dir() / get_option('gst-full-version-script')
320 link_arg = '-Wl,--version-script=' + symbol_map
321 if cc.has_link_argument(link_arg)
322 gstfull_link_args += link_arg
323 link_deps += symbol_map
324 elif cc.get_id() == 'msvc'
325 warning('FIXME: Provide a def file to publish the public symbols')
327 error('Failed to link with version script (' + symbol_map + '), check logs for details')
331 # Build both shared and static library
332 gstfull = both_libraries('gstreamer-full-1.0',
333 init_static_plugins_c,
334 link_with : all_plugins,
335 link_args: gstfull_link_args,
336 link_whole : exposed_libs,
337 dependencies : incdir_deps + glib_deps,
338 link_depends : link_deps,
342 gst_full_dep = declare_dependency(link_with: gstfull.get_shared_lib(),
343 dependencies : incdir_deps + glib_deps,
344 include_directories: include_directories('.')
347 gst_full_libs_private = cc.get_supported_link_arguments(['-Wl,--undefined=gst_init_static_plugins'])
348 if gst_full_libs_private == []
349 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.')
352 if not get_option('introspection').disabled()
354 foreach gir: exposed_girs
356 foreach include: gir.get('includes', [])
357 includes += [built_girs.get(include, include)]
361 'includes': includes,
362 'extra_args': gir.get('extra_args', []) + ['--add-include-path=' + meson.current_build_dir()],
365 built_girs += {gir.get('namespace') + '-' + gir.get('nsversion'): gnome.generate_gir(gstfull, kwargs: gir)[0]}
369 pkgconfig.generate(gstfull,
371 libraries_private: gst_full_libs_private,
372 subdirs : 'gstreamer-1.0')
373 meson.override_dependency('gstreamer-full-1.0', gst_full_dep)
376 foreach custom_subproj: get_option('custom_subprojects').split(',')
377 if custom_subproj != ''
378 message ('Adding custom subproject ' + custom_subproj)
379 subproject(custom_subproj)
380 subprojects_names += [custom_subproj]
384 message('Building subprojects: ' + ', '.join(subprojects_names))
386 setenv = find_program('gst-env.py')
387 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.project_build_root()),
388 '--gstbuilddir=@0@'.format(meson.current_build_dir()),
389 '--srcdir=@0@'.format(meson.project_source_root())]
392 if meson.can_run_host_binaries() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
393 # FIXME: Ideally we could get the wrapper directly from meson
394 devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
395 sysroot = meson.get_cross_property('sys_root')
398 devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
402 run_target('uninstalled', command : devenv_cmd)
403 run_target('devenv', command : devenv_cmd)
405 if orc_subproject.found() and orc_update_targets.length() > 0
406 alias_target('update-orc-dist', orc_update_targets)
410 'gstreamer-full': get_option('default_library') == 'static',
411 }, section: 'Build options', bool_yn: true, list_sep: ' ')