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 # Install gst-indent pre-commit hook
28 run_command(python3, '-c', 'import shutil; shutil.copy("scripts/git-hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")')
30 # Ensure that the user does not have Strawberry Perl in PATH, since it ships
31 # with a pkg-config.bat and broken pkgconfig files for libffi and zlib. Will
32 # cause a build error, such as in
33 # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/41
34 ensure_no_strawberry_perl = '''
36 assert(r'Strawberry\perl\bin' not in os.environ['PATH'])
38 if build_system == 'windows'
39 cmdres = run_command(python3, '-c', ensure_no_strawberry_perl)
40 if cmdres.returncode() != 0
41 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.')
45 documented_projects = ''
46 # Make it possible to use msys2 built zlib which fails
47 # when not using the mingw toolchain as it uses unistd.h
48 if not meson.is_subproject() and cc.get_id() == 'msvc'
49 uname = find_program('uname', required: false)
51 ret = run_command(uname, '-o')
52 if ret.returncode() == 0 and ret.stdout().to_lower() == 'msys'
53 ret = run_command(uname, '-r')
54 # The kernel version returned by uname is actually the msys version
55 if ret.returncode() == 0 and ret.stdout().startswith('2')
56 # If a system zlib is found, disable UNIX features in zlib.h and zconf.h
57 if cc.find_library('z').found()
58 add_global_arguments('-DZ_SOLO', language: 'c')
65 # Ensure that MSVC interprets all source code as UTF-8. Only do this when we're
66 # not a subproject, because subprojects are not allowed to call
67 # add_global_arguments().
68 if not meson.is_subproject() and cc.get_id() == 'msvc'
70 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
71 language: ['c', 'cpp'])
74 # Ordered list of subprojects (dict has no ordering guarantees)
76 ['gstreamer', {'build-hotdoc': true}],
77 ['gst-plugins-base', {'option': get_option('base'), 'build-hotdoc': true}],
78 ['gst-plugins-good', {'option': get_option('good'), 'build-hotdoc': true}],
79 ['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
80 ['gst-plugins-bad', { 'option': get_option('bad'), 'build-hotdoc': true}],
81 ['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true}],
82 ['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true}],
83 ['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true}],
84 ['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true }],
85 ['gst-integration-testsuites', { 'option': get_option('devtools') }],
86 ['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true}],
87 ['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true}],
88 ['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true}],
89 ['gstreamer-sharp', { 'option': get_option('sharp') }],
90 ['pygobject', { 'option': get_option('python'), 'match_gst_version': false }],
91 ['gst-python', { 'option': get_option('python')}],
92 ['gst-examples', { 'option': get_option('gst-examples'), 'match_gst_versions': false}],
93 ['gst-plugins-rs', { 'option': get_option('rs'), 'match_gst_version': false}],
99 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
100 os.path.join('@1@', '@0@'))
103 if build_system == 'windows'
104 subproject('win-flex-bison-binaries')
105 subproject('win-nasm')
106 elif build_system == 'darwin'
107 subproject('macos-bison-binary')
110 orc_subproject = subproject('orc', required: get_option('orc'))
112 subprojects_names = []
113 plugins_doc_caches = []
114 orc_update_targets = []
116 foreach sp : subprojects
119 is_required = build_infos.get('option', true)
120 match_gst_version = build_infos.get('match_gst_version', true)
123 subproj = subproject(project_name, version: gst_version, required: is_required)
125 subproj = subproject(project_name, required: is_required)
129 plugins = subproj.get_variable('plugins', [])
130 all_plugins += plugins
132 orc_update_targets += subproj.get_variable('orc_update_targets', [])
134 subprojects_names += [project_name]
135 cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
136 if cmdres.returncode() == 0
137 message('Created symlink to ' + project_name)
140 if not meson.is_cross_build() and build_infos.get('build-hotdoc', false)
141 if plugins.length() > 0
142 plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
144 if documented_projects != ''
145 documented_projects += ','
147 documented_projects += project_name
152 # Check if we need to also build glib-networking for TLS modules
153 glib_dep = dependency('glib-2.0')
154 if glib_dep.type_name() == 'internal'
155 subproject('glib-networking', required : get_option('tls'),
156 default_options: ['gnutls=auto', 'openssl=auto'])
159 plugins_doc_dep = custom_target('plugins-doc-cache',
160 command: [python3, '-c', 'print("Built all doc caches")'],
161 input: plugins_doc_caches,
162 output: 'plugins_doc_caches',
166 if meson.is_cross_build() or build_machine.system() == 'windows'
167 if get_option('doc').enabled()
168 error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
171 documented_projects = ''
172 message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
174 hotdoc_p = find_program('hotdoc', required : get_option('doc'))
175 if not hotdoc_p.found()
176 documented_projects = ''
177 message('Not building documentation as hotdoc was not found')
181 write_file_contents = '''
185 assert len(sys.argv) >= 3
187 contents = sys.argv[2]
189 with open(fname, 'w') as f:
194 output : 'GstDocumentedSubprojects',
196 '-c', write_file_contents,
201 if documented_projects != ''
202 subproject('gst-docs', required: get_option('doc').enabled())
203 message('Gst docs subprojects: ' + documented_projects)
206 all_plugins_paths = []
207 foreach plugin: all_plugins
208 all_plugins_paths += plugin.full_path()
210 # Work around meson bug: https://github.com/mesonbuild/meson/pull/6770
211 pathsep = host_machine.system() == 'windows' ? ';' : ':'
212 all_plugins_paths = pathsep.join(all_plugins_paths)
214 generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
216 output : 'GstPluginsPath.json',
217 command : [generate_plugins_paths,
222 # FIXME: Create a 'libraries' list in each subproject like we do for 'plugins'
224 # name: [subproject_name, variable_name]
225 'gstreamer': ['gstreamer', 'libgst'],
226 'base': ['gstreamer', 'gst_base'],
227 'check': ['gstreamer', 'gst_check'],
228 'controller': ['gstreamer', 'gst_controller'],
229 'net': ['gstreamer', 'gst_net'],
231 'allocators': ['gst-plugins-base', 'gstallocators'],
232 'app': ['gst-plugins-base', 'gstapp'],
233 'audio': ['gst-plugins-base', 'gstaudio'],
234 'fft': ['gst-plugins-base', 'gstfft'],
235 'pbutils': ['gst-plugins-base', 'pbutils'],
236 'riff': ['gst-plugins-base', 'gstriff'],
237 'rtp': ['gst-plugins-base', 'gst_rtp'],
238 'rtsp': ['gst-plugins-base', 'gst_rtsp'],
239 'sdp': ['gst-plugins-base', 'gstsdp'],
240 'tag': ['gst-plugins-base', 'gsttag'],
241 'video': ['gst-plugins-base', 'gstvideo'],
242 'gl': ['gst-plugins-base', 'gstgl'],
244 'bad-audio': ['gst-plugins-bad', 'gstbadaudio'],
245 'bad-transcoder': ['gst-plugins-bad', 'gst_transcoder'],
246 'codecparsers': ['gst-plugins-bad', 'gstcodecparsers'],
247 'insertbin': ['gst-plugins-bad', 'gstinsertbin'],
248 'mpegts': ['gst-plugins-bad', 'gstmpegts'],
249 'player': ['gst-plugins-bad', 'gstplayer'],
250 'sctp': ['gst-plugins-bad', 'libgstsctp'],
251 'webrtc': ['gst-plugins-bad', 'gstwebrtc'],
252 'vulkan': ['gst-plugins-bad', 'gstvulkan'],
254 'rtsp-server': ['gst-rtsp-server', 'gst_rtsp_server'],
257 if get_option('default_library') == 'static'
258 if not get_option('introspection').disabled()
259 error('GObject Introspection is not supported in static builds. Please use -Dintrospection=disabled')
261 # Generate a .c file which declare and register all built plugins
263 foreach plugin: all_plugins
264 plugins_names += plugin.full_path()
266 all_plugin_names = ';'.join(plugins_names)
268 static_plugins = get_option('gst-full-plugins')
269 if static_plugins == '*'
270 static_plugins = all_plugin_names
272 generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
273 init_static_plugins_c = configure_file(
274 output: 'gstinitstaticplugins.c',
275 command : [generate_init_static_plugins,
277 '-p ' + static_plugins,
278 '-e ' + get_option('gst-full-elements'),
279 '-t ' + get_option('gst-full-typefind-functions'),
280 '-d ' + get_option('gst-full-device-providers'),
281 '-T ' + get_option('gst-full-dynamic-types')
285 gstfull_link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions'])
287 # Get a list of libraries that needs to be exposed in the ABI.
290 foreach name : get_option('gst-full-libraries') + ['gstreamer']
291 info = libraries_map[name]
292 exposed_libs += subproject(info[0]).get_variable(info[1])
293 depname = name == 'gstreamer' ? 'gstreamer-1.0' : 'gstreamer-@0@-1.0'.format(name)
294 incdir_deps += dependency(depname).partial_dependency(includes: true, sources: true)
297 # glib and gobject are part of our public API. If we are using glib from the
298 # system then our pkg-config file must require it. If we built it as
299 # subproject then we need to link_whole it.
301 glib_dep = dependency('glib-2.0')
302 gobject_dep = dependency('gobject-2.0')
303 if gobject_dep.type_name() == 'internal'
304 glib_subproject = subproject('glib')
305 exposed_libs += glib_subproject.get_variable('libglib')
306 exposed_libs += glib_subproject.get_variable('libgobject')
308 glib_dep.partial_dependency(includes: true),
309 gobject_dep.partial_dependency(includes: true),
312 glib_deps = [glib_dep, gobject_dep]
316 if get_option('gst-full-version-script') != ''
317 symbol_map = meson.current_source_dir() / get_option('gst-full-version-script')
318 link_arg = '-Wl,--version-script=' + symbol_map
319 if cc.has_link_argument(link_arg)
320 gstfull_link_args += link_arg
321 link_deps += symbol_map
322 elif cc.get_id() == 'msvc'
323 warning('FIXME: Provide a def file to publish the public symbols')
325 error('Failed to link with version script (' + symbol_map + '), check logs for details')
329 # Build both shared and static library
330 gstfull = both_libraries('gstreamer-full-1.0',
331 init_static_plugins_c,
332 link_with : all_plugins,
333 link_args: gstfull_link_args,
334 link_whole : exposed_libs,
335 dependencies : incdir_deps + glib_deps,
336 link_depends : link_deps,
340 gst_full_dep = declare_dependency(link_with: gstfull.get_shared_lib(),
341 dependencies : incdir_deps + glib_deps,
342 include_directories: include_directories('.')
344 gst_full_libs_private = cc.get_supported_link_arguments(['-Wl,--undefined=gst_init_static_plugins'])
345 if gst_full_libs_private == []
346 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.')
348 pkgconfig.generate(gstfull,
350 libraries_private: gst_full_libs_private,
351 subdirs : 'gstreamer-1.0')
352 meson.override_dependency('gstreamer-full-1.0', gst_full_dep)
355 foreach custom_subproj: get_option('custom_subprojects').split(',')
356 if custom_subproj != ''
357 message ('Adding custom subproject ' + custom_subproj)
358 subproject(custom_subproj)
359 subprojects_names += [custom_subproj]
363 message('Building subprojects: ' + ', '.join(subprojects_names))
367 setenv = find_program('gst-env.py')
369 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.build_root()),
370 '--gstbuilddir=@0@'.format(meson.current_build_dir()),
371 '--srcdir=@0@'.format(meson.source_root())]
373 if meson.has_exe_wrapper() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
374 # FIXME: Ideally we could get the wrapper directly from meson
375 devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
376 sysroot = meson.get_cross_property('sys_root')
379 devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
383 run_target('uninstalled', command : devenv_cmd)
384 run_target('devenv', command : devenv_cmd)
386 if orc_subproject.found() and orc_update_targets.length() > 0
387 alias_target('update-orc-dist', orc_update_targets)