structured: Enhance error message when no clip duration set
[platform/upstream/gst-editing-services.git] / meson.build
index 92f301e..7b673ef 100644 (file)
@@ -1,16 +1,18 @@
 project('gst-editing-services', 'c',
-  version : '1.11.91',
-  meson_version : '>= 0.36.0',
+  version : '1.16.2',
+  meson_version : '>= 0.47',
   default_options : [ 'warning_level=1',
                       'buildtype=debugoptimized' ])
 
 gst_version = meson.project_version()
 version_arr = gst_version.split('.')
-gst_version_major = version_arr[0]
-gst_version_minor = version_arr[1]
-gst_version_micro = version_arr[2]
-if version_arr.length() == 4
-  gst_version_nano = version_arr[3]
+gst_version = meson.project_version()
+version_arr = gst_version.split('.')
+gst_version_major = version_arr[0].to_int()
+gst_version_minor = version_arr[1].to_int()
+gst_version_micro = version_arr[2].to_int()
+ if version_arr.length() == 4
+  gst_version_nano = version_arr[3].to_int()
 else
   gst_version_nano = 0
 endif
@@ -19,12 +21,17 @@ apiversion = '1.0'
 soversion = 0
 # maintaining compatibility with the previous libtool versioning
 # current = minor * 100 + micro
-libversion = '@0@.@1@.0'.format(soversion, gst_version_minor.to_int() * 100 + gst_version_micro.to_int())
+curversion = gst_version_minor * 100 + gst_version_micro
+libversion = '@0@.@1@.0'.format(soversion, curversion)
+osxversion = curversion + 1
 
 glib_req = '>= 2.40.0'
 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
 
 cc = meson.get_compiler('c')
+
+cdata = configuration_data()
+
 # Ignore several spurious warnings for things gstreamer does very commonly
 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
@@ -38,7 +45,28 @@ if cc.get_id() == 'msvc'
       language : 'c')
 endif
 
-cdata = configuration_data()
+if cc.has_link_argument('-Wl,-Bsymbolic-functions')
+  add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
+endif
+
+# Symbol visibility
+if cc.get_id() == 'msvc'
+  export_define = '__declspec(dllexport) extern'
+elif cc.has_argument('-fvisibility=hidden')
+  add_project_arguments('-fvisibility=hidden', language: 'c')
+  export_define = 'extern __attribute__ ((visibility ("default")))'
+else
+  export_define = 'extern'
+endif
+
+# Passing this through the command line would be too messy
+cdata.set('GST_API_EXPORT', export_define)
+
+# Disable strict aliasing
+if cc.has_argument('-fno-strict-aliasing')
+  add_project_arguments('-fno-strict-aliasing', language: 'c')
+endif
+
 cdata.set('VERSION', '"@0@"'.format(gst_version))
 cdata.set('PACKAGE', '"gst-editing-services"')
 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
@@ -47,7 +75,6 @@ cdata.set('PACKAGE_NAME', '"GStreamer Editing Services"')
 cdata.set('GST_PACKAGE_NAME', '"GStreamer Editing Services"')
 cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"')
 cdata.set('GST_LICENSE', '"LGPL"')
-cdata.set('LIBDIR', '"@0@"'.format(get_option('libdir')))
 
 # Mandatory GST deps
 gst_dep = dependency('gstreamer-' + apiversion, version : gst_req,
@@ -60,15 +87,17 @@ gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
     fallback : ['gstreamer', 'gst_base_dep'])
 if host_machine.system() != 'windows'
   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
-    fallback : ['gstreamer', 'gst_check_dep'], required: false)
+    required : get_option('tests'),
+    fallback : ['gstreamer', 'gst_check_dep'])
 endif
 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
   fallback : ['gstreamer', 'gst_controller_dep'])
 gstvalidate_dep = dependency('gst-validate-1.0', version : gst_req, required : false,
   fallback : ['gst-devtools', 'validate_dep'])
 
-gio_dep = dependency('gio-2.0', version : glib_req)
-libxml_dep = dependency('libxml-2.0')
+gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
+libxml_dep = dependency('libxml-2.0', required: get_option('xptv'))
+cdata.set('DISABLE_XPTV', not libxml_dep.found())
 
 # TODO Properly port to Gtk 3
 # gtk_dep = dependency('gtk+-3.0', required : false)
@@ -81,16 +110,14 @@ if gstvalidate_dep.found()
     cdata.set('HAVE_GST_VALIDATE', 1)
 endif
 
-configure_file(input : 'config.h.meson',
-  output : 'config.h',
-  configuration : cdata)
+configure_file(output : 'config.h', configuration : cdata)
 
 
-gir = find_program('g-ir-scanner', required : false)
+gir = find_program('g-ir-scanner', required : get_option('introspection'))
 gnome = import('gnome')
 
 # Fixme, not very elegant.
