summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Cerveau <scerveau@collabora.com>2020-07-16 13:18:38 +0200
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-12-11 12:50:16 +0000
commitb6f61768d381b91ce7cb9c0a568a524e85ce20cb (patch)
tree4f20945361fa5fef7f73c28959aab02b15b093e2
parentf0210bf92e4b957b8b9873a7fa211500189ca08c (diff)
gst-full: add 'gst-full-' features options
These options allow to select a set of features from a given plugin with the following syntax: -Dgst-full-plugins=plugin1;plugin10 -Dgst-full-elements=plugin2:element1,element2 -Dgst-full-typefind-functions=plugins3:func -Dgst-full-device-providers=plugin4,dp1 -Dgst-full-dynamic-types=plugin5:dt1 By default all the enabled plugin are registered and gst-full-plugins will allow to include only a set of plugin If a feature(element, typefind etc.) is selected from a plugin, the plugin is removed from the plugins list. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199>
-rw-r--r--README.md27
-rw-r--r--meson.build19
-rw-r--r--meson_options.txt10
-rw-r--r--scripts/generate_init_static_plugins.py99
4 files changed, 141 insertions, 14 deletions
diff --git a/README.md b/README.md
index 05e4c9d..ba62f49 100644
--- a/README.md
+++ b/README.md
@@ -138,6 +138,33 @@ the gstreamer-full library, allowing the linker to garbage collect unused code
and so reduce the total library size. A default script `gstreamer-full-default.map`
declares only glib/gstreamer symbols as public.
+One can use the `gst-full-plugins` option to pass a list of plugins to be registered
+in the gstreamer-full library. The default value is '*' which means that all the plugins selected
+during the build process will be registered statically. An empty value will prevent any plugins to
+be registered.
+
+One can select a specific set of features with `gst-full-elements`, `gst-full-typefind-functions`, `gst-full-device-providers` or `gst-full-dynamic-types` to select specific feature from a plugin.
+When a feature has been listed in one of those options, the other features from its plugin will no longer be automatically included, even if the plugin is listed in `gst-full-plugins`.
+
+The user must insure that all selected plugins and features (element, typefind, etc.) have been
+enabled during the build configuration.
+
+To register features, the syntax is the following:
+plugins are separated by ';' and features from a plugin starts after ':' and are ',' separated.
+
+As an example:
+ * `-Dgst-full-plugins=coreelements;playback;typefindfunctions;alsa;pbtypes`: enable only `coreelements`, `playback`, `typefindfunctions`, `alsa`, `pbtypes` plugins.
+ * `-Dgst-full-elements=coreelements:filesrc,fakesink,identity;alsa:alsasrc`: enable only `filesrc`, `identity` and `fakesink` elements from `coreelements` and `alsasrc` element from `alsa` plugin.
+ * `-Dgst-full-typefind-functions=typefindfunctions:wav,flv`: enable only typefind func `wav` and `flv` from `typefindfunctions`
+ * `-Dgst-full-device-providers=alsa:alsadeviceprovider`: enable `alsadeviceprovider` from `alsa`.
+ * `-Dgst-full-dynamic-types=pbtypes:video_multiview_flagset`: enable `video_multiview_flagset` from `pbtypes
+
+All features from the `playback` plugin will be enabled and the other plugins will be restricted to the specific features requested.
+
+All the selected features will be registered into a dedicated `NULL` plugin name.
+
+This will cause the features/plugins that are not registered to not be included in the final gstreamer-full library.
+
This is an experimental feature, backward uncompatible changes could still be
made in the future.
diff --git a/meson.build b/meson.build
index 551000e..6137302 100644
--- a/meson.build
+++ b/meson.build
@@ -249,12 +249,27 @@ libraries_map = {
if get_option('default_library') == 'static'
# Generate a .c file which declare and register all built plugins
+ plugins_names = []
+ foreach plugin: all_plugins
+ plugins_names += plugin.full_path()
+ endforeach
+ all_plugin_names = ';'.join(plugins_names)
+
+ static_plugins = get_option('gst-full-plugins')
+ if static_plugins == '*'
+ static_plugins = all_plugin_names
+ endif
generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
init_static_plugins_c = configure_file(
output: 'gstinitstaticplugins.c',
command : [generate_init_static_plugins,
- '@OUTPUT@',
- all_plugins_paths]
+ '-o ' + '@OUTPUT@',
+ '-p ' + static_plugins,
+ '-e ' + get_option('gst-full-elements'),
+ '-t ' + get_option('gst-full-typefind-functions'),
+ '-d ' + get_option('gst-full-device-providers'),
+ '-T ' + get_option('gst-full-dynamic-types')
+ ]
)
gstfull_link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions'])
diff --git a/meson_options.txt b/meson_options.txt
index 1cc6c54..818855a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -23,6 +23,16 @@ option('gst-full-libraries', type : 'array', value : [],
description : '''List of libraries to expose in gstreamer-full's ABI. gstreamer, glib and gobject are always included.''')
option('gst-full-version-script', type : 'string', value: 'gstreamer-full-default.map',
description : 'path of the version script to be used by the linker, see https://www.gnu.org/software/gnulib/manual/html_node/LD-Version-Scripts.html')
+option('gst-full-plugins', type : 'string', value : '*',
+ description : '''List of plugins to expose in gstreamer-full's ABI with the syntax plugin1;plugin2. By default '*' will export all plugins enabled by the build process.''')
+option('gst-full-elements', type : 'string', value : '',
+ description : '''List of elements to expose in gstreamer-full's ABI with the syntax plugin1;plugin2:element1,element2. By default '' will export all element of the enabled plugin.''')
+option('gst-full-typefind-functions', type : 'string', value : '',
+ description : '''List of typefind functions to expose in gstreamer-full's ABI with the syntax plugin:func1,func2. By default '' will export all typefind functions of the enabled plugin.''')
+option('gst-full-device-providers', type : 'string', value : '',
+ description : '''List of device providers to expose in gstreamer-full's ABI with the syntax plugin1:dp1;plugin2:dp1:dp2. By default '' will export all device provider of the enabled plugin.''')
+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.''')
# Common options, automatically inherited by subprojects
option('tests', type : 'feature', value : 'auto', description : 'Build tests')
diff --git a/scripts/generate_init_static_plugins.py b/scripts/generate_init_static_plugins.py
index 15725d8..5d7af8b 100644
--- a/scripts/generate_init_static_plugins.py
+++ b/scripts/generate_init_static_plugins.py
@@ -7,6 +7,10 @@ from string import Template
TEMPLATE = Template('''
#include <gst/gst.h>
+$elements_declaration
+$typefind_funcs_declaration
+$device_providers_declaration
+$dynamic_types_declaration
$plugins_declaration
void
@@ -14,30 +18,101 @@ gst_init_static_plugins (void)
{
static gsize initialization_value = 0;
if (g_once_init_enter (&initialization_value)) {
+ $elements_registration
+ $typefind_funcs_registration
+ $device_providers_registration
+ $dynamic_types_registration
$plugins_registration
+
g_once_init_leave (&initialization_value, 1);
}
}
''')
+# Retrieve the plugin name as it can be a plugin filename
+def get_plugin_name(name):
+ for p in plugins:
+ if name in p:
+ return p
+ return ''
+
+def process_features(features_list, plugins, feature_prefix):
+ plugins_list = plugins
+ feature_declaration = []
+ feature_registration = []
+ if features_list is not None:
+ feature_plugins = features_list.split(';')
+ for plugin in feature_plugins:
+ split = plugin.split(':')
+ plugin_name = split[0].strip()
+ if len(split) == 2:
+ if (get_plugin_name(plugin_name)) != '':
+ plugins_list.remove(get_plugin_name(plugin_name))
+ features = split[1].split(',')
+ for feature in features:
+ feature = feature.replace("-", "_")
+ feature_declaration += ['%s_REGISTER_DECLARE(%s);' % (feature_prefix, feature)]
+ feature_registration += ['%s_REGISTER(%s, NULL);' % (feature_prefix, feature)]
+ return (plugins_list, feature_declaration, feature_registration)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
- parser.add_argument(dest="output", help="Output file")
- parser.add_argument(dest="plugins", help="The list of plugins")
-
+ parser.add_argument('-o', dest="output", help="Output file")
+ parser.add_argument('-p','--plugins', nargs='?', default='', dest="plugins", help="The list of plugins")
+ parser.add_argument('-e', '--elements', nargs='?', default='', dest="elements", help="The list of plugin:elements")
+ parser.add_argument('-t', '--type-finds', nargs='?', default='', dest="typefindfuncs", help="The list of plugin:typefinds")
+ parser.add_argument('-d', '--devide-providers', nargs='?', default='', dest="deviceproviders", help="The list of plugin:deviceproviders")
+ parser.add_argument('-T', '--dynamic-types', nargs='?', default='', dest="dynamictypes", help="The list of plugin:dynamictypes")
options = parser.parse_args()
+ if options.output is None:
+ output_file = 'gstinitstaticplugins.c'
+ else:
+ output_file = options.output
+ enable_staticelements_plugin = 0;
+ elements_declaration = []
+ elements_registration = []
+ typefind_funcs_declaration = []
+ typefind_funcs_registration = []
+ device_providers_declaration = []
+ device_providers_registration = []
+ dynamic_types_declaration = []
+ dynamic_types_registration = []
+ plugins_declaration = []
+ plugins_registration = []
- names = set()
- for plugin in options.plugins.split(os.pathsep):
+ if options.plugins is None:
+ plugins = []
+ else:
+ plugins = options.plugins.split(';')
+
+ # process the features
+ (plugins, elements_declaration, elements_registration) = process_features(options.elements, plugins, 'GST_ELEMENT')
+ (plugins, typefind_funcs_declaration, typefind_funcs_registration) = process_features(options.typefindfuncs, plugins, 'GST_TYPE_FIND')
+ (plugins, device_providers_declaration, device_providers_registration) = process_features(options.deviceproviders, plugins, 'GST_DEVICE_PROVIDER')
+ (plugins, dynamic_types_declaration, dynamic_types_registration) = process_features(options.dynamictypes, plugins, 'GST_DYNAMIC_TYPE')
+
+ # Enable plugin or elements according to the ';' separated list.
+ for plugin in plugins:
+ split = plugin.split(':')
+ plugin_name = split[0]
+ if plugin_name == '':
+ continue
filename = os.path.basename(plugin)
if filename.startswith('libgst') and filename.endswith('.a'):
- names.add(filename[len('libgst'):-len('.a')])
-
- registration = ['GST_PLUGIN_STATIC_REGISTER(%s);' % name for name in names]
- declaration = ['GST_PLUGIN_STATIC_DECLARE(%s);' % name for name in names]
+ plugin_name = filename[len('libgst'):-len('.a')]
+ plugins_registration += ['GST_PLUGIN_STATIC_REGISTER(%s);' % (plugin_name)]
+ plugins_declaration += ['GST_PLUGIN_STATIC_DECLARE(%s);' % (plugin_name)]
- with open(options.output, "w") as f:
+ with open(output_file.strip(), "w") as f:
+ static_elements_plugin = ''
f.write(TEMPLATE.substitute({
- 'plugins_declaration': '\n'.join(declaration),
- 'plugins_registration': '\n '.join(registration),
+ 'elements_declaration': '\n'.join(elements_declaration),
+ 'elements_registration': '\n '.join(elements_registration),
+ 'typefind_funcs_declaration': '\n'.join(typefind_funcs_declaration),
+ 'typefind_funcs_registration': '\n '.join(typefind_funcs_registration),
+ 'device_providers_declaration': '\n'.join(device_providers_declaration),
+ 'device_providers_registration': '\n '.join(device_providers_registration),
+ 'dynamic_types_declaration': '\n'.join(dynamic_types_declaration),
+ 'dynamic_types_registration': '\n '.join(dynamic_types_registration),
+ 'plugins_declaration': '\n'.join(plugins_declaration),
+ 'plugins_registration': '\n '.join(plugins_registration),
}))