Add feature options for all plugins
authorNirbheek Chauhan <nirbheek@centricular.com>
Fri, 27 Jul 2018 13:59:01 +0000 (19:29 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Fri, 27 Jul 2018 14:04:01 +0000 (19:34 +0530)
The only automagic dependency left is C++ availability detection.

https://bugzilla.gnome.org/show_bug.cgi?id=795107

ext/a52dec/meson.build
ext/amrnb/meson.build
ext/amrwbdec/meson.build
ext/cdio/meson.build
ext/dvdread/meson.build
ext/mpeg2dec/meson.build
ext/sidplay/meson.build
ext/x264/meson.build
gst/meson.build
meson.build
meson_options.txt

index 5ce9d7b..74e102c 100644 (file)
@@ -1,6 +1,14 @@
-a52_dep = cc.find_library('a52', required : false)
+if get_option('a52dec').disabled()
+  subdir_done()
+endif
+
+a52_dep = cc.find_library('a52', required : get_option('a52dec'))
+have_a52_h = cc.has_header_symbol('a52dec/a52.h', 'a52_init', prefix : '#include <stdint.h>')
+if not have_a52_h and get_option('a52dec').enabled()
+  error('a52dec plugin enabled but a52.h not found')
+endif
 
-if a52_dep.found() and cc.has_header_symbol('a52dec/a52.h', 'a52_init', prefix : '#include <stdint.h>')
+if a52_dep.found() and have_a52_h
   a52dec = library('gsta52dec',
     'gsta52dec.c',
     c_args : ugly_args,
index 4d3a9eb..ad6ce2d 100644 (file)
@@ -1,4 +1,4 @@
-amrnb_dep = dependency('opencore-amrnb', version : '>= 0.1.3', required : false)
+amrnb_dep = dependency('opencore-amrnb', version : '>= 0.1.3', required : get_option('amrnb'))
 
 if amrnb_dep.found()
   amrnb = library('gstamrnb',
index b3aaf17..324dce1 100644 (file)
@@ -1,4 +1,4 @@
-amrwb_dep = dependency('opencore-amrwb', version : '>= 0.1.3', required : false)
+amrwb_dep = dependency('opencore-amrwb', version : '>= 0.1.3', required : get_option('amrwbdec'))
 
 if amrwb_dep.found()
   amrwbdec = library('gstamrwbdec',
index d2fff24..e121894 100644 (file)
@@ -1,4 +1,4 @@
-cdio_dep = dependency('libcdio', version : '>= 0.76', required : false)
+cdio_dep = dependency('libcdio', version : '>= 0.76', required : get_option('cdio'))
 
 if cdio_dep.found()
   cdio = library('gstcdio',
index b744c39..ae5a7a6 100644 (file)
@@ -1,5 +1,6 @@
-gmodule_dep = dependency('gmodule-2.0', required : false)
-dvdread_dep = dependency('dvdread', version : '>= 0.5.0', required : false)
+gmodule_dep = dependency('gmodule-2.0', fallback : ['glib', 'libgmodule_dep'],
+                         required : get_option('dvdread'))
+dvdread_dep = dependency('dvdread', version : '>= 0.5.0', required : get_option('dvdread'))
 
 if gmodule_dep.found() and dvdread_dep.found()
   dvdread = library('gstdvdread',
index 02d2a87..f06004b 100644 (file)
@@ -1,4 +1,4 @@
-mpeg2_dep = dependency('libmpeg2', version : '>= 0.4.0', required : false)
+mpeg2_dep = dependency('libmpeg2', version : '>= 0.4.0', required : get_option('mpeg2dec'))
 
 if mpeg2_dep.found()
   mpeg2dec = library('gstmpeg2dec',
index 7781938..a50c932 100644 (file)
@@ -1,21 +1,12 @@
 # sidplay plugin works with libsidplay 1.36.x (not 2.x.x)
 have_sidplay = false
-if add_languages('cpp')
-  extra_args = []
-  cxx = meson.get_compiler('cpp')
-  if cxx.has_argument('-fvisibility=hidden')
-    extra_args += ['-fvisibility=hidden']
-  endif
-  if cxx.has_argument('-fno-strict-aliasing')
-    extra_args += ['-fno-strict-aliasing']
-  endif
-
+if have_cxx and not get_option('sidplay').disabled()
   if cxx.has_header('sidplay/player.h')
     sid_code = '''#include <sidplay/player.h>
                   void somefunc (void) {
                     sidTune tune = sidTune(0);
                   }'''
-    sidplay_dep = cxx.find_library('sidplay', required: false)
+    sidplay_dep = cxx.find_library('sidplay', required: get_option('sidplay'))
     if sidplay_dep.found()
       have_sidplay = cxx.compiles(sid_code, dependencies: sidplay_dep, name : 'sidplay')
     endif
@@ -24,9 +15,11 @@ endif
 
 if have_sidplay
   shared_module('gstsid', 'gstsiddec.cc',
-    cpp_args : ugly_args + extra_args,
+    cpp_args : ugly_args,
     include_directories : [configinc],
     dependencies : [gstaudio_dep, sidplay_dep],
     install : true,
     install_dir : plugins_install_dir)
+elif get_option('sidplay').enabled()
+  error('sidplay plugin enabled but dependencies not found')
 endif
index 78f9cc9..428162a 100644 (file)
@@ -2,7 +2,7 @@ x264_sources = [
   'gstx264enc.c',
 ]
 
-x264_dep = dependency('x264', required : false)
+x264_dep = dependency('x264', required : get_option('x264'))
 
 if x264_dep.found()
   x264_libraries = get_option('x264_libraries')
index 2bc6671..19e7d2a 100644 (file)
@@ -1,5 +1,5 @@
-subdir('asfdemux')
-subdir('dvdlpcmdec')
-subdir('dvdsub')
-subdir('realmedia')
-subdir('xingmux')
+foreach plugin : ['asfdemux', 'dvdlpcmdec', 'dvdsub', 'realmedia', 'xingmux']
+  if not get_option(plugin).disabled()
+    subdir(plugin)
+  endif
+endforeach
index f7251ae..97ac896 100644 (file)
@@ -25,6 +25,9 @@ api_version = '1.0'
 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
 
 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
@@ -47,15 +50,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()
@@ -168,7 +164,7 @@ 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'))
 if orc_dep.found()
   cdata.set('HAVE_ORC', 1) # used by a52dec for cpu detection
 else
@@ -205,6 +201,9 @@ warning_flags = [
   '-Wvla',
   '-Wpointer-arith',
   '-Waggregate-return',
+  '-fno-strict-aliasing',
+  # Symbol visibility
+  '-fvisibility=hidden',
 ]
 
 warning_c_flags = [
@@ -214,10 +213,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')
index 3864769..31c860a 100644 (file)
@@ -1,9 +1,27 @@
 option('x264_libraries', type : 'string', value : '',
        description : 'Colon separated list of additional x264 library paths, e.g. for 10-bit version')
 
+# Feature options for plugins without external deps
+option('asfdemux', type : 'feature', value : 'auto')
+option('dvdlpcmdec', type : 'feature', value : 'auto')
+option('dvdsub', type : 'feature', value : 'auto')
+option('realmedia', type : 'feature', value : 'auto')
+option('xingmux', type : 'feature', value : 'auto')
+
+# Feature options for plugins that need external deps
+option('a52dec', type : 'feature', value : 'auto', description : 'Dolby Digital (AC-3) audio decoder plugin')
+option('amrnb', type : 'feature', value : 'auto', description : 'Adaptive Multi-Rate Narrow-Band audio codec plugin')
+option('amrwbdec', type : 'feature', value : 'auto', description : 'Adaptive Multi-Rate Wide-Band audio decoder plugin')
+option('cdio', type : 'feature', value : 'auto', description : 'CD audio source plugin')
+option('dvdread', type : 'feature', value : 'auto', description : 'DVD video source plugin')
+option('mpeg2dec', type : 'feature', value : 'auto', description : 'MPEG 2 video decoder plugin')
+option('sidplay', type : 'feature', value : 'auto', description : 'Commodore 64 audio decoder plugin')
+option('x264', type : 'feature', value : 'auto', description : 'H.264 video encoder plugin')
+
 # Common options
 option('nls', type : 'feature', value : 'auto', yield: true,
        description : 'Enable native language support (translations)')
+option('orc', type : 'feature', value : 'auto', yield : true)
 option('package-name', type : 'string', yield : true,
        description : 'package name to use in plugins')
 option('package-origin', type : 'string', value : 'Unknown package origin', yield: true,