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