framepositioner: Fix some source repositionning rounding issues
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-editing-services', 'c',
2   version : '1.17.0.1',
3   meson_version : '>= 0.48',
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.44.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 # Ignore several spurious warnings for things gstreamer does very commonly
37 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
38 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
39 # NOTE: Only add warnings here if you are sure they're spurious
40 if cc.get_id() == 'msvc'
41   add_project_arguments(
42       '/wd4018', # implicit signed/unsigned conversion
43       '/wd4146', # unary minus on unsigned (beware INT_MIN)
44       '/wd4244', # lossy type conversion (e.g. double -> int)
45       '/wd4305', # truncating type conversion (e.g. double -> float)
46       language : 'c')
47 endif
48
49 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
50   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
51 endif
52
53 # Symbol visibility
54 if cc.get_id() == 'msvc'
55   export_define = '__declspec(dllexport) extern'
56 elif cc.has_argument('-fvisibility=hidden')
57   add_project_arguments('-fvisibility=hidden', language: 'c')
58   export_define = 'extern __attribute__ ((visibility ("default")))'
59 else
60   export_define = 'extern'
61 endif
62
63 # Passing this through the command line would be too messy
64 cdata.set('GST_API_EXPORT', export_define)
65
66 # Disable strict aliasing
67 if cc.has_argument('-fno-strict-aliasing')
68   add_project_arguments('-fno-strict-aliasing', language: 'c')
69 endif
70
71 cdata.set('VERSION', '"@0@"'.format(gst_version))
72 cdata.set('PACKAGE', '"gst-editing-services"')
73 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
74 cdata.set('PACKAGE_BUGREPORT', '"http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer"')
75 cdata.set('PACKAGE_NAME', '"GStreamer Editing Services"')
76 cdata.set('GST_PACKAGE_NAME', '"GStreamer Editing Services"')
77 cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"')
78 cdata.set('GST_LICENSE', '"LGPL"')
79
80 # Mandatory GST deps
81 gst_dep = dependency('gstreamer-' + apiversion, version : gst_req,
82     fallback : ['gstreamer', 'gst_dep'])
83 gstpbutils_dep = dependency('gstreamer-pbutils-' + apiversion, version : gst_req,
84     fallback : ['gst-plugins-base', 'pbutils_dep'])
85 gstvideo_dep = dependency('gstreamer-video-' + apiversion, version : gst_req,
86     fallback : ['gst-plugins-base', 'video_dep'])
87 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
88     fallback : ['gstreamer', 'gst_base_dep'])
89 if host_machine.system() != 'windows'
90   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
91     required : get_option('tests'),
92     fallback : ['gstreamer', 'gst_check_dep'])
93 endif
94 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
95   fallback : ['gstreamer', 'gst_controller_dep'])
96 gstvalidate_dep = dependency('gst-validate-1.0', version : gst_req, required : get_option('validate'),
97   fallback : ['gst-devtools', 'validate_dep'])
98
99 gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
100 libxml_dep = dependency('libxml-2.0', required: get_option('xptv'))
101 cdata.set('DISABLE_XPTV', not libxml_dep.found())
102
103 # TODO Properly port to Gtk 3
104 # gtk_dep = dependency('gtk+-3.0', required : false)
105
106 libges_deps = [gst_dep, gstbase_dep, gstvideo_dep, gstpbutils_dep,
107                gstcontroller_dep, gio_dep, libxml_dep, mathlib]
108
109 if gstvalidate_dep.found()
110     libges_deps = libges_deps + [gstvalidate_dep]
111     cdata.set('HAVE_GST_VALIDATE', 1)
112 endif
113
114 gir = find_program('g-ir-scanner', required : get_option('introspection'))
115 gnome = import('gnome')
116
117 # Fixme, not very elegant.
118 build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
119 gir_init_section = [ '--add-init-section=' + \
120     'extern void gst_init(gint*,gchar**);' + \
121     'extern void ges_init(void);' + \
122     'g_setenv("GST_REGISTRY_1.0", "/no/way/this/exists.reg", TRUE);' + \
123     'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \
124     'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
125     'g_setenv("GST_DEBUG", "0", TRUE);' + \
126     'gst_init(NULL,NULL);' + \
127     'ges_init();', '--quiet']
128
129 has_python = false
130 if build_gir
131   pymod = import('python')
132   python = pymod.find_installation(required: get_option('python'))
133   if python.found()
134     # Workaround for https://github.com/mesonbuild/meson/issues/5629
135     pythonver = python.language_version()
136     python_dep = dependency('python-@0@-embed'.format(pythonver), version: '>=3', required: false)
137     if not python_dep.found()
138       python_dep = python.dependency(required : get_option('python'))
139     endif
140   else
141     python_dep = dependency('', required: false)
142   endif
143   if python_dep.found()
144     python_abi_flags = python.get_variable('ABIFLAGS', '')
145     pylib_loc = get_option('libpython-dir')
146
147     error_msg = ''
148     if not cc.compiles('#include <Python.h>', dependencies: [python_dep])
149       error_msg = 'Could not compile a simple program against python'
150     elif pylib_loc == ''
151       check_path_exists = 'import os, sys; assert(os.path.exists(sys.argv[1]))'
152       pylib_loc = python.get_variable('LIBPL', '')
153       if host_machine.system() != 'windows'
154         pylib_ldlibrary = python.get_variable('LDLIBRARY', '')
155         if host_machine.system() == 'darwin'
156           # OSX is a pain. Python as shipped by apple installs libpython in /usr/lib
157           # so we hardcode that. Other systems can use -Dlibpythondir to
158           # override this.
159           pylib_loc = '/usr/lib'
160         else
161           if run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() != 0
162             # Workaround for Fedora
163             pylib_loc = python.get_variable('LIBDIR', '')
164             message('pylib_loc = @0@'.format(pylib_loc))
165           endif
166         endif
167
168         res = run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary))
169         if res.returncode() != 0
170           error_msg = '@0@ doesn\' exist, can\'t use python'.format(join_paths(pylib_loc, pylib_ldlibrary))
171         endif
172       endif
173       if error_msg == ''
174         pylib_suffix = 'so'
175         if host_machine.system() == 'windows'
176           pylib_suffix = 'dll'
177         elif host_machine.system() == 'darwin'
178           pylib_suffix = 'dylib'
179         endif
180
181         gmodule_dep = dependency('gmodule-2.0')
182         libges_deps = libges_deps + [python_dep, gmodule_dep]
183         has_python = true
184         message('python_abi_flags = @0@'.format(python_abi_flags))
185         message('pylib_loc = @0@'.format(pylib_loc))
186         cdata.set('HAS_PYTHON', true)
187         cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
188         cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
189         cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
190         cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
191       else
192           if get_option('python').enabled()
193             error(error_msg)
194           else
195             message(error_msg)
196           endif
197       endif
198     endif
199   endif
200 endif
201
202 configure_file(output : 'config.h', configuration : cdata)
203
204 ges_c_args = ['-DHAVE_CONFIG_H', '-DG_LOG_DOMAIN="GES"']
205 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
206
207 pkgconfig = import('pkgconfig')
208 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
209 if get_option('default_library') == 'shared'
210   # If we don't build static plugins there is no need to generate pc files
211   plugins_pkgconfig_install_dir = disabler()
212 endif
213
214 if gst_dep.type_name() == 'internal'
215   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
216 else
217   # We can't check that in the case of subprojects as we won't
218   # be able to build against an internal dependency (which is not built yet)
219   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
220 endif
221
222 if gst_debug_disabled and cc.has_argument('-Wno-unused')
223   add_project_arguments('-Wno-unused', language: 'c')
224 endif
225
226 warning_flags = [
227   '-Wmissing-declarations',
228   '-Wmissing-prototypes',
229   '-Wredundant-decls',
230   '-Wundef',
231   '-Wwrite-strings',
232   '-Wformat',
233   '-Wformat-security',
234   '-Winit-self',
235   '-Wmissing-include-dirs',
236   '-Waddress',
237   '-Wno-multichar',
238   '-Wdeclaration-after-statement',
239   '-Wvla',
240   '-Wpointer-arith',
241 ]
242
243 foreach extra_arg : warning_flags
244   if cc.has_argument (extra_arg)
245     add_project_arguments([extra_arg], language: 'c')
246   endif
247 endforeach
248
249 python3 = import('python').find_installation()
250 configinc = include_directories('.')
251 subdir('ges')
252 subdir('plugins')
253 subdir('tools')
254 subdir('pkgconfig')
255 subdir('tests')
256 subdir('examples')
257 subdir('docs')
258
259 override_detector = '''
260 import sys
261 import os
262
263 prefix = sys.argv[1]
264 version = sys.version_info
265
266 # If we are installing in the same prefix as PyGobject
267 # make sure to install in the right place.
268 import gi.overrides
269
270 overrides_path = os.path.dirname(gi.overrides.__file__)
271 if os.path.commonprefix([overrides_path, prefix]) == prefix:
272     print(overrides_path)
273     exit(0)
274
275 # Otherwise follow python's way of install site packages inside
276 # the provided prefix
277 if os.name == 'posix':
278     print(os.path.join(
279         prefix, 'lib', 'python%d.%d' % (version.major, version.minor),
280         'site-packages', 'gi', 'overrides'))
281 else:
282     print(os.path.join(
283         prefix, 'Lib', 'Python%d%d' % (version.major, version.minor),
284         'site-packages', 'gi', 'overrides'))
285 '''
286 pygi_override_dir = get_option('pygi-overrides-dir')
287 if pygi_override_dir == ''
288     cres = run_command(python3, '-c', override_detector, get_option('prefix'))
289     if cres.returncode() == 0
290       pygi_override_dir = cres.stdout().strip()
291     endif
292     if cres.stderr() != ''
293         message(cres.stderr())
294     endif
295 endif
296
297 if pygi_override_dir != ''
298   message('pygobject overrides directory ' + pygi_override_dir)
299   subdir('bindings/python')
300 endif
301
302 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')