Back to development
[platform/upstream/gstreamer.git] / subprojects / gst-editing-services / meson.build
1 project('gst-editing-services', 'c',
2   version : '1.21.1.1',
3   meson_version : '>= 0.62',
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.62.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 # glib doesn't support unloading, which means that unloading and reloading
71 # any library that registers static types will fail
72 if cc.has_link_argument('-Wl,-z,nodelete')
73   add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
74 endif
75
76 # Symbol visibility
77 if cc.get_id() == 'msvc'
78   export_define = '__declspec(dllexport) extern'
79 elif cc.has_argument('-fvisibility=hidden')
80   add_project_arguments('-fvisibility=hidden', language: 'c')
81   export_define = 'extern __attribute__ ((visibility ("default")))'
82 else
83   export_define = 'extern'
84 endif
85
86 # Passing this through the command line would be too messy
87 cdata.set('GST_API_EXPORT', export_define)
88
89 # Disable strict aliasing
90 if cc.has_argument('-fno-strict-aliasing')
91   add_project_arguments('-fno-strict-aliasing', language: 'c')
92 endif
93
94 cdata.set('VERSION', '"@0@"'.format(gst_version))
95 cdata.set('PACKAGE', '"gst-editing-services"')
96 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
97 cdata.set('PACKAGE_BUGREPORT', '"https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/new"')
98 cdata.set('PACKAGE_NAME', '"GStreamer Editing Services"')
99 cdata.set('GST_PACKAGE_NAME', '"GStreamer Editing Services"')
100 cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"')
101 cdata.set('GST_LICENSE', '"LGPL"')
102
103 # Mandatory GST deps
104 gst_dep = dependency('gstreamer-' + apiversion, version : gst_req,
105     fallback : ['gstreamer', 'gst_dep'])
106 gstpbutils_dep = dependency('gstreamer-pbutils-' + apiversion, version : gst_req,
107     fallback : ['gst-plugins-base', 'pbutils_dep'])
108 gstvideo_dep = dependency('gstreamer-video-' + apiversion, version : gst_req,
109     fallback : ['gst-plugins-base', 'video_dep'])
110 gstaudio_dep = dependency('gstreamer-audio-' + apiversion, version : gst_req,
111     fallback : ['gst-plugins-base', 'audio_dep'])
112 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
113     fallback : ['gstreamer', 'gst_base_dep'])
114 if host_machine.system() != 'windows'
115   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
116     required : get_option('tests'),
117     fallback : ['gstreamer', 'gst_check_dep'])
118 endif
119 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
120   fallback : ['gstreamer', 'gst_controller_dep'])
121 gstvalidate_dep = dependency('gst-validate-1.0', version : gst_req, required : get_option('validate'),
122   fallback : ['gst-devtools', 'validate_dep'])
123
124 gio_dep = dependency('gio-2.0', version: glib_req)
125 gmodule_dep = dependency('gmodule-no-export-2.0')
126 libxml_dep = dependency('libxml-2.0', required: get_option('xptv'))
127 cdata.set('DISABLE_XPTV', not libxml_dep.found())
128
129 # TODO Properly port to Gtk 3
130 # gtk_dep = dependency('gtk+-3.0', required : false)
131
132 libges_deps = [gst_dep, gstbase_dep, gstvideo_dep, gstpbutils_dep,
133                gstcontroller_dep, gio_dep, libxml_dep, mathlib]
134
135 if gstvalidate_dep.found()
136     libges_deps = libges_deps + [gstvalidate_dep]
137     cdata.set('HAVE_GST_VALIDATE', 1)
138 endif
139
140 gir = find_program('g-ir-scanner', required : get_option('introspection'))
141 gnome = import('gnome')
142
143 # Fixme, not very elegant.
144 build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
145 gir_init_section = [ '--add-init-section=' + \
146     'extern void gst_init(gint*,gchar**);' + \
147     'extern void ges_init(void);' + \
148     'g_setenv("GST_REGISTRY_1.0", "/no/way/this/exists.reg", TRUE);' + \
149     'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \
150     'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
151     'g_setenv("GST_DEBUG", "0", TRUE);' + \
152     'gst_init(NULL,NULL);' + \
153     'ges_init();', '--quiet']
154
155 has_python = false
156 static_build = get_option('default_library') == 'static'
157 if static_build
158   if get_option('python').enabled()
159     error('Want to build python based modules but it is not supported while static building')
160   else
161     message('Disabling python support as it is not supported on static builds')
162   endif
163 elif build_gir
164   pymod = import('python')
165   python = pymod.find_installation(required: get_option('python'))
166   if python.found()
167     # Workaround for https://github.com/mesonbuild/meson/issues/5629
168     pythonver = python.language_version()
169     python_dep = dependency('python-@0@-embed'.format(pythonver), version: '>=3', required: false)
170     if not python_dep.found()
171       python_dep = python.dependency(required : get_option('python'))
172     endif
173   else
174     python_dep = dependency('', required: false)
175   endif
176   if python_dep.found()
177     python_abi_flags = python.get_variable('ABIFLAGS', '')
178     pylib_loc = get_option('libpython-dir')
179
180     error_msg = ''
181     if not cc.compiles('#include <Python.h>', dependencies: [python_dep])
182       error_msg = 'Could not compile a simple program against python'
183     elif pylib_loc == ''
184       fsmod = import('fs')
185       pylib_loc = python.get_variable('LIBPL', '')
186       if host_machine.system() != 'windows' and host_machine.system() != 'darwin'
187         pylib_ldlibrary = python.get_variable('LDLIBRARY', '')
188         if not fsmod.exists(pylib_loc / pylib_ldlibrary)
189           # Workaround for Fedora
190           pylib_loc = python.get_variable('LIBDIR', '')
191           message('pylib_loc = @0@'.format(pylib_loc))
192         endif
193
194         if not fsmod.exists(pylib_loc / pylib_ldlibrary)
195           error_msg = '@0@ doesn\' exist, can\'t use python'.format(join_paths(pylib_loc, pylib_ldlibrary))
196         endif
197       endif
198       if error_msg == ''
199         pylib_suffix = 'so'
200         if host_machine.system() == 'windows'
201           pylib_suffix = 'dll'
202         elif host_machine.system() == 'darwin'
203           pylib_suffix = 'dylib'
204         endif
205
206         libges_deps = libges_deps + [python_dep, gmodule_dep]
207         has_python = true
208         message('python_abi_flags = @0@'.format(python_abi_flags))
209         message('pylib_loc = @0@'.format(pylib_loc))
210         cdata.set('HAS_PYTHON', true)
211         cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
212         cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
213         cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
214         cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
215       else
216           if get_option('python').enabled()
217             error(error_msg)
218           else
219             message(error_msg)
220           endif
221       endif
222     endif
223   endif
224 endif
225
226 ges_c_args = ['-DHAVE_CONFIG_H', '-DG_LOG_DOMAIN="GES"']
227 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
228
229 pkgconfig = import('pkgconfig')
230 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
231 if get_option('default_library') == 'shared'
232   # If we don't build static plugins there is no need to generate pc files
233   plugins_pkgconfig_install_dir = disabler()
234 endif
235
236 if gst_dep.type_name() == 'internal'
237   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
238 else
239   # We can't check that in the case of subprojects as we won't
240   # be able to build against an internal dependency (which is not built yet)
241   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
242 endif
243
244 if gst_debug_disabled and cc.has_argument('-Wno-unused')
245   add_project_arguments('-Wno-unused', language: 'c')
246 endif
247
248 warning_flags = [
249   '-Wmissing-declarations',
250   '-Wmissing-prototypes',
251   '-Wredundant-decls',
252   '-Wundef',
253   '-Wwrite-strings',
254   '-Wformat',
255   '-Wformat-security',
256   '-Winit-self',
257   '-Wmissing-include-dirs',
258   '-Waddress',
259   '-Wno-multichar',
260   '-Wvla',
261   '-Wpointer-arith',
262 ]
263
264 foreach extra_arg : warning_flags
265   if cc.has_argument (extra_arg)
266     add_project_arguments([extra_arg], language: 'c')
267   endif
268 endforeach
269
270 python3 = import('python').find_installation()
271 pkgconfig = import('pkgconfig')
272 pkgconfig_subdirs = ['gstreamer-1.0']
273
274 configinc = include_directories('.')
275 gst_libraries = []
276
277 subdir('ges')
278 subdir('plugins')
279 subdir('tools')
280
281 subdir('tests')
282 if not get_option('examples').disabled()
283   subdir('examples')
284 endif
285 subdir('docs')
286
287 pygi_override_dir = get_option('pygi-overrides-dir')
288 if pygi_override_dir == ''
289   pygi_override_dir = python3.get_install_dir(
290     subdir : join_paths('gi', 'overrides')
291   )
292 endif
293
294 message('pygobject overrides directory = @0@'.format(pygi_override_dir))
295 subdir('bindings/python')
296
297 # Set release date
298 if gst_version_nano == 0
299   extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
300   run_result = run_command(extract_release_date, gst_version, files('gst-editing-services.doap'), check: true)
301   release_date = run_result.stdout().strip()
302   cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
303   message('Package release date: ' + release_date)
304 endif
305
306 if gio_dep.version().version_compare('< 2.67.4')
307   cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
308 endif
309
310 configure_file(output: 'config.h', configuration: cdata)
311
312 plugin_names = []
313 gst_plugins = []
314 foreach plugin: plugins
315   pkgconfig.generate(plugin, install_dir: plugins_pkgconfig_install_dir)
316   dep = declare_dependency(link_with: plugin, variables: {'full_path': plugin.full_path()})
317   meson.override_dependency(plugin.name(), dep)
318   gst_plugins += [dep]
319   if plugin.name().startswith('gst')
320     plugin_names += [plugin.name().substring(3)]
321   else
322     plugin_names += [plugin.name()]
323   endif
324 endforeach
325
326 summary({
327     'Plugins': plugin_names,
328 }, list_sep: ', ')