-build_gir = gir.found() and not meson.is_cross_build() and not get_option('disable_introspection')
+build_gir = gir.found() and not meson.is_cross_build()
 gir_init_section = [ '--add-init-section=' + \
     'extern void gst_init(gint*,gchar**);' + \
     'extern void ges_init(void);' + \
@@ -99,37 +126,53 @@ gir_init_section = [ '--add-init-section=' + \
     'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
     'g_setenv("GST_DEBUG", "0", TRUE);' + \
     'gst_init(NULL,NULL);' + \
-    'ges_init();' ]
+    'ges_init();', '--quiet']
 
-ges_c_args = ['-DHAVE_CONFIG_H']
+ges_c_args = ['-DHAVE_CONFIG_H', '-DG_LOG_DOMAIN="GES"']
 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
 
-vs_module_defs_dir = meson.current_source_dir() + '/win32/common/'
+pkgconfig = import('pkgconfig')
+plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
+if get_option('default_library') == 'shared'
+  # If we don't build static plugins there is no need to generate pc files
+  plugins_pkgconfig_install_dir = disabler()
+endif
 
 if gst_dep.type_name() == 'internal'
-    gst_proj = subproject('gstreamer')
-
-    if gst_proj.get_variable('disable_gst_debug')
-        message('GStreamer debug system is disabled')
-        add_project_arguments('-Wno-unused', language: 'c')
-    else
-        message('GStreamer debug system is enabled')
-    endif
+  gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
 else
-    # We can't check that in the case of subprojects as we won't
-    # be able to build against an internal dependency (which is not built yet)
-    if not cc.compiles('''
-#include <gst/gstconfig.h>
-#ifdef GST_DISABLE_GST_DEBUG
-#error "debugging disabled, make compiler fail"
-#endif''' , dependencies: gst_dep)
-        message('GStreamer debug system is disabled')
-        add_global_arguments('-Wno-unused', language: 'c')
-    else
-        message('GStreamer debug system is enabled')
-    endif
+  # We can't check that in the case of subprojects as we won't
+  # be able to build against an internal dependency (which is not built yet)
+  gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
 endif
 
+if gst_debug_disabled and cc.has_argument('-Wno-unused')
+  add_project_arguments('-Wno-unused', language: 'c')
+endif
+
+warning_flags = [
+  '-Wmissing-declarations',
+  '-Wmissing-prototypes',
+  '-Wredundant-decls',
+  '-Wundef',
+  '-Wwrite-strings',
+  '-Wformat',
+  '-Wformat-security',
+  '-Winit-self',
+  '-Wmissing-include-dirs',
+  '-Waddress',
+  '-Wno-multichar',
+  '-Wdeclaration-after-statement',
+  '-Wvla',
+  '-Wpointer-arith',
+]
+
+foreach extra_arg : warning_flags
+  if cc.has_argument (extra_arg)
+    add_project_arguments([extra_arg], language: 'c')
+  endif
+endforeach
+
 configinc = include_directories('.')
 subdir('ges')
 subdir('plugins')
@@ -138,17 +181,58 @@ subdir('pkgconfig')
 subdir('tests')
 subdir('examples')
 
+override_detector = '''
+import sys
+import os
+
+prefix = sys.argv[1]
+version = sys.version_info
+
+# If we are installing in the same prefix as PyGobject
+# make sure to install in the right place.
+import gi.overrides
+
+overrides_path = os.path.dirname(gi.overrides.__file__)
+if os.path.commonprefix([overrides_path, prefix]) == prefix:
+    print(overrides_path)
+    exit(0)
+
+# Otherwise follow python's way of install site packages inside
+# the provided prefix
+if os.name == 'posix':
+    print(os.path.join(
+        prefix, 'lib', 'python%d.%d' % (version.major, version.minor),
+        'site-packages', 'gi', 'overrides'))
+else:
+    print(os.path.join(
+        prefix, 'Lib', 'Python%d%d' % (version.major, version.minor),
+        'site-packages', 'gi', 'overrides'))
+'''
+python3 = import('python').find_installation()
+pygi_override_dir = get_option('pygi-overrides-dir')
+if pygi_override_dir == ''
+    cres = run_command(python3, '-c', override_detector, get_option('prefix'))
+    if cres.returncode() == 0
+      pygi_override_dir = cres.stdout().strip()
+    endif
+    if cres.stderr() != ''
+        message(cres.stderr())
+    endif
+endif
+
+if pygi_override_dir != ''
+  message('pygobject overrides directory ' + pygi_override_dir)
+  subdir('bindings/python')
+endif
+
 if build_machine.system() == 'windows'
   message('Disabling gtk-doc while building on Windows')
-elif get_option('disable_gtkdoc')
-  message('gtk-doc is disabled via options')
 else
-  if find_program('gtkdoc-scan', required : false).found()
+  if find_program('gtkdoc-scan', required : get_option('gtk_doc')).found()
     subdir('docs')
   else
     message('Not building documentation as gtk-doc was not found')
   endif
 endif
 
-python3 = find_program('python3')
 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')