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())
8 build_system = build_machine.system()
9 cc = meson.get_compiler('c')
11 pkgconfig = import('pkgconfig')
12 python3 = import('python').find_installation()
13 # Ensure that we're not being run from inside the gst-uninstalled env
14 # because that will confuse meson, and it might find the already-built
15 # gstreamer. It's fine if people run `ninja` as long as it doesn't run
16 # reconfigure because ninja doesn't care about the env.
17 ensure_not_uninstalled = '''
19 assert('GST_ENV' not in os.environ)
21 cmdres = run_command(python3, '-c', ensure_not_uninstalled)
22 if cmdres.returncode() != 0
23 error('Do not run `ninja` or `meson` for gst-build inside the uninstalled environment, you will run into problems')
26 # Install gst-indent pre-commit hook
27 run_command(python3, '-c', 'import shutil; shutil.copy("scripts/git-hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")')
29 # Ensure that the user does not have Strawberry Perl in PATH, since it ships
30 # with a pkg-config.bat and broken pkgconfig files for libffi and zlib. Will
31 # cause a build error, such as in
32 # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/41
33 ensure_no_strawberry_perl = '''
35 assert(r'Strawberry\perl\bin' not in os.environ['PATH'])
37 if build_system == 'windows'
38 cmdres = run_command(python3, '-c', ensure_no_strawberry_perl)
39 if cmdres.returncode() != 0
40 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.')
44 documented_projects = ''
45 # Make it possible to use msys2 built zlib which fails
46 # when not using the mingw toolchain as it uses unistd.h
47 if not meson.is_subproject() and cc.get_id() == 'msvc'
48 uname = find_program('uname', required: false)
50 ret = run_command(uname, '-o')
51 if ret.returncode() == 0 and ret.stdout().to_lower() == 'msys'
52 ret = run_command(uname, '-r')
53 # The kernel version returned by uname is actually the msys version
54 if ret.returncode() == 0 and ret.stdout().startswith('2')
55 # If a system zlib is found, disable UNIX features in zlib.h and zconf.h
56 if cc.find_library('z').found()
57 add_global_arguments('-DZ_SOLO', language: 'c')
64 # Ensure that MSVC interprets all source code as UTF-8. Only do this when we're
65 # not a subproject, because subprojects are not allowed to call
66 # add_global_arguments().
67 if not meson.is_subproject() and cc.get_id() == 'msvc'
69 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
70 language: ['c', 'cpp'])
73 # Ordered list of subprojects (dict has no ordering guarantees)
75 ['gstreamer', {'build-hotdoc': true}],
76 ['gst-plugins-base', {'option': get_option('base'), 'build-hotdoc': true}],
77 ['gst-plugins-good', {'option': get_option('good'), 'build-hotdoc': true}],
78 ['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
79 ['gst-plugins-bad', { 'option': get_option('bad'), 'build-hotdoc': true}],
80 ['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true}],
81 ['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true}],
82 ['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true}],
83 ['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true }],
84 ['gst-integration-testsuites', { 'option': get_option('devtools') }],
85 ['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true}],
86 ['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true}],
87 ['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true}],
88 ['gstreamer-sharp', { 'option': get_option('sharp') }],
89 ['pygobject', { 'option': get_option('python'), 'match_gst_version': false }],
90 ['gst-python', { 'option': get_option('python')}],
91 ['gst-examples', { 'option': get_option('gst-examples'), 'match_gst_versions': false}],
92 ['gst-plugins-rs', { 'option': get_option('rs'), 'match_gst_version': false}],
98 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
99 os.path.join('@1@', '@0@'))
102 if build_system == 'windows'
103 subproject('win-flex-bison-binaries')
104 subproject('win-nasm')
105 elif build_system == 'darwin'
106 subproject('macos-bison-binary')
109 orc_subproject = subproject('orc', required: get_option('orc'))
111 subprojects_names = []
112 plugins_doc_caches = []
113 orc_update_targets = []
115 foreach sp : subprojects
118 is_required = build_infos.get('option', true)
119 match_gst_version = build_infos.get('match_gst_version', true)
122 subproj = subproject(project_name, version: gst_version, required: is_required)
124 subproj = subproject(project_name, required: is_required)
128 plugins = subproj.get_variable('plugins', [])
129 all_plugins += plugins
131 orc_update_targets += subproj.get_variable('orc_update_targets', [])
133 subprojects_names += [project_name]
134 cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
135 if cmdres.returncode() == 0
136 message('Created symlink to ' + project_name)
139 if not meson.is_cross_build() and build_infos.get('build-hotdoc', false)
140 if plugins.length() > 0
141 plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
143 if documented_projects != ''
144 documented_projects += ','
146 documented_projects += project_name
151 # Check if we need to also build glib-networking for TLS modules
152 glib_dep = dependency('glib-2.0')
153 if glib_dep.type_name() == 'internal'
154 subproject('glib-networking', required : get_option('tls'),
155 default_options: ['gnutls=auto', 'openssl=auto'])
158 plugins_doc_dep = custom_target('plugins-doc-cache',
159 command: [python3, '-c', 'print("Built all doc caches")'],
160 input: plugins_doc_caches,
161 output: 'plugins_doc_caches',
165 if meson.is_cross_build() or build_machine.system() == 'windows'
166 if get_option('doc').enabled()
167 error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
170 documented_projects = ''
171 message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
173 hotdoc_p = find_program('hotdoc', required : get_option('doc'))
174 if not hotdoc_p.found()
175 documented_projects = ''
176 message('Not building documentation as hotdoc was not found')
180 write_file_contents = '''
184 assert len(sys.argv) >= 3
186 contents = sys.argv[2]
188 with open(fname, 'w') as f:
193 output : 'GstDocumentedSubprojects',
195 '-c', write_file_contents,
200 if documented_projects != ''
201 subproject('gst-docs', required: get_option('doc').enabled())
202 message('Gst docs subprojects: ' + documented_projects)
205 all_plugins_paths = []
206 foreach plugin: all_plugins
207 all_plugins_paths += plugin.full_path()
209 # Work around meson bug: https://github.com/mesonbuild/meson/pull/6770
210 pathsep = host_machine.system() == 'windows' ? ';' : ':'
211 all_plugins_paths = pathsep.join(all_plugins_paths)
213 generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
215 output : 'GstPluginsPath.json',
216 command : [generate_plugins_paths,
221 # FIXME: Create a 'libraries' list in each subproject like we do for 'plugins'
223 # name: [subproject_name, variable_name]
224 'gstreamer': ['gstreamer', 'libgst'],
225 'base': ['gstreamer', 'gst_base'],
226 'check': ['gstreamer', 'gst_check'],
227 'controller': ['gstreamer', 'gst_controller'],
228 'net': ['gstreamer', 'gst_net'],
230 'allocators': ['gst-plugins-base', 'gstallocators'],
231 'app': ['gst-plugins-base', 'gstapp'],
232 'audio': ['gst-plugins-base', 'gstaudio'],
233 'fft': ['gst-plugins-base', 'gstfft'],
234 'pbutils': ['gst-plugins-base', 'pbutils'],
235 'riff': ['gst-plugins-base', 'gstriff'],
236 'rtp': ['gst-plugins-base', 'gst_rtp'],
237 'rtsp': ['gst-plugins-base', 'gst_rtsp'],
238 'sdp': ['gst-plugins-base', 'gstsdp'],
239 'tag': ['gst-plugins-base', 'gsttag'],
240 'video': ['gst-plugins-base', 'gstvideo'],
241 'gl': ['gst-plugins-base', 'gstgl'],
243 'bad-audio': ['gst-plugins-bad', 'gstbadaudio'],
244 'bad-transcoder': ['gst-plugins-bad', 'gst_transcoder'],
245 'codecparsers': ['gst-plugins-bad', 'gstcodecparsers'],
246 'insertbin': ['gst-plugins-bad', 'gstinsertbin'],
247 'mpegts': ['gst-plugins-bad', 'gstmpegts'],
248 'player': ['gst-plugins-bad', 'gstplayer'],
249 'sctp': ['gst-plugins-bad', 'libgstsctp'],
250 'webrtc': ['gst-plugins-bad', 'gstwebrtc'],
251 'vulkan': ['gst-plugins-bad', 'gstvulkan'],
253 'rtsp-server': ['gst-rtsp-server', 'gst_rtsp_server'],
256 if get_option('default_library') == 'static'
257 if not get_option('introspection').disabled()
258 error('GObject Introspection is not supported in static builds. Please use -Dintrospection=disabled')
260 # Generate a .c file which declare and register all built plugins
262 foreach plugin: all_plugins
263 plugins_names += plugin.full_path()
265 all_plugin_names = ';'.join(plugins_names)
267 static_plugins = get_option('gst-full-plugins')
268 if static_plugins == '*'
269 static_plugins = all_plugin_names
271 generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
272 init_static_plugins_c = configure_file(
273 output: 'gstinitstaticplugins.c',
274 command : [generate_init_static_plugins,
276 '-p ' + static_plugins,
277 '-e ' + get_option('gst-full-elements'),
278 '-t ' + get_option('gst-full-typefind-functions'),
279 '-d ' + get_option('gst-full-device-providers'),
280 '-T ' + get_option('gst-full-dynamic-types')
284 gstfull_link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions'])
286 # Get a list of libraries that needs to be exposed in the ABI.
289 foreach name : get_option('gst-full-libraries') + ['gstreamer']
290 info = libraries_map[name]
291 exposed_libs += subproject(info[0]).get_variable(info[1])
292 depname = name == 'gstreamer' ? 'gstreamer-1.0' : 'gstreamer-@0@-1.0'.format(name)
293 incdir_deps += dependency(depname).partial_dependency(includes: true, sources: true)
296 # glib and gobject are part of our public API. If we are using glib from the
297 # system then our pkg-config file must require it. If we built it as
298 # subproject then we need to link_whole it.
300 glib_dep = dependency('glib-2.0')
301 gobject_dep = dependency('gobject-2.0')
302 if gobject_dep.type_name() == 'internal'
303 glib_subproject = subproject('glib')
304 exposed_libs += glib_subproject.get_variable('libglib')
305 exposed_libs += glib_subproject.get_variable('libgobject')
307 glib_dep.partial_dependency(includes: true),
308 gobject_dep.partial_dependency(includes: true),
311 glib_deps = [glib_dep, gobject_dep]
315 if get_option('gst-full-version-script') != ''
316 symbol_map = meson.current_source_dir() / get_option('gst-full-version-script')
317 link_arg = '-Wl,--version-script=' + symbol_map
318 if cc.has_link_argument(link_arg)
319 gstfull_link_args += link_arg
320 link_deps += symbol_map
321 elif cc.get_id() == 'msvc'
322 warning('FIXME: Provide a def file to publish the public symbols')
324 error('Failed to link with version script (' + symbol_map + '), check logs for details')
328 # Build both shared and static library
329 gstfull = both_libraries('gstreamer-full-1.0',
330 init_static_plugins_c,
331 link_with : all_plugins,
332 link_args: gstfull_link_args,
333 link_whole : exposed_libs,
334 dependencies : incdir_deps + glib_deps,
335 link_depends : link_deps,
339 gst_full_dep = declare_dependency(link_with: gstfull.get_shared_lib(),
340 dependencies : incdir_deps + glib_deps,
341 include_directories: include_directories('.')
343 gst_full_libs_private = cc.get_supported_link_arguments(['-Wl,--undefined=gst_init_static_plugins'])
344 if gst_full_libs_private == []
345 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.')
347 pkgconfig.generate(gstfull,
349 libraries_private: gst_full_libs_private,
350 subdirs : 'gstreamer-1.0')
351 meson.override_dependency('gstreamer-full-1.0', gst_full_dep)
354 foreach custom_subproj: get_option('custom_subprojects').split(',')
355 if custom_subproj != ''
356 message ('Adding custom subproject ' + custom_subproj)
357 subproject(custom_subproj)
358 subprojects_names += [custom_subproj]
362 message('Building subprojects: ' + ', '.join(subprojects_names))
366 setenv = find_program('gst-env.py')
368 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.build_root()),
369 '--gstbuilddir=@0@'.format(meson.current_build_dir()),
370 '--srcdir=@0@'.format(meson.source_root())]
372 if meson.has_exe_wrapper() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
373 # FIXME: Ideally we could get the wrapper directly from meson
374 devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
375 sysroot = meson.get_cross_property('sys_root')
378 devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
382 run_target('uninstalled', command : devenv_cmd)
383 run_target('devenv', command : devenv_cmd)
385 if orc_subproject.found() and orc_update_targets.length() > 0
386 alias_target('update-orc-dist', orc_update_targets)