meson: add sodium option

Allow us to pick between the built-in libsodium, use the one from the
system or disable the plugin.
This commit is contained in:
Guillaume Desmottes 2020-01-17 10:23:43 +05:30
parent a43ad8f2dd
commit 1b84dd1f6b
3 changed files with 33 additions and 5 deletions

View file

@ -7,8 +7,8 @@ import shutil
import subprocess
import sys
command, meson_build_dir, meson_current_source_dir, meson_build_root, target, exclude = sys.argv[
1:7]
command, meson_build_dir, meson_current_source_dir, meson_build_root, target, exclude, extra_env = sys.argv[
1:8]
cargo_target_dir = os.path.join(meson_build_dir, 'target')
@ -26,9 +26,14 @@ pkg_config_path.append(os.path.join(
meson_build_root, 'subprojects', 'gst-plugins-base', 'pkgconfig'))
env['PKG_CONFIG_PATH'] = ':'.join(pkg_config_path)
if len(extra_env) > 0:
for e in extra_env.split(','):
k, v = e.split(':')
env[k] = v
if command == 'build':
# cargo build
ext = sys.argv[7]
ext = sys.argv[8]
cargo_cmd = ['cargo', 'build', '--all-targets',
'--manifest-path', os.path.join(
meson_current_source_dir, 'Cargo.toml'),

View file

@ -33,12 +33,12 @@ plugins_rep = {
'gst-plugin-rav1e': 'libgstrav1e',
'gst-plugin-reqwest': 'libgstreqwest',
'gst-plugin-rusoto': 'libgstrusoto',
'gst-plugin-sodium': 'libgstsodium',
'gst-plugin-threadshare': 'libgstthreadshare',
'gst-plugin-togglerecord': 'libgsttogglerecord',
}
exclude = []
extra_env = {}
if dependency('dav1d', required : get_option('dav1d')).found()
plugins_rep += {'gst-plugin-dav1d' : 'libgstrsdav1d'}
@ -46,6 +46,17 @@ else
exclude += ['gst-plugin-dav1d']
endif
sodium = get_option ('sodium')
if sodium == 'system'
dependency('libsodium')
plugins_rep += {'gst-plugin-sodium': 'libgstsodium'}
extra_env += {'SODIUM_USE_PKG_CONFIG': '1'}
elif sodium == 'built-in'
plugins_rep += {'gst-plugin-sodium': 'libgstsodium'}
else
exclude += ['gst-plugin-sodium']
endif
output = []
foreach p, lib : plugins_rep
@ -83,6 +94,13 @@ endforeach
exclude = ','.join(exclude)
# serialize extra_env
extra_env_list = []
foreach key, value : extra_env
extra_env_list += key + ':' + value
endforeach
extra_env_str = ','.join(extra_env_list)
# Always build the target so we don't have to list all source files as input
rs_plugins = custom_target('gst-plugins-rs',
build_by_default: true,
@ -98,6 +116,7 @@ rs_plugins = custom_target('gst-plugins-rs',
meson.build_root(),
target,
exclude,
extra_env_str,
ext])
# FIXME: raises a warning as the target has multiple outputs and meson will use
@ -112,5 +131,6 @@ test('tests',
meson.current_source_dir(),
meson.build_root(),
target,
exclude],
exclude,
extra_env_str],
timeout: 600)

View file

@ -1 +1,4 @@
option('dav1d', type : 'feature', value : 'auto', description : 'Build dav1d plugin')
option('sodium', type : 'combo',
choices : ['system', 'built-in', 'disabled'], value : 'built-in',
description : 'Weither to use libsodium from the system or the built-in version from the sodiumoxide crate')