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 # Ensure that MSVC interprets all source code as UTF-8. Only do this when we're
63 # not a subproject, because subprojects are not allowed to call
64 # add_global_arguments().
65 if not meson.is_subproject() and cc.get_id() == 'msvc'
67 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
68 language: ['c', 'cpp'])
71 # Ordered list of subprojects (dict has no ordering guarantees)
73 ['gstreamer', {'build-hotdoc': true}],
74 ['gst-plugins-base', {'option': get_option('base'), 'build-hotdoc': true}],
75 ['gst-plugins-good', {'option': get_option('good'), 'build-hotdoc': true}],
76 ['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
77 ['gst-plugins-bad', { 'option': get_option('bad'), 'build-hotdoc': true}],
78 ['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true}],
79 ['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true}],
80 ['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true}],
81 ['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true }],
82 ['gst-integration-testsuites', { 'option': get_option('devtools') }],
83 ['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true}],
84 ['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true}],
85 ['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true}],
86 ['gstreamer-sharp', { 'option': get_option('sharp') }],
87 ['pygobject', { 'option': get_option('python'), 'match_gst_version': false }],
88 ['gst-python', { 'option': get_option('python')}],
89 ['gst-examples', { 'option': get_option('gst-examples'), 'match_gst_versions': false}],
90 ['gst-plugins-rs', { 'option': get_option('rs'), 'match_gst_version': false}],
96 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
97 os.path.join('@1@', '@0@'))
100 if build_system == 'windows'
101 subproject('win-flex-bison-binaries')
102 subproject('win-nasm')
103 elif build_system == 'darwin'
104 subproject('macos-bison-binary')
107 orc_subproject = subproject('orc', required: get_option('orc'))
109 subprojects_names = []
110 plugins_doc_caches = []
111 orc_update_targets = []
113 foreach sp : subprojects
116 is_required = build_infos.get('option', true)
117 match_gst_version = build_infos.get('match_gst_version', true)
120 subproj = subproject(project_name, version: gst_version, required: is_required)
122 subproj = subproject(project_name, required: is_required)
126 plugins = subproj.get_variable('plugins', [])
127 all_plugins += plugins
129 orc_update_targets += subproj.get_variable('orc_update_targets', [])
131 subprojects_names += [project_name]
132 cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
133 if cmdres.returncode() == 0
134 message('Created symlink to ' + project_name)
137 if not meson.is_cross_build() and build_infos.get('build-hotdoc', false)
138 if plugins.length() > 0
139 plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
141 if documented_projects != ''
142 documented_projects += ','
144 documented_projects += project_name
149 # Check if we need to also build glib-networking for TLS modules
150 glib_dep = dependency('glib-2.0')
151 if glib_dep.type_name() == 'internal'
152 subproject('glib-networking', required : get_option('tls'),
153 default_options: ['gnutls=auto', 'openssl=auto'])
156 plugins_doc_dep = custom_target('plugins-doc-cache',
157 command: [python3, '-c', 'print("Built all doc caches")'],
158 input: plugins_doc_caches,
159 output: 'plugins_doc_caches',
163 if meson.is_cross_build() or build_machine.system() == 'windows'
164 if get_option('doc').enabled()
165 error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
168 documented_projects = ''
169 message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
171 hotdoc_p = find_program('hotdoc', required : get_option('doc'))
172 if not hotdoc_p.found()
173 documented_projects = ''
174 message('Not building documentation as hotdoc was not found')
178 write_file_contents = '''
182 assert len(sys.argv) >= 3
184 contents = sys.argv[2]
186 with open(fname, 'w') as f:
191 output : 'GstDocumentedSubprojects',
193 '-c', write_file_contents,
198 if documented_projects != ''
199 subproject('gst-docs', required: get_option('doc').enabled())
200 message('Gst docs subprojects: ' + documented_projects)
203 all_plugins_paths = []
204 foreach plugin: all_plugins
205 all_plugins_paths += plugin.full_path()
207 # Work around meson bug: https://github.com/mesonbuild/meson/pull/6770
208 pathsep = host_machine.system() == 'windows' ? ';' : ':'
209 all_plugins_paths = pathsep.join(all_plugins_paths)
211 generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
213 output : 'GstPluginsPath.json',
214 command : [generate_plugins_paths,
219 # FIXME: Create a 'libraries' list in each subproject like we do for 'plugins'
221 # name: [subproject_name, variable_name]
222 'gstreamer': ['gstreamer', 'libgst'],
223 'base': ['gstreamer', 'gst_base'],
224 'check': ['gstreamer', 'gst_check'],
225 'controller': ['gstreamer', 'gst_controller'],
226 'net': ['gstreamer', 'gst_net'],
228 'allocators': ['gst-plugins-base', 'gstallocators'],
229 'app': ['gst-plugins-base', 'gstapp'],
230 'audio': ['gst-plugins-base', 'gstaudio'],
231 'fft': ['gst-plugins-base', 'gstfft'],
232 'pbutils': ['gst-plugins-base', 'pbutils'],
233 'riff': ['gst-plugins-base', 'gstriff'],
234 'rtp': ['gst-plugins-base', 'gst_rtp'],
235 'rtsp': ['gst-plugins-base', 'gst_rtsp'],
236 'sdp': ['gst-plugins-base', 'gstsdp'],
237 'tag': ['gst-plugins-base', 'gsttag'],
238 'video': ['gst-plugins-base', 'gstvideo'],
239 'gl': ['gst-plugins-base', 'gstgl'],
241 'bad-audio': ['gst-plugins-bad', 'gstbadaudio'],
242 'bad-transcoder': ['gst-plugins-bad', 'gst_transcoder'],
243 'codecparsers': ['gst-plugins-bad', 'gstcodecparsers'],
244 'insertbin': ['gst-plugins-bad', 'gstinsertbin'],
245 'mpegts': ['gst-plugins-bad', 'gstmpegts'],
246 'player': ['gst-plugins-bad', 'gstplayer'],
247 'sctp': ['gst-plugins-bad', 'libgstsctp'],
248 'webrtc': ['gst-plugins-bad', 'gstwebrtc'],
249 'vulkan': ['gst-plugins-bad', 'gstvulkan'],
251 'rtsp-server': ['gst-rtsp-server', 'gst_rtsp_server'],
254 if get_option('default_library') == 'static'
255 if not get_option('introspection').disabled()
256 error('GObject Introspection is not supported in static builds. Please use -Dintrospection=disabled')
258 # Generate a .c file which declare and register all built plugins
260 foreach plugin: all_plugins
261 plugins_names += plugin.full_path()
263 all_plugin_names = ';'.join(plugins_names)
265 static_plugins = get_option('gst-full-plugins')
266 if static_plugins == '*'
267 static_plugins = all_plugin_names
269 generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
270 init_static_plugins_c = configure_file(
271 output: 'gstinitstaticplugins.c',
272 command : [generate_init_static_plugins,
274 '-p ' + static_plugins,
275 '-e ' + get_option('gst-full-elements'),
276 '-t ' + get_option('gst-full-typefind-functions'),
277 '-d ' + get_option('gst-full-device-providers'),
278 '-T ' + get_option('gst-full-dynamic-types')
282 gstfull_link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions'])
284 # Get a list of libraries that needs to be exposed in the ABI.
287 foreach name : get_option('gst-full-libraries') + ['gstreamer']
288 info = libraries_map[name]
289 exposed_libs += subproject(info[0]).get_variable(info[1])
290 depname = name == 'gstreamer' ? 'gstreamer-1.0' : 'gstreamer-@0@-1.0'.format(name)
291 incdir_deps += dependency(depname).partial_dependency(includes: true, sources: true)
294 # glib and gobject are part of our public API. If we are using glib from the
295 # system then our pkg-config file must require it. If we built it as
296 # subproject then we need to link_whole it.
298 glib_dep = dependency('glib-2.0')
299 gobject_dep = dependency('gobject-2.0')
300 if gobject_dep.type_name() == 'internal'
301 glib_subproject = subproject('glib')
302 exposed_libs += glib_subproject.get_variable('libglib')
303 exposed_libs += glib_subproject.get_variable('libgobject')
305 glib_dep.partial_dependency(includes: true),
306 gobject_dep.partial_dependency(includes: true),
309 glib_deps = [glib_dep, gobject_dep]
313 if get_option('gst-full-version-script') != ''
314 symbol_map = meson.current_source_dir() / get_option('gst-full-version-script')
315 link_arg = '-Wl,--version-script=' + symbol_map
316 if cc.has_link_argument(link_arg)
317 gstfull_link_args += link_arg
318 link_deps += symbol_map
319 elif cc.get_id() == 'msvc'
320 warning('FIXME: Provide a def file to publish the public symbols')
322 error('Failed to link with version script (' + symbol_map + '), check logs for details')
326 # Build both shared and static library
327 gstfull = both_libraries('gstreamer-full-1.0',
328 init_static_plugins_c,
329 link_with : all_plugins,
330 link_args: gstfull_link_args,
331 link_whole : exposed_libs,
332 dependencies : incdir_deps + glib_deps,
333 link_depends : link_deps,
337 gst_full_dep = declare_dependency(link_with: gstfull.get_shared_lib(),
338 dependencies : incdir_deps + glib_deps,
339 include_directories: include_directories('.')
341 gst_full_libs_private = cc.get_supported_link_arguments(['-Wl,--undefined=gst_init_static_plugins'])
342 if gst_full_libs_private == []
343 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.')
345 pkgconfig.generate(gstfull,
347 libraries_private: gst_full_libs_private,
348 subdirs : 'gstreamer-1.0')
349 meson.override_dependency('gstreamer-full-1.0', gst_full_dep)
352 foreach custom_subproj: get_option('custom_subprojects').split(',')
353 if custom_subproj != ''
354 message ('Adding custom subproject ' + custom_subproj)
355 subproject(custom_subproj)
356 subprojects_names += [custom_subproj]
360 message('Building subprojects: ' + ', '.join(subprojects_names))
364 setenv = find_program('gst-env.py')
366 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.build_root()),
367 '--gstbuilddir=@0@'.format(meson.current_build_dir()),
368 '--srcdir=@0@'.format(meson.source_root())]
370 if meson.has_exe_wrapper() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
371 # FIXME: Ideally we could get the wrapper directly from meson
372 devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
373 sysroot = meson.get_cross_property('sys_root')
376 devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
380 run_target('uninstalled', command : devenv_cmd)
381 run_target('devenv', command : devenv_cmd)
383 update = find_program('git-update')
384 run_target('git-update', command : [update])
385 run_target('update', command : [update,
386 '--builddir=@0@'.format(meson.current_build_dir())])
388 if orc_subproject.found() and orc_update_targets.length() > 0
389 alias_target('update-orc-dist', orc_update_targets)