meson: Disable plugins and related outputs if features are disabled

Previously, there was no check performed on features of plugins if these
specify GStreamer plugins. This commit adds that, and ensures that the
plugins and pkg-config targets are skipped if no outputs are to be
generated (this is already done for examples).

Closes #369

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1327>
This commit is contained in:
L. E. Segovia 2023-08-17 22:09:10 -03:00 committed by Sebastian Dröge
parent d6f42a2037
commit 31ad311d7f

View file

@ -142,21 +142,6 @@ plugins = {
'regex': {'library': 'libgstregex'},
'textwrap': {'library': 'libgsttextwrap'},
'fallbackswitch': {
'library': 'libgstfallbackswitch',
'examples': ['gtk-fallbackswitch'],
'features': ['gtk', 'gio', 'gst-plugin-gtk4'],
},
'livesync': {
'library': 'libgstlivesync',
'examples': ['gtk-livesync'],
'features': ['gtk', 'gio', 'gst-plugin-gtk4'],
},
'togglerecord': {
'library': 'libgsttogglerecord',
'examples': ['gtk-recording'],
'features': ['gtk', 'gio', 'gst-plugin-gtk4'],
},
'tracers': {'library': 'libgstrstracers'},
'uriplaylistbin': {
'library': 'libgsturiplaylistbin',
@ -263,12 +248,29 @@ if get_option('gtk4').allowed()
gtk4_features += 'x11glx'
endif
endif
plugins += {'gtk4': {
plugins += {
'gtk4': {
'library': 'libgstgtk4',
'examples': ['gtksink'],
'extra-deps': {'gtk4': '>=4.6'},
'features': gtk4_features,
}}
},
'fallbackswitch': {
'library': 'libgstfallbackswitch',
'examples': ['gtk-fallbackswitch'],
'features': ['gtk', 'gio', 'gst-plugin-gtk4'],
},
'livesync': {
'library': 'libgstlivesync',
'examples': ['gtk-livesync'],
'features': ['gtk', 'gio', 'gst-plugin-gtk4'],
},
'togglerecord': {
'library': 'libgsttogglerecord',
'examples': ['gtk-recording'],
'features': ['gtk', 'gio', 'gst-plugin-gtk4'],
},
}
endif
# Process plugins list
@ -331,11 +333,22 @@ foreach plugin_name, details: plugins
deps_cache += {dep_name: dep}
if not dep.found()
plugin_deps_found = false
break
endif
endforeach
plugin_features = details.get('features', [])
if plugin_deps_found
# Validate gst-plugin features
foreach feature: features
if feature.startswith('gst-plugin') and not packages.contains(feature)
plugin_deps_found = false
break
endif
endforeach
endif
if plugin_deps_found
packages += f'gst-plugin-@plugin_name@'
features += details.get('features', [])
features += plugin_features
extra_features = run_command('dependencies.py', meson.current_source_dir(), plugin_name,
'--feature', '--gst-version', gst_dep.version(), capture: true, check: true).stdout().strip()
if extra_features != ''
@ -385,7 +398,9 @@ endif
# get cmdline for rust
extra_env += {'RUSTC': ' '.join(rustc.cmd_array())}
rs_plugins = custom_target('gst-plugins-rs',
plugins = []
if output.length() > 0
rs_plugins = custom_target('gst-plugins-rs',
build_by_default: true,
output: output,
console: true,
@ -406,8 +421,8 @@ rs_plugins = custom_target('gst-plugins-rs',
'--depfile', '@DEPFILE@',
'--lib-suffixes', library_suffixes,
] + feature_args + extra_args)
plugins = rs_plugins.to_list()
plugins = rs_plugins.to_list()
endif
# This is used by GStreamer to static link Rust plugins into gst-full
gst_plugins = []
@ -476,7 +491,8 @@ subdir('docs')
# We don't need to pass a command as we depends on the target above
# but it is currently mandatory ( https://github.com/mesonbuild/meson/issues/8059 )
# so use python as it's guaranteed to be present on any setup
custom_target('gst-plugins-rs-pc-files',
if pc_files.length() > 0
custom_target('gst-plugins-rs-pc-files',
build_by_default: true,
output: pc_files,
console: true,
@ -484,6 +500,7 @@ custom_target('gst-plugins-rs-pc-files',
install_dir: pkgconfig_install_dir,
depends: rs_plugins,
command: [python, '-c', '""'])
endif
if get_option('webrtc').allowed()
custom_target('gst-webrtc-signalling-server',