summaryrefslogtreecommitdiffstats
path: root/wscript
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-12 17:37:11 +0100
committerwm4 <wm4@nowhere>2017-01-12 17:45:11 +0100
commit44e06b70d504d5a9073990851a353820370f3667 (patch)
treeffda223303ae592718ae8c2daadfc40b77f37808 /wscript
parentac98ff71ddf3da7d864f149fc290fa07600b311a (diff)
downloadmpv-44e06b70d504d5a9073990851a353820370f3667.tar.bz2
mpv-44e06b70d504d5a9073990851a353820370f3667.tar.xz
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.
Diffstat (limited to 'wscript')
-rw-r--r--wscript13
1 files changed, 13 insertions, 0 deletions
diff --git a/wscript b/wscript
index 193cf70bc4..2872e2500a 100644
--- a/wscript
+++ b/wscript
@@ -68,6 +68,12 @@ build_options = [
'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',
'deps_any': [ 'libdl', 'os-win32', 'os-cygwin' ],
@@ -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):