meson: add 'gpl' option and only build plugins with (A)GPL deps if explicitly enabled

Require explicit opt-in to build plugins with (A)GPL dependencies.

Keep ugly/bad options on 'auto' for now so cerbero doesn't fail.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1084>
This commit is contained in:
Tim-Philipp Müller 2021-09-19 00:55:34 +01:00
parent 95eb8672a6
commit d4bdbeaa0d
22 changed files with 180 additions and 67 deletions

View file

@ -63,6 +63,7 @@ variables:
-Drtsp_server=enabled
-Dvaapi=enabled
-Dsharp=disabled
-Dgpl=enabled
MESON_GST_WERROR: >
-Dgstreamer:werror=true

View file

@ -129,6 +129,30 @@ the build files to find `libmfx`.
The plugin will be automatically enabled if possible, but you can ensure it by
passing `-Dbad=enabled -Dgst-plugins-bad:msdk=enabled` to `meson`.
### Building plugins with (A)GPL-licensed dependencies
Some plugins have GPL- or AGPL-licensed dependencies and will only be built
if you have explicitly opted in to allow (A)GPL-licensed dependencies by
passing `-Dgpl=enabled` to Meson.
List of plugins with (A)GPL-licensed dependencies (non-exhaustive) in gst-plugins-bad:
- dts (DTS audio decoder plugin)
- faad (Free AAC audio decoder plugin)
- iqa (Image quality assessment plugin based on dssim-c)
- mpeg2enc (MPEG-2 video encoder plugin)
- mplex (audio/video multiplexer plugin)
- ofa (Open Fingerprint Architecture library plugin)
- resindvd (Resin DVD playback plugin)
- x265 (HEVC/H.265 video encoder plugin)
List of plugins with (A)GPL-licensed dependencies (non-exhaustive) in gst-plugins-ugly:
- a52dec (Dolby Digital (AC-3) audio decoder plugin)
- cdio (CD audio source plugin based on libcdio)
- dvdread (DVD video source plugin based on libdvdread)
- mpeg2dec (MPEG-2 video decoder plugin based on libmpeg2)
- sidplay (Commodore 64 audio decoder plugin based on libsidplay)
- x264 (H.264 video encoder plugin based on libx264)
### Static build
Since *1.18.0* when doing a static build using `--default-library=static`, a

View file

@ -53,7 +53,8 @@ $env:MESON_ARGS = "-Dglib:installed_tests=false " +
"-Dlibav=disabled " +
"-Dvaapi=disabled " +
"-Dgst-plugins-base:pango=enabled " +
"-Dgst-plugins-good:cairo=enabled "
"-Dgst-plugins-good:cairo=enabled " +
"-Dgpl=enabled "
Write-Output "Building gst"
cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=amd64 && meson _build $env:MESON_ARGS && meson compile -C _build && ninja -C _build install"
@ -68,4 +69,4 @@ git clean -fdxx
if (!$?) {
Write-Host "Failed to git clean"
Exit 1
}
}

View file

