From 44e06b70d504d5a9073990851a353820370f3667 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 12 Jan 2017 17:37:11 +0100 Subject: player: add experimental C plugin interface This basically reuses the scripting infrastructure. Note that this needs to be explicitly enabled at compilation. For one, enabling export for certain symbols from an executable seems to be quite toolchain-specific. It might not work outside of Linux and cause random problems within Linux. If C plugins actually become commonly used and this approach is starting to turn out as a problem, we can build mpv CLI as a wrapper for libmpv, which would remove the requirement that plugins pick up host symbols. I'm being lazy, so implementation/documentation are parked in existing files, even if that stuff doesn't necessarily belong there. Sue me, or better send patches. --- wscript | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'wscript') diff --git a/wscript b/wscript index 193cf70bc4..2872e2500a 100644 --- a/wscript +++ b/wscript @@ -67,6 +67,12 @@ build_options = [ 'name': 'libdl', 'desc': 'dynamic loader', 'func': check_libs(['dl'], check_statement('dlfcn.h', 'dlopen("", 0)')) + }, { + 'name': '--cplugins', + 'desc': 'C plugins', + 'deps': [ 'libdl' ], + 'default': 'disable', + 'func': check_cc(linkflags=['-Wl,-export-dynamic']), }, { 'name': 'dlopen', 'desc': 'dlopen', @@ -1059,6 +1065,13 @@ def configure(ctx): if ctx.dependency_satisfied('clang-database'): ctx.load('clang_compilation_database') + if ctx.dependency_satisfied('cplugins'): + # We need to export the libmpv symbols, since the mpv binary itself is + # not linked against libmpv. The C plugin needs to be able to pick + # up the libmpv symbols from the binary. We still restrict the set + # of exported symbols via mpv.def. + ctx.env.LINKFLAGS += ['-Wl,-export-dynamic'] + ctx.store_dependencies_lists() def __write_version__(ctx): -- cgit v1.2.3