From c5cddfcec4bfdef5fe1be5133203a349ba5a99be Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 27 Jul 2018 19:29:01 +0530 Subject: [PATCH] Add feature options for all plugins The only automagic dependency left is C++ availability detection. https://bugzilla.gnome.org/show_bug.cgi?id=795107 --- ext/a52dec/meson.build | 12 ++++++++++-- ext/amrnb/meson.build | 2 +- ext/amrwbdec/meson.build | 2 +- ext/cdio/meson.build | 2 +- ext/dvdread/meson.build | 5 +++-- ext/mpeg2dec/meson.build | 2 +- ext/sidplay/meson.build | 17 +++++------------ ext/x264/meson.build | 2 +- gst/meson.build | 10 +++++----- meson.build | 23 +++++++++-------------- meson_options.txt | 18 ++++++++++++++++++ 11 files changed, 55 insertions(+), 40 deletions(-) diff --git a/ext/a52dec/meson.build b/ext/a52dec/meson.build index 5ce9d7b..74e102c 100644 --- a/ext/a52dec/meson.build +++ b/ext/a52dec/meson.build @@ -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 ') +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 ') +if a52_dep.found() and have_a52_h a52dec = library('gsta52dec', 'gsta52dec.c', c_args : ugly_args, diff --git a/ext/amrnb/meson.build b/ext/amrnb/meson.build index 4d3a9eb..ad6ce2d 100644 --- a/ext/amrnb/meson.build +++ b/ext/amrnb/meson.build @@ -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', diff --git a/ext/amrwbdec/meson.build b/ext/amrwbdec/meson.build index b3aaf17..324dce1 100644 --- a/ext/amrwbdec/meson.build +++ b/ext/amrwbdec/meson.build @@ -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', diff --git a/ext/cdio/meson.build b/ext/cdio/meson.build index d2fff24..e121894 100644 --- a/ext/cdio/meson.build +++ b/ext/cdio/meson.build @@ -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', diff --git a/ext/dvdread/meson.build b/ext/dvdread/meson.build index b744c39..ae5a7a6 100644 --- a/ext/dvdread/meson.build +++ b/ext/dvdread/meson.build @@ -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', diff --git a/ext/mpeg2dec/meson.build b/ext/mpeg2dec/meson.build index 02d2a87..f06004b 100644 --- a/ext/mpeg2dec/meson.build +++ b/ext/mpeg2dec/meson.build @@ -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', diff --git a/ext/sidplay/meson.build b/ext/sidplay/meson.build index 7781938..a50c932 100644 --- a/ext/sidplay/meson.build +++ b/ext/sidplay/meson.build @@ -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 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 diff --git a/ext/x264/meson.build b/ext/x264/meson.build index 78f9cc9..428162a 100644 --- a/ext/x264/meson.build +++ b/ext/x264/meson.build @@ -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') diff --git a/gst/meson.build b/gst/meson.build index 2bc6671..19e7d2a 100644 --- a/gst/meson.build +++ b/gst/meson.build @@ -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 diff --git a/meson.build b/meson.build index f7251ae..97ac896 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/meson_options.txt b/meson_options.txt index 3864769..31c860a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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, -- 2.7.4