1 project('All GStreamer modules', 'c',
3 meson_version : '>= 0.52.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')
61 # Change some warning which belong to level 3 (production quality) or
62 # 4 (informational) to level 1 (severe)
63 add_global_arguments (
64 '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
65 '/w14101', # 'identifier' : unreferenced local variable
66 '/w14189', # 'identifier' : local variable is initialized but not referenced
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')
105 orc_subproject = subproject('orc', required: get_option('orc'))
107 subprojects_names = []
108 plugins_doc_caches = []
109 orc_update_targets = []
111 foreach sp : subprojects
114 is_required = build_infos.get('option', true)
115 match_gst_version = build_infos.get('match_gst_version', true)
118 subproj = subproject(project_name, version: gst_version, required: is_required)
120 subproj = subproject(project_name, required: is_required)
124 plugins = subproj.get_variable('plugins', [])
125 all_plugins += plugins
127 orc_update_targets += subproj.get_variable('orc_update_targets', [])
129 subprojects_names += [project_name]
130 cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
131 if cmdres.returncode() == 0
132 message('Created symlink to ' + project_name)
135 if not meson.is_cross_build() and build_infos.get('build-hotdoc', false)
136 if plugins.length() > 0
137 plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
139 if documented_projects != ''
140 documented_projects += ','
142 documented_projects += project_name
147 # Check if we need to also build glib-networking for TLS modules
148 glib_dep = dependency('glib-2.0')
149 if glib_dep.type_name() == 'internal'
150 subproject('glib-networking', required : get_option('tls'),
151 default_options: ['gnutls=auto', 'openssl=auto'])
154 plugins_doc_dep = custom_target('plugins-doc-cache',
155 command: [python3, '-c', 'print("Built all doc caches")'],
156 input: plugins_doc_caches,
157 output: 'plugins_doc_caches',
161 if meson.is_cross_build() or build_machine.system() == 'windows'
162 if get_option('doc').enabled()
163 error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
166 documented_projects = ''
167 message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
169 hotdoc_p = find_program('hotdoc', required : get_option('doc'))
170 if not hotdoc_p.found()
171 documented_projects = ''
172 message('Not building documentation as hotdoc was not found')
176 write_file_contents = '''
180 assert len(sys.argv) >= 3
182 contents = sys.argv[2]
184 with open(fname, 'w') as f:
189 output : 'GstDocumentedSubprojects',
191 '-c', write_file_contents,
196 if documented_projects != ''
197 subproject('gst-docs', required: get_option('doc').enabled())
198 message('Gst docs subprojects: ' + documented_projects)
201 all_plugins_paths = []
202 foreach plugin: all_plugins
203 all_plugins_paths += plugin.full_path()
205 # Work around meson bug: https://github.com/mesonbuild/meson/pull/6770
206 pathsep = host_machine.system() == 'windows' ? ';' : ':'
207 all_plugins_paths = pathsep.join(all_plugins_paths)
209 generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
211 output : 'GstPluginsPath.json',
212 command : [generate_plugins_paths,
217 # FIXME: Create a 'libraries' list in each subproject like we do for 'plugins'
219 # name: [subproject_name, variable_name]
220 'gstreamer': ['gstreamer', 'libgst'],
221 'base': ['gstreamer', 'gst_base'],
222 'check': ['gstreamer', 'gst_check'],
223 'controller': ['gstreamer', 'gst_controller'],
224 'net': ['gstreamer', 'gst_net'],
226 'allocators': ['gst-plugins-base', 'gstallocators'],
227 'app': ['gst-plugins-base', 'gstapp'],
228 'audio': ['gst-plugins-base', 'gstaudio'],
229 'fft': ['gst-plugins-base', 'gstfft'],
230 'pbutils': ['gst-plugins-base', 'pbutils'],
231 'riff': ['gst-plugins-base', 'gstriff'],
232 'rtp': ['gst-plugins-base', 'gst_rtp'],
233 'rtsp': ['gst-plugins-base', 'gst_rtsp'],
234 'sdp': ['gst-plugins-base', 'gstsdp'],
235 'tag': ['gst-plugins-base', 'gsttag'],
236 'video': ['gst-plugins-base', 'gstvideo'],
237 'gl': ['gst-plugins-base', 'gstgl'],
239 'bad-audio': ['gst-plugins-bad', 'gstbadaudio'],
240 'bad-transcoder': ['gst-plugins-bad', 'gst_transcoder'],
241 'codecparsers': ['gst-plugins-bad', 'gstcodecparsers'],
242 'insertbin': ['gst-plugins-bad', 'gstinsertbin'],
243 'mpegts': ['gst-plugins-bad', 'gstmpegts'],
244 'player': ['gst-plugins-bad', 'gstplayer'],
245 'sctp': ['gst-plugins-bad', 'libgstsctp'],
246 'webrtc': ['gst-plugins-bad', 'gstwebrtc'],
247 'vulkan': ['gst-plugins-bad', 'gstvulkan'],
249 'rtsp-server': ['gst-rtsp-server', 'gst_rtsp_server'],
252 if get_option('default_library') == 'static'
253 # Generate a .c file which declare and register all built plugins
254 generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
255 init_static_plugins_c = configure_file(
256 output: 'gstinitstaticplugins.c',
257 command : [generate_init_static_plugins,
262 # Avoid a x264 link issue described here: https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/108
263 # Similar issue has been found with VLC: https://mailman.videolan.org/pipermail/vlc-devel/2009-March/057640.html
264 gstfull_link_args = []
265 if cc.has_link_argument('-Wl,-Bsymbolic')
266 gstfull_link_args += ['-Wl,-Bsymbolic']
270 gst_dep = subproject('gstreamer').get_variable('gst_dep')
272 # Get a list of libraries that needs to be exposed in the ABI.
274 foreach name : get_option('gst-full-libraries') + ['gstreamer']
275 info = libraries_map[name]
276 exposed_libs += subproject(info[0]).get_variable(info[1])
279 # glib and gobject are part of our public API. If we are using glib from the
280 # system then our pkg-config file must require it. If we built it as
281 # subproject then we need to link_whole it.
283 gobject_dep = dependency('gobject-2.0', fallback: ['glib', 'libgobject_dep'])
284 if gobject_dep.type_name() == 'internal'
285 glib_subproject = subproject('glib')
286 exposed_libs += glib_subproject.get_variable('libglib')
287 exposed_libs += glib_subproject.get_variable('libgobject')
289 requires = ['glib-2.0', 'gobject-2.0']
293 if get_option('gst-full-version-script') != ''
294 symbol_map = meson.current_source_dir() / get_option('gst-full-version-script')
295 link_arg = '-Wl,--version-script=' + symbol_map
296 if cc.has_link_argument(link_arg)
297 gstfull_link_args += link_arg
299 error('Failed to link with version script (' + symbol_map + '), check logs for details')
301 link_deps += symbol_map
304 # Build both shared and static library
305 gstfull = both_libraries('gstreamer-full-1.0',
306 init_static_plugins_c,
307 link_with : all_plugins,
308 link_args: gstfull_link_args,
309 link_whole : exposed_libs,
310 dependencies : gst_dep,
311 link_depends : link_deps,
314 pkgconfig.generate(gstfull,
316 subdirs : 'gstreamer-1.0')
319 foreach custom_subproj: get_option('custom_subprojects').split(',')
320 if custom_subproj != ''
321 message ('Adding custom subproject ' + custom_subproj)
322 subproject(custom_subproj)
323 subprojects_names += [custom_subproj]
327 message('Building subprojects: ' + ', '.join(subprojects_names))
328 setenv = find_program('gst-env.py')
330 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.build_root()),
331 '--srcdir=@0@'.format(meson.source_root())]
333 if meson.has_exe_wrapper() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
334 # FIXME: Ideally we could get the wrapper directly from meson
335 devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
336 sysroot = meson.get_cross_property('sys_root')
339 devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
343 run_target('uninstalled', command : devenv_cmd)
344 run_target('devenv', command : devenv_cmd)
346 update = find_program('git-update')
347 run_target('git-update', command : [update])
348 run_target('update', command : [update,
349 '--builddir=@0@'.format(meson.current_build_dir())])
351 if orc_subproject.found() and orc_update_targets.length() > 0
352 alias_target('update-orc-dist', orc_update_targets)