Back to development
[platform/upstream/gstreamer.git] / subprojects / gst-editing-services / meson.build
1 project('gst-editing-services', 'c',
2   version : '1.19.3.1',
3   meson_version : '>= 0.59',
4   default_options : [ 'warning_level=1',
5                       'buildtype=debugoptimized' ])
6
7 gst_version = meson.project_version()
8 version_arr = gst_version.split('.')
9 gst_version = meson.project_version()
10 version_arr = gst_version.split('.')
11 gst_version_major = version_arr[0].to_int()
12 gst_version_minor = version_arr[1].to_int()
13 gst_version_micro = version_arr[2].to_int()
14  if version_arr.length() == 4
15   gst_version_nano = version_arr[3].to_int()
16 else
17   gst_version_nano = 0
18 endif
19 gst_version_is_stable = gst_version_minor.is_even()
20 gst_version_is_dev = gst_version_minor.is_odd() and gst_version_micro < 90
21
22 apiversion = '1.0'
23 soversion = 0
24 # maintaining compatibility with the previous libtool versioning
25 # current = minor * 100 + micro
26 curversion = gst_version_minor * 100 + gst_version_micro
27 libversion = '@0@.@1@.0'.format(soversion, curversion)
28 osxversion = curversion + 1
29
30 glib_req = '>= 2.56.0'
31
32 if gst_version_is_stable
33   gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
34 else
35   gst_req = '>= ' + gst_version
36 endif
37
38 cc = meson.get_compiler('c')
39 mathlib = cc.find_library('m', required : false)
40
41 cdata = configuration_data()
42
43 prefix = get_option('prefix')
44 datadir = prefix / get_option('datadir')
45
46 if cc.get_id() == 'msvc'
47   msvc_args = [
48       # Ignore several spurious warnings for things gstreamer does very commonly
49       # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
50       # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
51       # NOTE: Only add warnings here if you are sure they're spurious
52       '/wd4018', # implicit signed/unsigned conversion
53       '/wd4146', # unary minus on unsigned (beware INT_MIN)
54       '/wd4244', # lossy type conversion (e.g. double -> int)
55       '/wd4305', # truncating type conversion (e.g. double -> float)
56       cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
57
58       # Enable some warnings on MSVC to match GCC/Clang behaviour
59       '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
60       '/w14101', # 'identifier' : unreferenced local variable
61       '/w14189', # 'identifier' : local variable is initialized but not referenced
62   ]
63   add_project_arguments(msvc_args, language: 'c')
64 endif
65
66 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
67   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
68 endif
69
70 # Symbol visibility
71 if cc.get_id() == 'msvc'
72   export_define = '__declspec(dllexport) extern'
73 elif cc.has_argument('-fvisibility=hidden')
74   add_project_arguments('-fvisibility=hidden', language: 'c')
75   export_define = 'extern __attribute__ ((visibility ("default")))'
76 else
77   export_define = 'extern'
78 endif
79
80 # Passing this through the command line would be too messy
81 cdata.set('GST_API_EXPORT', export_define)
82
83 # Disable strict aliasing
84 if cc.has_argument('-fno-strict-aliasing')
85   add_project_arguments('-fno-strict-aliasing', language: 'c')
86 endif
87
88 cdata.set('VERSION', '"@0@"'.format(gst_version))
89 cdata.set('PACKAGE', '"gst-editing-services"')
90 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
91 cdata.set('PACKAGE_BUGREPORT', '"https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/new"')
92 cdata.set('PACKAGE_NAME', '"GStreamer Editing Services"')
93 cdata.set('GST_PACKAGE_NAME', '"GStreamer Editing Services"')
94 cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"')
95 cdata.set('GST_LICENSE', '"LGPL"')
96
97 # Mandatory GST deps
98 gst_dep = dependency('gstreamer-' + apiversion, version : gst_req,
99     fallback : ['gstreamer', 'gst_dep'])
100 gstpbutils_dep = dependency('gstreamer-pbutils-' + apiversion, version : gst_req,
101     fallback : ['gst-plugins-base', 'pbutils_dep'])
102 gstvideo_dep = dependency('gstreamer-video-' + apiversion, version : gst_req,
103     fallback : ['gst-plugins-base', 'video_dep'])
104 gstaudio_dep = dependency('gstreamer-audio-' + apiversion, version : gst_req,
105     fallback : ['gst-plugins-base', 'audio_dep'])
106 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
107     fallback : ['gstreamer', 'gst_base_dep'])
108 if host_machine.system() != 'windows'
109   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
110     required : get_option('tests'),
111     fallback : ['gstreamer', 'gst_check_dep'])
112 endif
113 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
114   fallback : ['gstreamer', 'gst_controller_dep'])
115 gstvalidate_dep = dependency('gst-validate-1.0', version : gst_req, required : get_option('validate'),
116   fallback : ['gst-devtools', 'validate_dep'])
117
118 gio_dep = dependency('gio-2.0', version: glib_req, fallback: ['glib', 'libgio_dep'])
119 libxml_dep = dependency('libxml-2.0', required: get_option('xptv'))
120 cdata.set('DISABLE_XPTV', not libxml_dep.found())
121
122 # TODO Properly port to Gtk 3
123 # gtk_dep = dependency('gtk+-3.0', required : false)
124
125 libges_deps = [gst_dep, gstbase_dep, gstvideo_dep, gstpbutils_dep,
126                gstcontroller_dep, gio_dep, libxml_dep, mathlib]
127
128 if gstvalidate_dep.found()
129     libges_deps = libges_deps + [gstvalidate_dep]
130     cdata.set('HAVE_GST_VALIDATE', 1)
131 endif
132
133 gir = find_program('g-ir-scanner', required : get_option('introspection'))
134 gnome = import('gnome')
135
136 # Fixme, not very elegant.
137 build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
138 gir_init_section = [ '--add-init-section=' + \
139     'extern void gst_init(gint*,gchar**);' + \
140     'extern void ges_init(void);' + \
141     'g_setenv("GST_REGISTRY_1.0", "/no/way/this/exists.reg", TRUE);' + \
142     'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \
143     'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
144     'g_setenv("GST_DEBUG", "0", TRUE);' + \
145     'gst_init(NULL,NULL);' + \
146     'ges_init();', '--quiet']
147
148 has_python = false
149 static_build = get_option('default_library') == 'static'
150 if static_build
151   if get_option('python').enabled()
152     error('Want to build python based modules but it is not supported while static building')
153   else
154     message('Disabling python support as it is not supported on static builds')
155   endif
156 elif build_gir
157   pymod = import('python')
158   python = pymod.find_installation(required: get_option('python'))
159   if python.found()
160     # Workaround for https://github.com/mesonbuild/meson/issues/5629
161     pythonver = python.language_version()
162     python_dep = dependency('python-@0@-embed'.format(pythonver), version: '>=3', required: false)
163     if not python_dep.found()
164       python_dep = python.dependency(required : get_option('python'))
165     endif
166   else
167     python_dep = dependency('', required: false)
168   endif
169   if python_dep.found()
170     python_abi_flags = python.get_variable('ABIFLAGS', '')
171     pylib_loc = get_option('libpython-dir')
172
173     error_msg = ''
174     if not cc.compiles('#include <Python.h>', dependencies: [python_dep])
175       error_msg = 'Could not compile a simple program against python'
176     elif pylib_loc == ''
177       check_path_exists = 'import os, sys; assert(os.path.exists(sys.argv[1]))'
178       pylib_loc = python.get_variable('LIBPL', '')
179       if host_machine.system() != 'windows' and host_machine.system() != 'darwin'
180         pylib_ldlibrary = python.get_variable('LDLIBRARY', '')
181         if run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() != 0
182           # Workaround for Fedora
183           pylib_loc = python.get_variable('LIBDIR', '')
184           message('pylib_loc = @0@'.format(pylib_loc))
185         endif
186
187         res = run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary))
188         if res.returncode() != 0
189           error_msg = '@0@ doesn\' exist, can\'t use python'.format(join_paths(pylib_loc, pylib_ldlibrary))
190         endif
191       endif
192       if error_msg == ''
193         pylib_suffix = 'so'
194         if host_machine.system() == 'windows'
195           pylib_suffix = 'dll'
196         elif host_machine.system() == 'darwin'
197           pylib_suffix = 'dylib'
198         endif
199
200         gmodule_dep = dependency('gmodule-2.0')
201         libges_deps = libges_deps + [python_dep, gmodule_dep]
202         has_python = true
203         message('python_abi_flags = @0@'.format(python_abi_flags))
204         message('pylib_loc = @0@'.format(pylib_loc))
205         cdata.set('HAS_PYTHON', true)
206         cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
207         cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
208         cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
209         cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
210       else
211           if get_option('python').enabled()
212             error(error_msg)
213           else
214             message(error_msg)
215           endif
216       endif
217     endif
218   endif
219 endif
220
221 ges_c_args = ['-DHAVE_CONFIG_H', '-DG_LOG_DOMAIN="GES"']
222 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
223
224 pkgconfig = import('pkgconfig')
225 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
226 if get_option('default_library') == 'shared'
227   # If we don't build static plugins there is no need to generate pc files
228   plugins_pkgconfig_install_dir = disabler()
229 endif
230
231 if gst_dep.type_name() == 'internal'
232   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
233 else
234   # We can't check that in the case of subprojects as we won't
235   # be able to build against an internal dependency (which is not built yet)
236   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
237 endif
238
239 if gst_debug_disabled and cc.has_argument('-Wno-unused')
240   add_project_arguments('-Wno-unused', language: 'c')
241 endif
242
243 warning_flags = [
244   '-Wmissing-declarations',
245   '-Wmissing-prototypes',
246   '-Wredundant-decls',
247   '-Wundef',
248   '-Wwrite-strings',
249   '-Wformat',
250   '-Wformat-security',
251   '-Winit-self',
252   '-Wmissing-include-dirs',
253   '-Waddress',
254   '-Wno-multichar',
255   '-Wdeclaration-after-statement',
256   '-Wvla',
257   '-Wpointer-arith',
258 ]
259
260 foreach extra_arg : warning_flags
261   if cc.has_argument (extra_arg)
262     add_project_arguments([extra_arg], language: 'c')
263   endif
264 endforeach
265
266 python3 = import('python').find_installation()
267 pkgconfig = import('pkgconfig')
268 pkgconfig_subdirs = ['gstreamer-1.0']
269
270 configinc = include_directories('.')
271 libraries = []
272
273 subdir('ges')
274 subdir('plugins')
275 if not get_option('tools').disabled()
276   subdir('tools')
277 endif
278 subdir('tests')
279 if not get_option('examples').disabled()
280   subdir('examples')
281 endif
282 subdir('docs')
283
284 override_detector = '''
285 import sys
286 import os
287
288 prefix = sys.argv[1]
289 version = sys.version_info
290
291 # If we are installing in the same prefix as PyGobject
292 # make sure to install in the right place.
293 import gi.overrides
294
295 overrides_path = os.path.dirname(gi.overrides.__file__)
296 if os.path.commonprefix([overrides_path, prefix]) == prefix:
297     print(overrides_path)
298     exit(0)
299
300 # Otherwise follow python's way of install site packages inside
301 # the provided prefix
302 if os.name == 'posix':
303     print(os.path.join(
304         prefix, 'lib', 'python%d.%d' % (version.major, version.minor),
305         'site-packages', 'gi', 'overrides'))
306 else:
307     print(os.path.join(
308         prefix, 'Lib', 'Python%d%d' % (version.major, version.minor),
309         'site-packages', 'gi', 'overrides'))
310 '''
311 pygi_override_dir = get_option('pygi-overrides-dir')
312 if pygi_override_dir == ''
313     cres = run_command(python3, '-c', override_detector, get_option('prefix'))
314     if cres.returncode() == 0
315       pygi_override_dir = cres.stdout().strip()
316     endif
317     if cres.stderr() != ''
318         message(cres.stderr())
319     endif
320 endif
321
322 if pygi_override_dir != ''
323   message('pygobject overrides directory ' + pygi_override_dir)
324   subdir('bindings/python')
325 endif
326
327 # Set release date
328 if gst_version_nano == 0
329   extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
330   run_result = run_command(extract_release_date, gst_version, files('gst-editing-services.doap'))
331   if run_result.returncode() == 0
332     release_date = run_result.stdout().strip()
333     cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
334     message('Package release date: ' + release_date)
335   else
336     # Error out if our release can't be found in the .doap file
337     error(run_result.stderr())
338   endif
339 endif
340
341 if gio_dep.version().version_compare('< 2.67.4')
342   cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
343 endif
344
345 configure_file(output: 'config.h', configuration: cdata)