Release 1.19.2
[platform/upstream/gstreamer.git] / meson.build
index ad85f94..c5c78fc 100644 (file)
@@ -1,6 +1,6 @@
 project('gst-plugins-ugly', 'c',
-  version : '1.15.0.1',
-  meson_version : '>= 0.46.0',
+  version : '1.19.2',
+  meson_version : '>= 0.54',
   default_options : [ 'warning_level=1',
                       'buildtype=debugoptimized' ])
 
@@ -14,29 +14,45 @@ gst_version_micro = version_arr[2].to_int()
 else
   gst_version_nano = 0
 endif
+gst_version_is_dev = gst_version_minor % 2 == 1 and gst_version_micro < 90
 
-have_cxx = add_languages('cpp', required : false)
+have_cxx = add_languages('cpp', native: false, required: false)
 
-glib_req = '>= 2.40.0'
+glib_req = '>= 2.56.0'
 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
 
 api_version = '1.0'
 
-plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
+plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
+plugins = []
 
 cc = meson.get_compiler('c')
+if have_cxx
+  cxx = meson.get_compiler('cpp')
+endif
 
 if cc.get_id() == 'msvc'
-  # 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
-  # NOTE: Only add warnings here if you are sure they're spurious
-  add_project_arguments(
+  msvc_args = [
+      # 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
+      # NOTE: Only add warnings here if you are sure they're spurious
       '/wd4018', # implicit signed/unsigned conversion
       '/wd4146', # unary minus on unsigned (beware INT_MIN)
       '/wd4244', # lossy type conversion (e.g. double -> int)
       '/wd4305', # truncating type conversion (e.g. double -> float)
-      language : 'c')
+      cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
+
+      # Enable some warnings on MSVC to match GCC/Clang behaviour
+      '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
+      '/w14101', # 'identifier' : unreferenced local variable
+      '/w14189', # 'identifier' : local variable is initialized but not referenced
+  ]
+  if have_cxx
+    add_project_arguments(msvc_args, language: ['c', 'cpp'])
+  else
+    add_project_arguments(msvc_args, language: 'c')
+  endif
   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
   # are built with MinGW
   noseh_link_args = ['/SAFESEH:NO']
@@ -47,15 +63,8 @@ endif
 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
 endif
-
-# Symbol visibility
-if cc.has_argument('-fvisibility=hidden')
-  add_project_arguments('-fvisibility=hidden', language: 'c')
-endif
-
-# Disable strict aliasing
-if cc.has_argument('-fno-strict-aliasing')
-  add_project_arguments('-fno-strict-aliasing', language: 'c')
+if have_cxx and cxx.has_link_argument('-Wl,-Bsymbolic-functions')
+  add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'cpp')
 endif
 
 cdata = configuration_data()
@@ -81,25 +90,7 @@ foreach h : check_headers
 endforeach
 
 check_functions = [
-# check token HAVE_CPU_ALPHA
-# check token HAVE_CPU_ARM
-# check token HAVE_CPU_CRIS
-# check token HAVE_CPU_CRISV32
-# check token HAVE_CPU_HPPA
-# check token HAVE_CPU_I386
-# check token HAVE_CPU_IA64
-# check token HAVE_CPU_M68K
-# check token HAVE_CPU_MIPS
-# check token HAVE_CPU_PPC
-# check token HAVE_CPU_PPC64
-# check token HAVE_CPU_S390
-# check token HAVE_CPU_SPARC
-# check token HAVE_CPU_X86_64
-  ['HAVE_DCGETTEXT', 'dcgettext'],
-# check token HAVE_EXPERIMENTAL
-# check token HAVE_EXTERNAL
-# check token HAVE_GETTEXT
-# check token HAVE_VALGRIND
+  ['HAVE_DCGETTEXT', 'dcgettext'], # FIXME: this looks unused
 ]
 
 foreach f : check_functions
@@ -119,9 +110,6 @@ cdata.set_quoted('PACKAGE', 'gst-plugins-ugly')
 cdata.set_quoted('GST_LICENSE', 'LGPL')
 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-ugly-1.0')
 cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
-if get_option('nls')
-  cdata.set('ENABLE_NLS', 1)
-endif
 
 # GStreamer package name and origin url
 gst_package_name = get_option('package-name')
@@ -164,26 +152,31 @@ gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
     fallback : ['gst-plugins-base', 'sdp_dep'])
 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
     fallback : ['gst-plugins-base', 'rtsp_dep'])
-if host_machine.system() != 'windows'
-  gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
+gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
+    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'])
 
