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 documented_projects = ''
28 # Make it possible to use msys2 built zlib which fails
29 # when not using the mingw toolchain as it uses unistd.h
30 if not meson.is_subproject() and cc.get_id() == 'msvc'
31 uname = find_program('uname', required: false)
33 ret = run_command(uname, '-o')
34 if ret.returncode() == 0 and ret.stdout().to_lower() == 'msys'
35 ret = run_command(uname, '-r')
36 # The kernel version returned by uname is actually the msys version
37 if ret.returncode() == 0 and ret.stdout().startswith('2')
38 # If a system zlib is found, disable UNIX features in zlib.h and zconf.h
39 if cc.find_library('z').found()
40 add_global_arguments('-DZ_SOLO', language: 'c')
46 # Change some warning which belong to level 3 (production quality) or
47 # 4 (informational) to level 1 (severe)
48 add_global_arguments (
49 '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
50 '/w14101', # 'identifier' : unreferenced local variable
51 '/w14189', # 'identifier' : local variable is initialized but not referenced
52 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
53 language: ['c', 'cpp'])
56 # Ordered list of subprojects (dict has no ordering guarantees)
58 ['gstreamer', {'build-hotdoc': true}],
59 ['gst-plugins-base', {'build-hotdoc': true}],
60 ['gst-plugins-good', {'build-hotdoc': true}],
61 ['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
62 ['gst-plugins-bad', { 'option': get_option('bad'), 'build-hotdoc': true}],
63 ['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true}],
64 ['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true}],
65 ['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true}],
66 ['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true }],
67 ['gst-integration-testsuites', { 'option': get_option('devtools') }],
68 ['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true}],
69 ['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true}],
70 ['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true}],
71 ['gstreamer-sharp', { 'option': get_option('sharp') }],
72 ['pygobject', { 'option': get_option('python'), 'match_gst_version': false }],
73 ['gst-python', { 'option': get_option('python')}],
74 ['gst-examples', { 'option': get_option('gst-examples'), 'match_gst_versions': false}],
75 ['gst-plugins-rs', { 'option': get_option('rs'), 'match_gst_version': false}],
81 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
82 os.path.join('@1@', '@0@'))
85 if build_system == 'windows'
86 subproject('win-flex-bison-binaries')
87 subproject('win-nasm')
90 orc_subproject = subproject('orc', required: get_option('orc'))
92 subprojects_names = []
93 plugins_doc_caches = []
94 orc_update_targets = []
96 foreach sp : subprojects
99 is_required = build_infos.get('option', true)
100 match_gst_version = build_infos.get('match_gst_version', true)
103 subproj = subproject(project_name, version: gst_version, required: is_required)
105 subproj = subproject(project_name, required: is_required)
109 plugins = subproj.get_variable('plugins', [])
110 all_plugins += plugins
112 orc_update_targets += subproj.get_variable('orc_update_targets', [])
114 subprojects_names += [project_name]
115 cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
116 if cmdres.returncode() == 0
117 message('Created symlink to ' + project_name)
120 if not meson.is_cross_build() and build_infos.get('build-hotdoc', false)
121 if plugins.length() > 0
122 plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
124 if documented_projects != ''
125 documented_projects += ','
127 documented_projects += project_name
132 # Check if we need to also build glib-networking for TLS modules
133 glib_dep = dependency('glib-2.0')
134 if glib_dep.type_name() == 'internal'
135 subproject('glib-networking', required : get_option('tls'),
136 default_options: ['gnutls=auto', 'openssl=auto'])
139 plugins_doc_dep = custom_target('plugins-doc-cache',
140 command: [python3, '-c', 'print("Built all doc caches")'],
141 input: plugins_doc_caches,
142 output: 'plugins_doc_caches',
146 foreach custom_subproj: get_option('custom_subprojects').split(',')
147 if custom_subproj != ''
148 message ('Adding custom subproject ' + custom_subproj)
149 subproject(custom_subproj)
150 subprojects_names += [custom_subproj]
154 if meson.is_cross_build() or build_machine.system() == 'windows'
155 if get_option('doc').enabled()
156 error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
159 documented_projects = ''
160 message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
162 hotdoc_p = find_program('hotdoc', required : get_option('doc'))
163 if not hotdoc_p.found()
164 documented_projects = ''
165 message('Not building documentation as hotdoc was not found')
169 write_file_contents = '''
173 assert len(sys.argv) >= 3
175 contents = sys.argv[2]
177 with open(fname, 'w') as f:
182 output : 'GstDocumentedSubprojects',
184 '-c', write_file_contents,
189 if documented_projects != ''
190 subproject('gst-docs', required: get_option('doc').enabled())
191 message('Gst docs subprojects: ' + documented_projects)
194 all_plugins_paths = []
195 foreach plugin: all_plugins
196 all_plugins_paths += plugin.full_path()
198 # Work around meson bug: https://github.com/mesonbuild/meson/pull/6770
199 pathsep = host_machine.system() == 'windows' ? ';' : ':'
200 all_plugins_paths = pathsep.join(all_plugins_paths)
202 generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
204 output : 'GstPluginsPath.json',
205 command : [generate_plugins_paths,
210 # FIXME: Create a 'libraries' list in each subproject like we do for 'plugins'
212 # name: [subproject_name, variable_name]
213 'gstreamer': ['gstreamer', 'libgst'],
214 'base': ['gstreamer', 'gst_base'],
215 'check': ['gstreamer', 'gst_check'],
216 'controller': ['gstreamer', 'gst_controller'],
217 'net': ['gstreamer', 'gst_net'],
219 'allocators': ['gst-plugins-base', 'gstallocators'],
220 'app': ['gst-plugins-base', 'gstapp'],
221 'audio': ['gst-plugins-base', 'gstaudio'],
222 'fft': ['gst-plugins-base', 'gstfft'],
223 'pbutils': ['gst-plugins-base', 'pbutils'],
224 'riff': ['gst-plugins-base', 'gstriff'],
225 'rtp': ['gst-plugins-base', 'gst_rtp'],
226 'rtsp': ['gst-plugins-base', 'gst_rtsp'],
227 'sdp': ['gst-plugins-base', 'gstsdp'],
228 'tag': ['gst-plugins-base', 'gsttag'],
229 'video': ['gst-plugins-base', 'gstvideo'],
230 'gl': ['gst-plugins-base', 'gstgl'],
232 'bad-audio': ['gst-plugins-bad', 'gstbadaudio'],
233 'bad-transcoder': ['gst-plugins-bad', 'gst_transcoder'],
234 'codecparsers': ['gst-plugins-bad', 'gstcodecparsers'],
235 'insertbin': ['gst-plugins-bad', 'gstinsertbin'],
236 'mpegts': ['gst-plugins-bad', 'gstmpegts'],
237 'player': ['gst-plugins-bad', 'gstplayer'],
238 'sctp': ['gst-plugins-bad', 'libgstsctp'],
239 'webrtc': ['gst-plugins-bad', 'gstwebrtc'],
240 'vulkan': ['gst-plugins-bad', 'gstvulkan'],
242 'rtsp-server': ['gst-rtsp-server', 'gst_rtsp_server'],
245 if get_option('default_library') == 'static'
246 # Generate a .c file which declare and register all built plugins
247 generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
248 init_static_plugins_c = configure_file(
249 output: 'gstinitstaticplugins.c',
250 command : [generate_init_static_plugins,
254 install_headers('gstinitstaticplugins.h', subdir : 'gstreamer-1.0/gst')
256 # Avoid a x264 link issue described here: https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/108
257 # Similar issue has been found with VLC: https://mailman.videolan.org/pipermail/vlc-devel/2009-March/057640.html
258 gstfull_link_args = []
259 if cc.has_link_argument('-Wl,-Bsymbolic')
260 gstfull_link_args += ['-Wl,-Bsymbolic']
264 gst_dep = subproject('gstreamer').get_variable('gst_dep')
266 # Get a list of libraries that needs to be exposed in the ABI.
268 foreach name : get_option('gst-full-libraries') + ['gstreamer']
269 info = libraries_map[name]
270 exposed_libs += subproject(info[0]).get_variable(info[1])
273 # glib and gobject are part of our public API. If we are using glib from the
274 # system then our pkg-config file must require it. If we built it as
275 # subproject then we need to link_whole it.
277 gobject_dep = dependency('gobject-2.0', fallback: ['glib', 'libgobject_dep'])
278 if gobject_dep.type_name() == 'internal'
279 glib_subproject = subproject('glib')
280 exposed_libs += glib_subproject.get_variable('libglib')
281 exposed_libs += glib_subproject.get_variable('libgobject')
283 requires = ['glib-2.0', 'gobject-2.0']
286 # Build both shared and static library
287 gstfull = both_libraries('gstreamer-full-1.0',
288 init_static_plugins_c,
289 link_with : all_plugins,
290 link_args: gstfull_link_args,
291 link_whole : exposed_libs,
292 dependencies : gst_dep,
295 pkgconfig.generate(gstfull,
297 subdirs : 'gstreamer-1.0')
300 message('Building subprojects: ' + ', '.join(subprojects_names))
301 setenv = find_program('gst-env.py')
303 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.build_root()),
304 '--srcdir=@0@'.format(meson.source_root())]
306 if meson.has_exe_wrapper() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
307 # FIXME: Ideally we could get the wrapper directly from meson
308 devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
309 sysroot = meson.get_cross_property('sys_root')
312 devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
316 run_target('uninstalled', command : devenv_cmd)
317 run_target('devenv', command : devenv_cmd)
319 update = find_program('git-update')
320 run_target('git-update', command : [update])
321 run_target('update', command : [update,
322 '--builddir=@0@'.format(meson.current_build_dir())])
324 if orc_subproject.found() and orc_update_targets.length() > 0
325 alias_target('update-orc-dist', orc_update_targets)