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 5ce9d7b2857e9f1d0b747f4858a778bb32a50027..74e102cca869c962cf5f32680e18ffa2aea9c06b 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 4d3a9ebb2ce334360e485f6a8a476866e809f6fe..ad6ce2dd75e6b0d568a290eca6094c834f5a0179 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 b3aaf17e12433b06643a94063902b8fe7c470ad7..324dce1317f1f086f54b52478007cab5a1a80ac8 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 d2fff2411cc2cdde4c66b69b853f700eacfbd93d..e121894512836cf85b1a6fa6cb9959f388acc5a9 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 b744c39151d6adabbc71fee3247bedda117df107..ae5a7a611d9b765ec88c244228cb088ddfec208f 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 02d2a8796843f5bfb78d26a85c7a5ce2e8af234d..f06004bcef37eede945161d7afa0bec7371461d6 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 778193829171d9f1ef0cd55617e46e291a76f9c8..a50c9323d3adaa4faaeb0be084878d740118634a 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 78f9cc969b148873df034b908c94233fdf4fc7eb..428162a3b64e975b8f4d42dbf719ada3ac8ddfe2 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 2bc6671c60e9bb963baaa81c47927a46d339b2ce..19e7d2a8832c181d1733211c3ce6f4a858561c92 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 f7251ae5df8ecc940d364adff4a2c93fdb163f74..97ac89603ba19be935546a5b936706356bf36f83 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 386476978b889d6bab9d3ea1bebaf8a88fd269a3..31c860a882dec38aa175de5ca1b25450d67e2800 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,