From 1b84dd1f6b6917630a2219bc09482d05f1fc5b8e Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 17 Jan 2020 10:23:43 +0530 Subject: [PATCH] meson: add sodium option Allow us to pick between the built-in libsodium, use the one from the system or disable the plugin. --- cargo_wrapper.py | 11 ++++++++--- meson.build | 24 ++++++++++++++++++++++-- meson_options.txt | 3 +++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/cargo_wrapper.py b/cargo_wrapper.py index c8b14309..0d208dee 100644 --- a/cargo_wrapper.py +++ b/cargo_wrapper.py @@ -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'), diff --git a/meson.build b/meson.build index 916d70a0..8c6c9af3 100644 --- a/meson.build +++ b/meson.build @@ -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) diff --git a/meson_options.txt b/meson_options.txt index 59e23fe9..4adb4520 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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')