@ -34,6 +34,10 @@ option('gst-full-device-providers', type : 'string', value : '',
option('gst-full-dynamic-types', type : 'string', value : '',
description : '''List of dynamic types to expose in gstreamer-full's ABI with the syntax plugin:dt1,dt2. By default '' will export all device provider of the enabled plugin.''')
# License-related feature options
option('gpl', type: 'feature', value: 'disabled',
description: 'Allow build of plugins that have (A)GPL-licensed dependencies')
# Common options, automatically inherited by subprojects
option('tests', type : 'feature', value : 'auto', description : 'Build tests')
option('examples', type : 'feature', value : 'auto', description : 'Build examples')

View file

@ -1,5 +1,10 @@
dts_opt = get_option('dts').require(gpl_allowed, error_message: '''
Plugin dts explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
# Don't do any dependency checks if disabled
if get_option('dts').disabled()
if dts_opt.disabled()
subdir_done()
endif
@ -9,7 +14,7 @@ if not dca_dep.found()
if cc.has_header_symbol('dca.h', 'dca_init')
dca_dep = cc.find_library('dca', required : false)
endif
if not dca_dep.found() and get_option('dts').enabled()
if not dca_dep.found() and dts_opt.enabled()
error('DTS plugin enabled, but libdca not found')
endif
endif

View file

@ -1,12 +1,22 @@
faad_opt = get_option('faad').require(gpl_allowed, error_message: '''
Plugin faad explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
if faad_opt.disabled()
faad_dep = dependency('', required: false)
subdir_done()
endif
faad_args = [ ]
have_faad = cc.has_header_symbol('neaacdec.h', 'NeAACDecOpen')
have_faad_2_7 = have_faad and cc.has_header_symbol('neaacdec.h', 'LATM')
if have_faad and not have_faad_2_7 and get_option('faad').enabled()
if have_faad and not have_faad_2_7 and faad_opt.enabled()
message('Found faad2, but too old (< v2.7.0)')
endif
faad_dep = cc.find_library('faad', required : get_option('faad'))
faad_dep = cc.find_library('faad', required : faad_opt)
if faad_dep.found() and have_faad_2_7
gstfaad = library('gstfaad',

View file

@ -516,6 +516,7 @@ plugin_init (GstPlugin * plugin)
return GST_ELEMENT_REGISTER (iqa, plugin);
}
// FIXME: effective iqa plugin license should be AGPL3+ !
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
iqa,

View file

@ -1,4 +1,9 @@
dssim_dep = dependency('dssim', required : get_option('iqa'),
iqa_opt = get_option('iqa').require(gpl_allowed, error_message: '''
Plugin iqa explicitly required via options but (A)GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow (A)GPL-licensed plugins to be built.
''')
dssim_dep = dependency('dssim', required: iqa_opt,
fallback: ['dssim', 'dssim_dep'])
if dssim_dep.found()

View file

@ -1,21 +1,26 @@
mpeg2enc_opt = get_option('mpeg2enc').require(gpl_allowed, error_message: '''
Plugin mpeg2enc explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
# mjpegtools upstream breaks API constantly and doesn't export the version in
# a header anywhere. The configure file has a lot of logic to support old
# versions, but it all seems untested and broken. Require 2.0.0. Can be changed
# if someone complains.
mjpegtools_dep = dependency('mjpegtools', version : '>=2.0.0', required : get_option('mpeg2enc'))
mpeg2enc_dep = cxx.find_library('mpeg2encpp', required : get_option('mpeg2enc'))
no_warn_args = []
foreach arg : [
'-Wno-mismatched-tags', # mjpeg headers get class/struct mixed up
'-Wno-header-guard',
]
if cxx.has_argument(arg)
no_warn_args += [arg]
endif
endforeach
mjpegtools_dep = dependency('mjpegtools', version : '>=2.0.0', required : mpeg2enc_opt)
mpeg2enc_dep = cxx.find_library('mpeg2encpp', required : mpeg2enc_opt)
if mjpegtools_dep.found() and mpeg2enc_dep.found()
no_warn_args = []
foreach arg : [
'-Wno-mismatched-tags', # mjpeg headers get class/struct mixed up
'-Wno-header-guard',
]
if cxx.has_argument(arg)
no_warn_args += [arg]
endif
endforeach
gstmpeg2enc = library('gstmpeg2enc',
'gstmpeg2enc.cc',
'gstmpeg2encoptions.cc',

View file

@ -1,6 +1,11 @@
# See: ext/mpeg2enc for note about mjpegtools dep
mjpegtools_dep = dependency('mjpegtools', version : '>=2.0.0', required : get_option('mplex'))
mplex2_dep = cxx.find_library('mplex2', required : get_option('mplex'))
mplex_opt = get_option('mplex').require(gpl_allowed, error_message: '''
Plugin mplex explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
# See: ext/mplex for note about mjpegtools dep
mjpegtools_dep = dependency('mjpegtools', version : '>=2.0.0', required : mplex_opt)
mplex2_dep = cxx.find_library('mplex2', required : mplex_opt)
if mjpegtools_dep.found() and mplex2_dep.found()
gstmplex2 = library('gstmplex',

View file

@ -1,3 +1,8 @@
resindvd_opt = get_option('resindvd').require(gpl_allowed, error_message: '''
Plugin resindvd explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
resindvd_sources = [
'gstmpegdemux.c',
'gstmpegdesc.c',
@ -10,8 +15,8 @@ resindvd_sources = [
'rsnparsetter.c',
]
dvdnav_dep = dependency('dvdnav', version : '>= 4.1.2', required : get_option('resindvd'))
dvdread_dep = dependency('dvdread', version : '>= 4.1.2', required : get_option('resindvd'))
dvdnav_dep = dependency('dvdnav', version : '>= 4.1.2', required : resindvd_opt)
dvdread_dep = dependency('dvdread', version : '>= 4.1.2', required : resindvd_opt)
if dvdnav_dep.found() and dvdread_dep.found()
gstresindvd = library('gstresindvd',

View file

@ -1,4 +1,9 @@
x265_dep = dependency('x265', required: get_option('x265'))
x265_opt = get_option('x265').require(gpl_allowed, error_message: '''
Plugin x265 explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
x265_dep = dependency('x265', required: x265_opt)
if x265_dep.found()
gstx265 = library('gstx265',
'gstx265enc.c',

View file

@ -486,6 +486,8 @@ pkgconfig.generate(
description : 'Streaming media framework, bad plugins libraries',
)
gpl_allowed = get_option('gpl').allowed()
subdir('gst-libs')
subdir('gst')
subdir('sys')
@ -559,5 +561,9 @@ if meson.version().version_compare('>= 0.54')
plugin_names += [plugin.name()]
endif
endforeach
summary({'Plugins':plugin_names}, list_sep: ', ')
summary({
'Plugins': plugin_names,
'(A)GPL license allowed': gpl_allowed,
}, list_sep: ', ')
endif

View file

@ -101,10 +101,10 @@ option('decklink', type : 'feature', value : 'auto', description : 'DeckLink aud
option('directfb', type : 'feature', value : 'auto', description : 'DirectFB video sink plugin')
option('directsound', type : 'feature', value : 'auto', description : 'Directsound audio source plugin')
option('dtls', type : 'feature', value : 'auto', description : 'DTLS encoder and decoder plugin')
option('dts', type : 'feature', value : 'auto', description : 'DTS audio decoder plugin')
option('dts', type : 'feature', value : 'auto', description : 'DTS audio decoder plugin (GPL - only built if gpl option is also enabled!)')
option('dvb', type : 'feature', value : 'auto', description : 'DVB video bin and source plugin')
option('faac', type : 'feature', value : 'auto', description : 'Free AAC audio encoder plugin')
option('faad', type : 'feature', value : 'auto', description : 'Free AAC audio decoder plugin')
option('faad', type : 'feature', value : 'auto', description : 'Free AAC audio decoder plugin (GPL - only built if gpl option is also enabled!)')
option('fbdev', type : 'feature', value : 'auto', description : 'Framebuffer video sink plugin')
option('fdkaac', type : 'feature', value : 'auto', description : 'Fraunhofer AAC audio codec plugin')
option('flite', type : 'feature', value : 'auto', description : 'Flite speech synthesizer source plugin')
@ -114,7 +114,7 @@ option('gme', type : 'feature', value : 'auto', description : 'libgme gaming con
option('gs', type : 'feature', value : 'auto', description : 'Google Cloud Storage source and sink plugin')
option('gsm', type : 'feature', value : 'auto', description : 'GSM encoder/decoder plugin')
option('ipcpipeline', type : 'feature', value : 'auto', description : 'Inter-process communication plugin')
option('iqa', type : 'feature', value : 'auto', description : 'Image quality assessment plugin')
option('iqa', type : 'feature', value : 'auto', description : 'Image quality assessment plugin (AGPL - only built if gpl option is also enabled!)')
option('kate', type : 'feature', value : 'auto', description : 'Kate subtitle parser, tagger, and codec plugin')
option('kms', type : 'feature', value : 'auto', description : 'KMS video sink plugin')
option('ladspa', type : 'feature', value : 'auto', description : 'LADSPA plugin bridge')
@ -126,8 +126,8 @@ option('lv2', type : 'feature', value : 'auto', description : 'LV2 audio plugin
option('mediafoundation', type : 'feature', value : 'auto', description : 'Microsoft Media Foundation plugin')
option('microdns', type : 'feature', value : 'auto', description : 'libmicrodns-based device provider')
option('modplug', type : 'feature', value : 'auto', description : 'ModPlug audio decoder plugin')
option('mpeg2enc', type : 'feature', value : 'auto', description : 'mpeg2enc video encoder plugin')
option('mplex', type : 'feature', value : 'auto', description : 'mplex audio/video multiplexer plugin')
option('mpeg2enc', type : 'feature', value : 'auto', description : 'mpeg2enc video encoder plugin (GPL - only built if gpl option is also enabled!)')
option('mplex', type : 'feature', value : 'auto', description : 'mplex audio/video multiplexer plugin (GPL - only built if gpl option is also enabled!)')
option('msdk', type : 'feature', value : 'auto', description : 'Intel Media SDK video encoder/decoder plugin')
option('musepack', type : 'feature', value : 'auto', description : 'libmpcdec Musepack decoder plugin')
option('neon', type : 'feature', value : 'auto', description : 'NEON HTTP source plugin')
@ -141,7 +141,7 @@ option('openmpt', type : 'feature', value : 'auto', description : 'OpenMPT modul
option('openni2', type : 'feature', value : 'auto', description : 'OpenNI2 library plugin')
option('opensles', type : 'feature', value : 'auto', description : 'OpenSL ES audio source/sink plugin')
option('opus', type : 'feature', value : 'auto', description : 'OPUS audio parser plugin')
option('resindvd', type : 'feature', value : 'auto', description : 'Resin DVD playback plugin')
option('resindvd', type : 'feature', value : 'auto', description : 'Resin DVD playback plugin (GPL - only built if gpl option is also enabled!)')
option('rsvg', type : 'feature', value : 'auto', description : 'SVG overlayer and image decoder plugin')
option('rtmp', type : 'feature', value : 'auto', description : 'RTMP video network source and sink plugin')
option('sbc', type : 'feature', value : 'auto', description : 'SBC bluetooth audio codec plugin')
@ -171,7 +171,7 @@ option('webrtcdsp', type : 'feature', value : 'auto', description : 'Plugin with
option('wildmidi', type : 'feature', value : 'auto', description : 'WildMidi midi soft synth plugin')
option('winks', type : 'feature', value : 'auto', description : 'Windows Kernel Streaming video source plugin')
option('winscreencap', type : 'feature', value : 'auto', description : 'Windows Screen Capture video source plugin')
option('x265', type : 'feature', value : 'auto', description : 'HEVC/H.265 video encoder plugin')
option('x265', type : 'feature', value : 'auto', description : 'HEVC/H.265 video encoder plugin (GPL - only built if gpl option is also enabled!)')
option('zbar', type : 'feature', value : 'auto', description : 'Barcode image scanner plugin using zbar library')
option('zxing', type : 'feature', value : 'auto', description : 'Barcode image scanner plugin using zxing-cpp library')
option('wpe', type : 'feature', value : 'auto', description : 'WPE Web browser plugin')
@ -192,6 +192,10 @@ option('sctp-internal-usrsctp', type: 'feature', value : 'enabled',
option('mfx_api', type : 'combo', choices : ['MSDK', 'oneVPL', 'auto'], value : 'auto',
description : 'Select MFX API to build against')
# License-related feature options
option('gpl', type: 'feature', value: 'auto', yield: true, # FIXME: disable by default
description: 'Allow build plugins that have (A)GPL-licensed dependencies')
# Common feature options
option('examples', type : 'feature', value : 'auto', yield : true)
option('tests', type : 'feature', value : 'auto', yield : true)

View file

@ -1,22 +1,24 @@
if get_option('a52dec').disabled()
subdir_done()
endif
a52dec_opt = get_option('a52dec').require(gpl_allowed, error_message: '''
Plugin a52dec explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
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()
have_a52_h = 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,
include_directories : [configinc],
dependencies : [gstaudio_dep, orc_dep, a52_dep],
install : true,
install_dir : plugins_install_dir,
)
pkgconfig.generate(a52dec, install_dir : plugins_pkgconfig_install_dir)
plugins += [a52dec]
if have_a52_h
a52dec = library('gsta52dec',
'gsta52dec.c',
c_args : ugly_args,
include_directories : [configinc],
dependencies : [gstaudio_dep, orc_dep, a52_dep],
install : true,
install_dir : plugins_install_dir,
)
pkgconfig.generate(a52dec, install_dir : plugins_pkgconfig_install_dir)
plugins += [a52dec]
elif a52dec_opt.enabled()
error('a52dec plugin enabled but a52.h not found')
endif
endif

View file

@ -1,4 +1,9 @@
cdio_dep = dependency('libcdio', version : '>= 0.76', required : get_option('cdio'))
cdio_opt = get_option('cdio').require(gpl_allowed, error_message: '''
Plugin cdio explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
cdio_dep = dependency('libcdio', version : '>= 0.76', required : cdio_opt)
if cdio_dep.found()
cdio = library('gstcdio',

View file

@ -1,4 +1,9 @@
dvdread_dep = dependency('dvdread', version : '>= 0.5.0', required : get_option('dvdread'))
dvdread_opt = get_option('dvdread').require(gpl_allowed, error_message: '''
Plugin dvdread explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
dvdread_dep = dependency('dvdread', version : '>= 0.5.0', required : dvdread_opt)
if gmodule_dep.found() and dvdread_dep.found()
dvdread = library('gstdvdread',

View file

@ -1,4 +1,9 @@
mpeg2_dep = dependency('libmpeg2', version : '>= 0.4.0', required : get_option('mpeg2dec'))
mpeg2dec_opt = get_option('mpeg2dec').require(gpl_allowed, error_message: '''
Plugin mpeg2dec explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
mpeg2_dep = dependency('libmpeg2', version : '>= 0.4.0', required : mpeg2dec_opt)
if mpeg2_dep.found()
mpeg2dec = library('gstmpeg2dec',

View file

@ -1,7 +1,7 @@
sidplay_option = get_option('sidplay')
if sidplay_option.disabled()
subdir_done()
endif
sidplay_option = get_option('sidplay').require(gpl_allowed, error_message: '''
Plugin sidplay explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
if not add_languages('cpp', native: false, required: sidplay_option)
subdir_done()

View file

@ -1,9 +1,14 @@
x264_opt = get_option('x264').require(gpl_allowed, error_message: '''
Plugin x264 explicitly required via options but GPL-licensed plugins disabled via options.
Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
''')
x264_sources = [
'gstx264enc.c',
'gstencoderbitrateprofilemanager.c',
]
x264_dep = dependency('x264', required : get_option('x264'),
x264_dep = dependency('x264', required : x264_opt,
fallback: ['x264', 'libx264_dep'])
if x264_dep.found()

View file

@ -271,7 +271,10 @@ if get_option('default_library') == 'shared'
plugins_pkgconfig_install_dir = disabler()
endif
gpl_allowed = get_option('gpl').allowed()
python3 = import('python').find_installation()
subdir('gst')
subdir('ext')
subdir('tests')
@ -312,5 +315,8 @@ if meson.version().version_compare('>= 0.54')
plugin_names += [plugin.name()]
endif
endforeach
summary({'Plugins':plugin_names}, list_sep: ', ')
summary({
'Plugins': plugin_names,
'(A)GPL license allowed': gpl_allowed,
}, list_sep: ', ')
endif

View file

@ -9,14 +9,18 @@ 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('a52dec', type : 'feature', value : 'auto', description : 'Dolby Digital (AC-3) audio decoder plugin based on liba52 (GPL - only built if gpl option is also enabled!)')
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')
option('cdio', type : 'feature', value : 'auto', description : 'CD audio source plugin based on libcdio (GPL - only built if gpl option is also enabled!)')
option('dvdread', type : 'feature', value : 'auto', description : 'DVD video source plugin based on libdvdread (GPL - only built if gpl option is also enabled!)')
option('mpeg2dec', type : 'feature', value : 'auto', description : 'MPEG 2 video decoder plugin based on libmpeg2 (GPL - only built if gpl option is also enabled!)')
option('sidplay', type : 'feature', value : 'auto', description : 'Commodore 64 audio decoder plugin based on libsidplay (GPL - only built if gpl option is also enabled!)')
option('x264', type : 'feature', value : 'auto', description : 'H.264 video encoder plugin based on libx264 (GPL - only built if gpl option is also enabled!)')
# License-related feature options
option('gpl', type: 'feature', value: 'auto', yield: true, # FIXME: disable by default
description: 'Allow build plugins that have GPL-licensed dependencies')
# Common feature options
option('nls', type : 'feature', value : 'auto', yield: true,
@ -36,4 +40,4 @@ option('package-name', type : 'string', yield : true,
option('package-origin', type : 'string', value : 'Unknown package origin', yield: true,
description : 'package origin URL to use in plugins')
option('doc', type : 'feature', value : 'auto', yield: true,
description: 'Enable documentation.')
description: 'Enable documentation.')