-orc_dep = dependency('orc-0.4', version : '>= 0.4.16', required : false)
+orc_dep = dependency('orc-0.4', version : '>= 0.4.16', required : get_option('orc'),
+    fallback : ['orc', 'orc_dep'])
 if orc_dep.found()
   cdata.set('HAVE_ORC', 1) # used by a52dec for cpu detection
 else
   cdata.set('DISABLE_ORC', 1)
 endif
 
-configure_file(output : 'config.h', configuration : cdata)
+gmodule_dep = dependency('gmodule-2.0', fallback : ['glib', 'libgmodule_dep'])
+
+if gmodule_dep.version().version_compare('< 2.67.4')
+  cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
+endif
 
 ugly_args = ['-DHAVE_CONFIG_H']
 configinc = include_directories('.')
 libsinc = include_directories('gst-libs')
 
+# Disable compiler warnings for unused variables and args if gst debug system is disabled
 if gst_dep.type_name() == 'internal'
   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
 else
@@ -192,8 +185,16 @@ else
   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')
+if gst_debug_disabled
+  message('GStreamer debug system is disabled')
+  if cc.has_argument('-Wno-unused')
+    add_project_arguments('-Wno-unused', language: 'c')
+  endif
+  if have_cxx and cxx.has_argument ('-Wno-unused')
+    add_project_arguments('-Wno-unused', language: 'cpp')
+  endif
+else
+  message('GStreamer debug system is enabled')
 endif
 
 warning_flags = [
@@ -210,6 +211,9 @@ warning_flags = [
   '-Wvla',
   '-Wpointer-arith',
   '-Waggregate-return',
+  '-fno-strict-aliasing',
+  # Symbol visibility
+  '-fvisibility=hidden',
 ]
 
 warning_c_flags = [
@@ -219,10 +223,6 @@ warning_c_flags = [
   '-Wnested-externs'
 ]
 
-if have_cxx
-  cxx = meson.get_compiler('cpp')
-endif
-
 foreach extra_arg : warning_flags
   if cc.has_argument (extra_arg)
     add_project_arguments([extra_arg], language: 'c')
@@ -238,6 +238,30 @@ foreach extra_arg : warning_c_flags
   endif
 endforeach
 
+# Define G_DISABLE_DEPRECATED for development versions
+if gst_version_is_dev
+  message('Disabling deprecated GLib API')
+  add_project_arguments('-DG_DISABLE_DEPRECATED', language: 'c')
+endif
+
+cast_checks = get_option('gobject-cast-checks')
+if cast_checks.disabled() or (cast_checks.auto() and not gst_version_is_dev)
+  message('Disabling GLib cast checks')
+  add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
+endif
+
+glib_asserts = get_option('glib-asserts')
+if glib_asserts.disabled() or (glib_asserts.auto() and not gst_version_is_dev)
+  message('Disabling GLib asserts')
+  add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
+endif
+
+glib_checks = get_option('glib-checks')
+if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
+  message('Disabling GLib checks')
+  add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
+endif
+
 presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets')
 
 pkgconfig = import('pkgconfig')
@@ -247,14 +271,48 @@ if get_option('default_library') == 'shared'
   plugins_pkgconfig_install_dir = disabler()
 endif
 
+python3 = import('python').find_installation()
 subdir('gst')
 subdir('ext')
 subdir('tests')
 
 # xgettext is optional (on Windows for instance)
-if get_option('nls') and find_program('xgettext', required : false).found()
+if find_program('xgettext', required : get_option('nls')).found()
+  cdata.set('ENABLE_NLS', 1)
   subdir('po')
 endif
+subdir('docs')
+subdir('scripts')
+
+# Set release date
+if gst_version_nano == 0
+  extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
+  run_result = run_command(extract_release_date, gst_version, files('gst-plugins-ugly.doap'))
+  if run_result.returncode() == 0
+    release_date = run_result.stdout().strip()
+    cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
+    message('Package release date: ' + release_date)
+  else
+    # Error out if our release can't be found in the .doap file
+    error(run_result.stderr())
+  endif
+endif
+
+configure_file(output : 'config.h', configuration : cdata)
 
-python3 = import('python3').find_python()
 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')
+
+if meson.version().version_compare('>= 0.54')
+  plugin_names = []
+  foreach plugin: plugins
+    # FIXME: Use str.subtring() when we can depend on Meson 0.56
+    split = plugin.name().split('gst')
+    if split.length() == 2
+      plugin_names += [split[1]]
+    else
+      warning('Need substring API in meson >= 0.56 to properly parse plugin name: ' + plugin.name())
+      plugin_names += [plugin.name()]
+    endif
+  endforeach
+  summary({'Plugins':plugin_names}, list_sep: ', ')
+endif