1 project('All GStreamer modules', 'c',
3 meson_version : '>= 0.54.0',
4 default_options : ['buildtype=debugoptimized'])
6 gst_version = '>= @0@'.format(meson.project_version())
9 build_system = build_machine.system()
10 cc = meson.get_compiler('c')
12 pkgconfig = import('pkgconfig')
13 python3 = import('python').find_installation()
14 # Ensure that we're not being run from inside the gst-uninstalled env
15 # because that will confuse meson, and it might find the already-built
16 # gstreamer. It's fine if people run `ninja` as long as it doesn't run
17 # reconfigure because ninja doesn't care about the env.
18 ensure_not_uninstalled = '''
20 assert('GST_ENV' not in os.environ)
22 cmdres = run_command(python3, '-c', ensure_not_uninstalled)
23 if cmdres.returncode() != 0
24 error('Do not run `ninja` or `meson` for gst-build inside the uninstalled environment, you will run into problems')
27 # Ensure that the user does not have Strawberry Perl in PATH, since it ships
28 # with a pkg-config.bat and broken pkgconfig files for libffi and zlib. Will
29 # cause a build error, such as in
30 # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/41
31 ensure_no_strawberry_perl = '''
33 assert(r'Strawberry\perl\bin' not in os.environ['PATH'])
35 if build_system == 'windows'
36 cmdres = run_command(python3, '-c', ensure_no_strawberry_perl)
37 if cmdres.returncode() != 0
38 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.')
42 documented_projects = ''
43 # Make it possible to use msys2 built zlib which fails
44 # when not using the mingw toolchain as it uses unistd.h
45 if not meson.is_subproject() and cc.get_id() == 'msvc'
46 uname = find_program('uname', required: false)
48 ret = run_command(uname, '-o')
49 if ret.returncode() == 0 and ret.stdout().to_lower() == 'msys'
50 ret = run_command(uname, '-r')
51 # The kernel version returned by uname is actually the msys version
52 if ret.returncode() == 0 and ret.stdout().startswith('2')
53 # If a system zlib is found, disable UNIX features in zlib.h and zconf.h
54 if cc.find_library('z').found()
55 add_global_arguments('-DZ_SOLO', language: 'c')
62 # Ordered list of subprojects (dict has no ordering guarantees)
64 ['gstreamer', {'build-hotdoc': true}],
65 ['gst-plugins-base', {'option': get_option('base'), 'build-hotdoc': true}],
66 ['gst-plugins-good', {'option': get_option('good'), 'build-hotdoc': true}],
67 ['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
68 ['gst-plugins-bad', { 'option': get_option('bad'), 'build-hotdoc': true}],
69 ['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true}],
70 ['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true}],
71 ['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true}],
72 ['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true }],
73 ['gst-integration-testsuites', { 'option': get_option('devtools') }],
74 ['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true}],
75 ['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true}],
76 ['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true}],
77 ['gstreamer-sharp', { 'option': get_option('sharp') }],
78 ['pygobject', { 'option': get_option('python'), 'match_gst_version': false }],
79 ['gst-python', { 'option': get_option('python')}],
80 ['gst-examples', { 'option': get_option('gst-examples'), 'match_gst_versions': false}],
81 ['gst-plugins-rs', { 'option': get_option('rs'), 'match_gst_version': false}],
87 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
88 os.path.join('@1@', '@0@'))
91 if build_system == 'windows'
92 subproject('win-flex-bison-binaries')
93 subproject('win-nasm')
96 orc_subproject = subproject('orc', required: get_option('orc'))
98 subprojects_names = []
99 plugins_doc_caches = []
100 orc_update_targets = []
102 foreach sp : subprojects
105 is_required = build_infos.get('option', true)
106 match_gst_version = build_infos.get('match_gst_version', true)
109 subproj = subproject(project_name, version: gst_version, required: is_required)
111 subproj = subproject(project_name, required: is_required)
115 plugins = subproj.get_variable('plugins', [])
116 all_plugins += plugins
118 orc_update_targets += subproj.get_variable('orc_update_targets', [])
120 subprojects_names += [project_name]
121 cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
122 if cmdres.returncode() == 0
123 message('Created symlink to ' + project_name)
126 if not meson.is_cross_build() and build_infos.get('build-hotdoc', false)
127 if plugins.length() > 0
128 plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
130 if documented_projects != ''
131 documented_projects += ','
133 documented_projects += project_name
138 # Check if we need to also build glib-networking for TLS modules
139 glib_dep = dependency('glib-2.0')
140 if glib_dep.type_name() == 'internal'
141 subproject('glib-networking', required : get_option('tls'),
142 default_options: ['gnutls=auto', 'openssl=auto'])
145 plugins_doc_dep = custom_target('plugins-doc-cache',
146 command: [python3, '-c', 'print("Built all doc caches")'],
147 input: plugins_doc_caches,
148 output: 'plugins_doc_caches',
152 if meson.is_cross_build() or build_machine.system() == 'windows'
153 if get_option('doc').enabled()
154 error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
157 documented_projects = ''
158 message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
160 hotdoc_p = find_program('hotdoc', required : get_option('doc'))
161 if not hotdoc_p.found()
162 documented_projects = ''
163 message('Not building documentation as hotdoc was not found')
167 write_file_contents = '''
171 assert len(sys.argv) >= 3
173 contents = sys.argv[2]
175 with open(fname, 'w') as f:
180 output : 'GstDocumentedSubprojects',
182 '-c', write_file_contents,
187 if documented_projects != ''
188 subproject('gst-docs', required: get_option('doc').enabled())
189 message('Gst docs subprojects: ' + documented_projects)
192 all_plugins_paths = []
193 foreach plugin: all_plugins
194 all_plugins_paths += plugin.full_path()
196 # Work around meson bug: https://github.com/mesonbuild/meson/pull/6770
197 pathsep = host_machine.system() == 'windows' ? ';' : ':'
198 all_plugins_paths = pathsep.join(all_plugins_paths)
200 generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
202 output : 'GstPluginsPath.json',
203 command : [generate_plugins_paths,
208 # FIXME: Create a 'libraries' list in each subproject like we do for 'plugins'
210 # name: [subproject_name, variable_name]
211 'gstreamer': ['gstreamer', 'libgst'],
212 'base': ['gstreamer', 'gst_base'],
213 'check': ['gstreamer', 'gst_check'],
214 'controller': ['gstreamer', 'gst_controller'],
215 'net': ['gstreamer', 'gst_net'],
217 'allocators': ['gst-plugins-base', 'gstallocators'],
218 'app': ['gst-plugins-base', 'gstapp'],
219 'audio': ['gst-plugins-base', 'gstaudio'],
220 'fft': ['gst-plugins-base', 'gstfft'],
221 'pbutils': ['gst-plugins-base', 'pbutils'],
222 'riff': ['gst-plugins-base', 'gstriff'],
223 'rtp': ['gst-plugins-base', 'gst_rtp'],
224 'rtsp': ['gst-plugins-base', 'gst_rtsp'],
225 'sdp': ['gst-plugins-base', 'gstsdp'],
226 'tag': ['gst-plugins-base', 'gsttag'],
227 'video': ['gst-plugins-base', 'gstvideo'],
228 'gl': ['gst-plugins-base', 'gstgl'],
230 'bad-audio': ['gst-plugins-bad', 'gstbadaudio'],
231 'bad-transcoder': ['gst-plugins-bad', 'gst_transcoder'],
232 'codecparsers': ['gst-plugins-bad', 'gstcodecparsers'],
233 'insertbin': ['gst-plugins-bad', 'gstinsertbin'],
234 'mpegts': ['gst-plugins-bad', 'gstmpegts'],
235 'player': ['gst-plugins-bad', 'gstplayer'],
236 'sctp': ['gst-plugins-bad', 'libgstsctp'],
237 'webrtc': ['gst-plugins-bad', 'gstwebrtc'],
238 'vulkan': ['gst-plugins-bad', 'gstvulkan'],
240 'rtsp-server': ['gst-rtsp-server', 'gst_rtsp_server'],
243 if get_option('default_library') == 'static'
244 if not get_option('introspection').disabled()
245 error('GObject Introspection is not supported in static builds. Please use -Dintrospection=disabled')
247 # Generate a .c file which declare and register all built plugins
249 foreach plugin: all_plugins
250 plugins_names += plugin.full_path()
252 all_plugin_names = ';'.join(plugins_names)
254 static_plugins = get_option('gst-full-plugins')
255 if static_plugins == '*'
256 static_plugins = all_plugin_names
258 generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
259 init_static_plugins_c = configure_file(
260 output: 'gstinitstaticplugins.c',
261 command : [generate_init_static_plugins,
263 '-p ' + static_plugins,
264 '-e ' + get_option('gst-full-elements'),
265 '-t ' + get_option('gst-full-typefind-functions'),
266 '-d ' + get_option('gst-full-device-providers'),
267 '-T ' + get_option('gst-full-dynamic-types')
271 gstfull_link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions'])
273 # Get a list of libraries that needs to be exposed in the ABI.
276 foreach name : get_option('gst-full-libraries') + ['gstreamer']
277 info = libraries_map[name]
278 exposed_libs += subproject(info[0]).get_variable(info[1])
279 depname = name == 'gstreamer' ? 'gstreamer-1.0' : 'gstreamer-@0@-1.0'.format(name)
280 incdir_deps += dependency(depname).partial_dependency(includes: true, sources: true)
283 # glib and gobject are part of our public API. If we are using glib from the
284 # system then our pkg-config file must require it. If we built it as
285 # subproject then we need to link_whole it.
287 glib_dep = dependency('glib-2.0')
288 gobject_dep = dependency('gobject-2.0')
289 if gobject_dep.type_name() == 'internal'
290 glib_subproject = subproject('glib')
291 exposed_libs += glib_subproject.get_variable('libglib')
292 exposed_libs += glib_subproject.get_variable('libgobject')
294 glib_dep.partial_dependency(includes: true),
295 gobject_dep.partial_dependency(includes: true),
298 glib_deps = [glib_dep, gobject_dep]
302 if get_option('gst-full-version-script') != ''
303 symbol_map = meson.current_source_dir() / get_option('gst-full-version-script')
304 link_arg = '-Wl,--version-script=' + symbol_map
305 if cc.has_link_argument(link_arg)
306 gstfull_link_args += link_arg
307 link_deps += symbol_map
308 elif cc.get_id() == 'msvc'
309 warning('FIXME: Provide a def file to publish the public symbols')
311 error('Failed to link with version script (' + symbol_map + '), check logs for details')
315 # Build both shared and static library
316 gstfull = both_libraries('gstreamer-full-1.0',
317 init_static_plugins_c,
318 link_with : all_plugins,
319 link_args: gstfull_link_args,
320 link_whole : exposed_libs,
321 dependencies : incdir_deps + glib_deps,
322 link_depends : link_deps,
326 gst_full_dep = declare_dependency(link_with: gstfull.get_shared_lib(),
327 dependencies : incdir_deps + glib_deps,
328 include_directories: include_directories('.')
330 gst_full_libs_private = cc.get_supported_link_arguments(['-Wl,--undefined=gst_init_static_plugins'])
331 if gst_full_libs_private == []
332 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.')
334 pkgconfig.generate(gstfull,
336 libraries_private: gst_full_libs_private,
337 subdirs : 'gstreamer-1.0')
338 meson.override_dependency('gstreamer-full-1.0', gst_full_dep)
341 foreach custom_subproj: get_option('custom_subprojects').split(',')
342 if custom_subproj != ''
343 message ('Adding custom subproject ' + custom_subproj)
344 subproject(custom_subproj)
345 subprojects_names += [custom_subproj]
349 message('Building subprojects: ' + ', '.join(subprojects_names))
353 setenv = find_program('gst-env.py')
355 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.build_root()),
356 '--gstbuilddir=@0@'.format(meson.current_build_dir()),
357 '--srcdir=@0@'.format(meson.source_root())]
359 if meson.has_exe_wrapper() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
360 # FIXME: Ideally we could get the wrapper directly from meson
361 devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
362 sysroot = meson.get_cross_property('sys_root')
365 devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
369 run_target('uninstalled', command : devenv_cmd)
370 run_target('devenv', command : devenv_cmd)
372 update = find_program('git-update')
373 run_target('git-update', command : [update])
374 run_target('update', command : [update,
375 '--builddir=@0@'.format(meson.current_build_dir())])
377 if orc_subproject.found() and orc_update_targets.length() > 0
378 alias_target('update-orc-dist', orc_update_targets)